Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: src/jsregexp.cc

Issue 12496: Add v8::jscre namespace around jscre functions to avoid link errors with jsc ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/third_party/jscre/pcre.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 Handle<FixedArray> irregexp_data) { 371 Handle<FixedArray> irregexp_data) {
372 Factory::SetRegExpData(re, JSRegExp::IRREGEXP, pattern, flags, irregexp_data); 372 Factory::SetRegExpData(re, JSRegExp::IRREGEXP, pattern, flags, irregexp_data);
373 return re; 373 return re;
374 } 374 }
375 375
376 376
377 static inline Object* DoCompile(String* pattern, 377 static inline Object* DoCompile(String* pattern,
378 JSRegExp::Flags flags, 378 JSRegExp::Flags flags,
379 unsigned* number_of_captures, 379 unsigned* number_of_captures,
380 const char** error_message, 380 const char** error_message,
381 JscreRegExp** code) { 381 v8::jscre::JscreRegExp** code) {
382 JSRegExpIgnoreCaseOption case_option = flags.is_ignore_case() 382 v8::jscre::JSRegExpIgnoreCaseOption case_option = flags.is_ignore_case()
383 ? JSRegExpIgnoreCase 383 ? v8::jscre::JSRegExpIgnoreCase
384 : JSRegExpDoNotIgnoreCase; 384 : v8::jscre::JSRegExpDoNotIgnoreCase;
385 JSRegExpMultilineOption multiline_option = flags.is_multiline() 385 v8::jscre::JSRegExpMultilineOption multiline_option = flags.is_multiline()
386 ? JSRegExpMultiline 386 ? v8::jscre::JSRegExpMultiline
387 : JSRegExpSingleLine; 387 : v8::jscre::JSRegExpSingleLine;
388 *error_message = NULL; 388 *error_message = NULL;
389 malloc_failure = Failure::Exception(); 389 malloc_failure = Failure::Exception();
390 *code = jsRegExpCompile(pattern->GetTwoByteData(), 390 *code = v8::jscre::jsRegExpCompile(pattern->GetTwoByteData(),
391 pattern->length(), 391 pattern->length(),
392 case_option, 392 case_option,
393 multiline_option, 393 multiline_option,
394 number_of_captures, 394 number_of_captures,
395 error_message, 395 error_message,
396 &JSREMalloc, 396 &JSREMalloc,
397 &JSREFree); 397 &JSREFree);
398 if (*code == NULL && (malloc_failure->IsRetryAfterGC() || 398 if (*code == NULL && (malloc_failure->IsRetryAfterGC() ||
399 malloc_failure->IsOutOfMemoryFailure())) { 399 malloc_failure->IsOutOfMemoryFailure())) {
400 return malloc_failure; 400 return malloc_failure;
401 } else { 401 } else {
402 // It doesn't matter which object we return here, we just need to return 402 // It doesn't matter which object we return here, we just need to return
403 // a non-failure to indicate to the GC-retry code that there was no 403 // a non-failure to indicate to the GC-retry code that there was no
404 // allocation failure. 404 // allocation failure.
405 return pattern; 405 return pattern;
406 } 406 }
407 } 407 }
408 408
409 409
410 void CompileWithRetryAfterGC(Handle<String> pattern, 410 void CompileWithRetryAfterGC(Handle<String> pattern,
411 JSRegExp::Flags flags, 411 JSRegExp::Flags flags,
412 unsigned* number_of_captures, 412 unsigned* number_of_captures,
413 const char** error_message, 413 const char** error_message,
414 JscreRegExp** code) { 414 v8::jscre::JscreRegExp** code) {
415 CALL_HEAP_FUNCTION_VOID(DoCompile(*pattern, 415 CALL_HEAP_FUNCTION_VOID(DoCompile(*pattern,
416 flags, 416 flags,
417 number_of_captures, 417 number_of_captures,
418 error_message, 418 error_message,
419 code)); 419 code));
420 } 420 }
421 421
422 422
423 Handle<Object> RegExpImpl::JscreCompile(Handle<JSRegExp> re) { 423 Handle<Object> RegExpImpl::JscreCompile(Handle<JSRegExp> re) {
424 ASSERT_EQ(re->TypeTag(), JSRegExp::JSCRE); 424 ASSERT_EQ(re->TypeTag(), JSRegExp::JSCRE);
425 ASSERT(re->DataAt(JSRegExp::kJscreDataIndex)->IsUndefined()); 425 ASSERT(re->DataAt(JSRegExp::kJscreDataIndex)->IsUndefined());
426 426
427 Handle<String> pattern(re->Pattern()); 427 Handle<String> pattern(re->Pattern());
428 JSRegExp::Flags flags = re->GetFlags(); 428 JSRegExp::Flags flags = re->GetFlags();
429 429
430 Handle<String> two_byte_pattern = StringToTwoByte(pattern); 430 Handle<String> two_byte_pattern = StringToTwoByte(pattern);
431 431
432 unsigned number_of_captures; 432 unsigned number_of_captures;
433 const char* error_message = NULL; 433 const char* error_message = NULL;
434 434
435 JscreRegExp* code = NULL; 435 v8::jscre::JscreRegExp* code = NULL;
436 FlattenString(pattern); 436 FlattenString(pattern);
437 437
438 CompileWithRetryAfterGC(two_byte_pattern, 438 CompileWithRetryAfterGC(two_byte_pattern,
439 flags, 439 flags,
440 &number_of_captures, 440 &number_of_captures,
441 &error_message, 441 &error_message,
442 &code); 442 &code);
443 443
444 if (code == NULL) { 444 if (code == NULL) {
445 // Throw an exception. 445 // Throw an exception.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 int num_captures, 553 int num_captures,
554 Handle<String> subject, 554 Handle<String> subject,
555 int previous_index, 555 int previous_index,
556 const uc16* two_byte_subject, 556 const uc16* two_byte_subject,
557 int* offsets_vector, 557 int* offsets_vector,
558 int offsets_vector_length) { 558 int offsets_vector_length) {
559 int rc; 559 int rc;
560 { 560 {
561 AssertNoAllocation a; 561 AssertNoAllocation a;
562 ByteArray* internal = JscreInternal(regexp); 562 ByteArray* internal = JscreInternal(regexp);
563 const JscreRegExp* js_regexp = 563 const v8::jscre::JscreRegExp* js_regexp =
564 reinterpret_cast<JscreRegExp*>(internal->GetDataStartAddress()); 564 reinterpret_cast<v8::jscre::JscreRegExp*>(
565 internal->GetDataStartAddress());
565 566
566 LOG(RegExpExecEvent(regexp, previous_index, subject)); 567 LOG(RegExpExecEvent(regexp, previous_index, subject));
567 568
568 rc = jsRegExpExecute(js_regexp, 569 rc = v8::jscre::jsRegExpExecute(js_regexp,
569 two_byte_subject, 570 two_byte_subject,
570 subject->length(), 571 subject->length(),
571 previous_index, 572 previous_index,
572 offsets_vector, 573 offsets_vector,
573 offsets_vector_length); 574 offsets_vector_length);
574 } 575 }
575 576
576 // The KJS JavaScript engine returns null (ie, a failed match) when 577 // The KJS JavaScript engine returns null (ie, a failed match) when
577 // JSRE's internal match limit is exceeded. We duplicate that behavior here. 578 // JSRE's internal match limit is exceeded. We duplicate that behavior here.
578 if (rc == JSRegExpErrorNoMatch 579 if (rc == v8::jscre::JSRegExpErrorNoMatch
579 || rc == JSRegExpErrorHitLimit) { 580 || rc == v8::jscre::JSRegExpErrorHitLimit) {
580 return Factory::null_value(); 581 return Factory::null_value();
581 } 582 }
582 583
583 // Other JSRE errors: 584 // Other JSRE errors:
584 if (rc < 0) { 585 if (rc < 0) {
585 // Throw an exception. 586 // Throw an exception.
586 Handle<Object> code(Smi::FromInt(rc)); 587 Handle<Object> code(Smi::FromInt(rc));
587 Handle<Object> args[2] = { Factory::LookupAsciiSymbol("jsre_exec"), code }; 588 Handle<Object> args[2] = { Factory::LookupAsciiSymbol("jsre_exec"), code };
588 Handle<Object> regexp_err( 589 Handle<Object> regexp_err(
589 Factory::NewTypeError("jsre_error", HandleVector(args, 2))); 590 Factory::NewTypeError("jsre_error", HandleVector(args, 2)));
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 byte codes[1024]; 2597 byte codes[1024];
2597 IrregexpAssembler assembler(Vector<byte>(codes, 1024)); 2598 IrregexpAssembler assembler(Vector<byte>(codes, 1024));
2598 RegExpMacroAssemblerIrregexp macro_assembler(&assembler); 2599 RegExpMacroAssemblerIrregexp macro_assembler(&assembler);
2599 return compiler.Assemble(&macro_assembler, 2600 return compiler.Assemble(&macro_assembler,
2600 node, 2601 node,
2601 input->capture_count); 2602 input->capture_count);
2602 } 2603 }
2603 2604
2604 2605
2605 }} // namespace v8::internal 2606 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/third_party/jscre/pcre.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698