OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 Handle<FixedArray> data(FixedArray::cast(re->data())); | 224 Handle<FixedArray> data(FixedArray::cast(re->data())); |
225 compilation_cache->PutRegExp(pattern, flags, data); | 225 compilation_cache->PutRegExp(pattern, flags, data); |
226 | 226 |
227 return re; | 227 return re; |
228 } | 228 } |
229 | 229 |
230 | 230 |
231 Handle<Object> RegExpImpl::Exec(Handle<JSRegExp> regexp, | 231 Handle<Object> RegExpImpl::Exec(Handle<JSRegExp> regexp, |
232 Handle<String> subject, | 232 Handle<String> subject, |
233 int index, | 233 int index, |
234 Handle<JSArray> last_match_info, | 234 Handle<JSArray> last_match_info) { |
235 Zone* zone) { | |
236 switch (regexp->TypeTag()) { | 235 switch (regexp->TypeTag()) { |
237 case JSRegExp::ATOM: | 236 case JSRegExp::ATOM: |
238 return AtomExec(regexp, subject, index, last_match_info); | 237 return AtomExec(regexp, subject, index, last_match_info); |
239 case JSRegExp::IRREGEXP: { | 238 case JSRegExp::IRREGEXP: { |
240 Handle<Object> result = | 239 Handle<Object> result = |
241 IrregexpExec(regexp, subject, index, last_match_info, zone); | 240 IrregexpExec(regexp, subject, index, last_match_info); |
242 ASSERT(!result.is_null() || | 241 ASSERT(!result.is_null() || |
243 regexp->GetIsolate()->has_pending_exception()); | 242 regexp->GetIsolate()->has_pending_exception()); |
244 return result; | 243 return result; |
245 } | 244 } |
246 default: | 245 default: |
247 UNREACHABLE(); | 246 UNREACHABLE(); |
248 return Handle<Object>::null(); | 247 return Handle<Object>::null(); |
249 } | 248 } |
250 } | 249 } |
251 | 250 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 337 |
339 // Irregexp implementation. | 338 // Irregexp implementation. |
340 | 339 |
341 // Ensures that the regexp object contains a compiled version of the | 340 // Ensures that the regexp object contains a compiled version of the |
342 // source for either ASCII or non-ASCII strings. | 341 // source for either ASCII or non-ASCII strings. |
343 // If the compiled version doesn't already exist, it is compiled | 342 // If the compiled version doesn't already exist, it is compiled |
344 // from the source pattern. | 343 // from the source pattern. |
345 // If compilation fails, an exception is thrown and this function | 344 // If compilation fails, an exception is thrown and this function |
346 // returns false. | 345 // returns false. |
347 bool RegExpImpl::EnsureCompiledIrregexp( | 346 bool RegExpImpl::EnsureCompiledIrregexp( |
348 Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii, | 347 Handle<JSRegExp> re, Handle<String> sample_subject, bool is_ascii) { |
349 Zone* zone) { | |
350 Object* compiled_code = re->DataAt(JSRegExp::code_index(is_ascii)); | 348 Object* compiled_code = re->DataAt(JSRegExp::code_index(is_ascii)); |
351 #ifdef V8_INTERPRETED_REGEXP | 349 #ifdef V8_INTERPRETED_REGEXP |
352 if (compiled_code->IsByteArray()) return true; | 350 if (compiled_code->IsByteArray()) return true; |
353 #else // V8_INTERPRETED_REGEXP (RegExp native code) | 351 #else // V8_INTERPRETED_REGEXP (RegExp native code) |
354 if (compiled_code->IsCode()) return true; | 352 if (compiled_code->IsCode()) return true; |
355 #endif | 353 #endif |
356 // We could potentially have marked this as flushable, but have kept | 354 // We could potentially have marked this as flushable, but have kept |
357 // a saved version if we did not flush it yet. | 355 // a saved version if we did not flush it yet. |
358 Object* saved_code = re->DataAt(JSRegExp::saved_code_index(is_ascii)); | 356 Object* saved_code = re->DataAt(JSRegExp::saved_code_index(is_ascii)); |
359 if (saved_code->IsCode()) { | 357 if (saved_code->IsCode()) { |
360 // Reinstate the code in the original place. | 358 // Reinstate the code in the original place. |
361 re->SetDataAt(JSRegExp::code_index(is_ascii), saved_code); | 359 re->SetDataAt(JSRegExp::code_index(is_ascii), saved_code); |
362 ASSERT(compiled_code->IsSmi()); | 360 ASSERT(compiled_code->IsSmi()); |
363 return true; | 361 return true; |
364 } | 362 } |
365 return CompileIrregexp(re, sample_subject, is_ascii, zone); | 363 return CompileIrregexp(re, sample_subject, is_ascii); |
366 } | 364 } |
367 | 365 |
368 | 366 |
369 static bool CreateRegExpErrorObjectAndThrow(Handle<JSRegExp> re, | 367 static bool CreateRegExpErrorObjectAndThrow(Handle<JSRegExp> re, |
370 bool is_ascii, | 368 bool is_ascii, |
371 Handle<String> error_message, | 369 Handle<String> error_message, |
372 Isolate* isolate) { | 370 Isolate* isolate) { |
373 Factory* factory = isolate->factory(); | 371 Factory* factory = isolate->factory(); |
374 Handle<FixedArray> elements = factory->NewFixedArray(2); | 372 Handle<FixedArray> elements = factory->NewFixedArray(2); |
375 elements->set(0, re->Pattern()); | 373 elements->set(0, re->Pattern()); |
376 elements->set(1, *error_message); | 374 elements->set(1, *error_message); |
377 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); | 375 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); |
378 Handle<Object> regexp_err = | 376 Handle<Object> regexp_err = |
379 factory->NewSyntaxError("malformed_regexp", array); | 377 factory->NewSyntaxError("malformed_regexp", array); |
380 isolate->Throw(*regexp_err); | 378 isolate->Throw(*regexp_err); |
381 return false; | 379 return false; |
382 } | 380 } |
383 | 381 |
384 | 382 |
385 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, | 383 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, |
386 Handle<String> sample_subject, | 384 Handle<String> sample_subject, |
387 bool is_ascii, | 385 bool is_ascii) { |
388 Zone* zone) { | |
389 // Compile the RegExp. | 386 // Compile the RegExp. |
390 Isolate* isolate = re->GetIsolate(); | 387 Isolate* isolate = re->GetIsolate(); |
391 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); | 388 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); |
392 PostponeInterruptsScope postpone(isolate); | 389 PostponeInterruptsScope postpone(isolate); |
393 // If we had a compilation error the last time this is saved at the | 390 // If we had a compilation error the last time this is saved at the |
394 // saved code index. | 391 // saved code index. |
395 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); | 392 Object* entry = re->DataAt(JSRegExp::code_index(is_ascii)); |
396 // When arriving here entry can only be a smi, either representing an | 393 // When arriving here entry can only be a smi, either representing an |
397 // uncompiled regexp, a previous compilation error, or code that has | 394 // uncompiled regexp, a previous compilation error, or code that has |
398 // been flushed. | 395 // been flushed. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 return false; | 427 return false; |
431 } | 428 } |
432 RegExpEngine::CompilationResult result = | 429 RegExpEngine::CompilationResult result = |
433 RegExpEngine::Compile(&compile_data, | 430 RegExpEngine::Compile(&compile_data, |
434 flags.is_ignore_case(), | 431 flags.is_ignore_case(), |
435 flags.is_global(), | 432 flags.is_global(), |
436 flags.is_multiline(), | 433 flags.is_multiline(), |
437 pattern, | 434 pattern, |
438 sample_subject, | 435 sample_subject, |
439 is_ascii, | 436 is_ascii, |
440 zone); | 437 isolate->zone()); |
441 if (result.error_message != NULL) { | 438 if (result.error_message != NULL) { |
442 // Unable to compile regexp. | 439 // Unable to compile regexp. |
443 Handle<String> error_message = | 440 Handle<String> error_message = |
444 isolate->factory()->NewStringFromUtf8(CStrVector(result.error_message)); | 441 isolate->factory()->NewStringFromUtf8(CStrVector(result.error_message)); |
445 CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate); | 442 CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate); |
446 return false; | 443 return false; |
447 } | 444 } |
448 | 445 |
449 Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data())); | 446 Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data())); |
450 data->set(JSRegExp::code_index(is_ascii), result.code); | 447 data->set(JSRegExp::code_index(is_ascii), result.code); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 // Initialize compiled code entries to null. | 492 // Initialize compiled code entries to null. |
496 re->GetIsolate()->factory()->SetRegExpIrregexpData(re, | 493 re->GetIsolate()->factory()->SetRegExpIrregexpData(re, |
497 JSRegExp::IRREGEXP, | 494 JSRegExp::IRREGEXP, |
498 pattern, | 495 pattern, |
499 flags, | 496 flags, |
500 capture_count); | 497 capture_count); |
501 } | 498 } |
502 | 499 |
503 | 500 |
504 int RegExpImpl::IrregexpPrepare(Handle<JSRegExp> regexp, | 501 int RegExpImpl::IrregexpPrepare(Handle<JSRegExp> regexp, |
505 Handle<String> subject, | 502 Handle<String> subject) { |
506 Zone* zone) { | |
507 if (!subject->IsFlat()) FlattenString(subject); | 503 if (!subject->IsFlat()) FlattenString(subject); |
508 | 504 |
509 // Check the asciiness of the underlying storage. | 505 // Check the asciiness of the underlying storage. |
510 bool is_ascii = subject->IsAsciiRepresentationUnderneath(); | 506 bool is_ascii = subject->IsAsciiRepresentationUnderneath(); |
511 if (!EnsureCompiledIrregexp(regexp, subject, is_ascii, zone)) return -1; | 507 if (!EnsureCompiledIrregexp(regexp, subject, is_ascii)) return -1; |
512 | 508 |
513 #ifdef V8_INTERPRETED_REGEXP | 509 #ifdef V8_INTERPRETED_REGEXP |
514 // Byte-code regexp needs space allocated for all its registers. | 510 // Byte-code regexp needs space allocated for all its registers. |
515 return IrregexpNumberOfRegisters(FixedArray::cast(regexp->data())); | 511 return IrregexpNumberOfRegisters(FixedArray::cast(regexp->data())); |
516 #else // V8_INTERPRETED_REGEXP | 512 #else // V8_INTERPRETED_REGEXP |
517 // Native regexp only needs room to output captures. Registers are handled | 513 // Native regexp only needs room to output captures. Registers are handled |
518 // internally. | 514 // internally. |
519 return (IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())) + 1) * 2; | 515 return (IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())) + 1) * 2; |
520 #endif // V8_INTERPRETED_REGEXP | 516 #endif // V8_INTERPRETED_REGEXP |
521 } | 517 } |
(...skipping 12 matching lines...) Expand all Loading... |
534 *max_matches = size / registers_per_match; | 530 *max_matches = size / registers_per_match; |
535 return size; | 531 return size; |
536 #endif // V8_INTERPRETED_REGEXP | 532 #endif // V8_INTERPRETED_REGEXP |
537 } | 533 } |
538 | 534 |
539 | 535 |
540 int RegExpImpl::IrregexpExecRaw( | 536 int RegExpImpl::IrregexpExecRaw( |
541 Handle<JSRegExp> regexp, | 537 Handle<JSRegExp> regexp, |
542 Handle<String> subject, | 538 Handle<String> subject, |
543 int index, | 539 int index, |
544 Vector<int> output, | 540 Vector<int> output) { |
545 Zone* zone) { | |
546 Isolate* isolate = regexp->GetIsolate(); | 541 Isolate* isolate = regexp->GetIsolate(); |
547 | 542 |
548 Handle<FixedArray> irregexp(FixedArray::cast(regexp->data()), isolate); | 543 Handle<FixedArray> irregexp(FixedArray::cast(regexp->data()), isolate); |
549 | 544 |
550 ASSERT(index >= 0); | 545 ASSERT(index >= 0); |
551 ASSERT(index <= subject->length()); | 546 ASSERT(index <= subject->length()); |
552 ASSERT(subject->IsFlat()); | 547 ASSERT(subject->IsFlat()); |
553 | 548 |
554 bool is_ascii = subject->IsAsciiRepresentationUnderneath(); | 549 bool is_ascii = subject->IsAsciiRepresentationUnderneath(); |
555 | 550 |
556 #ifndef V8_INTERPRETED_REGEXP | 551 #ifndef V8_INTERPRETED_REGEXP |
557 ASSERT(output.length() >= (IrregexpNumberOfCaptures(*irregexp) + 1) * 2); | 552 ASSERT(output.length() >= (IrregexpNumberOfCaptures(*irregexp) + 1) * 2); |
558 do { | 553 do { |
559 EnsureCompiledIrregexp(regexp, subject, is_ascii, zone); | 554 EnsureCompiledIrregexp(regexp, subject, is_ascii); |
560 Handle<Code> code(IrregexpNativeCode(*irregexp, is_ascii), isolate); | 555 Handle<Code> code(IrregexpNativeCode(*irregexp, is_ascii), isolate); |
561 NativeRegExpMacroAssembler::Result res = | 556 NativeRegExpMacroAssembler::Result res = |
562 NativeRegExpMacroAssembler::Match(code, | 557 NativeRegExpMacroAssembler::Match(code, |
563 subject, | 558 subject, |
564 output.start(), | 559 output.start(), |
565 output.length(), | 560 output.length(), |
566 index, | 561 index, |
567 isolate); | 562 isolate); |
568 if (res != NativeRegExpMacroAssembler::RETRY) { | 563 if (res != NativeRegExpMacroAssembler::RETRY) { |
569 ASSERT(res != NativeRegExpMacroAssembler::EXCEPTION || | 564 ASSERT(res != NativeRegExpMacroAssembler::EXCEPTION || |
570 isolate->has_pending_exception()); | 565 isolate->has_pending_exception()); |
571 STATIC_ASSERT( | 566 STATIC_ASSERT( |
572 static_cast<int>(NativeRegExpMacroAssembler::SUCCESS) == RE_SUCCESS); | 567 static_cast<int>(NativeRegExpMacroAssembler::SUCCESS) == RE_SUCCESS); |
573 STATIC_ASSERT( | 568 STATIC_ASSERT( |
574 static_cast<int>(NativeRegExpMacroAssembler::FAILURE) == RE_FAILURE); | 569 static_cast<int>(NativeRegExpMacroAssembler::FAILURE) == RE_FAILURE); |
575 STATIC_ASSERT(static_cast<int>(NativeRegExpMacroAssembler::EXCEPTION) | 570 STATIC_ASSERT(static_cast<int>(NativeRegExpMacroAssembler::EXCEPTION) |
576 == RE_EXCEPTION); | 571 == RE_EXCEPTION); |
577 return static_cast<IrregexpResult>(res); | 572 return static_cast<IrregexpResult>(res); |
578 } | 573 } |
579 // If result is RETRY, the string has changed representation, and we | 574 // If result is RETRY, the string has changed representation, and we |
580 // must restart from scratch. | 575 // must restart from scratch. |
581 // In this case, it means we must make sure we are prepared to handle | 576 // In this case, it means we must make sure we are prepared to handle |
582 // the, potentially, different subject (the string can switch between | 577 // the, potentially, different subject (the string can switch between |
583 // being internal and external, and even between being ASCII and UC16, | 578 // being internal and external, and even between being ASCII and UC16, |
584 // but the characters are always the same). | 579 // but the characters are always the same). |
585 IrregexpPrepare(regexp, subject, zone); | 580 IrregexpPrepare(regexp, subject); |
586 is_ascii = subject->IsAsciiRepresentationUnderneath(); | 581 is_ascii = subject->IsAsciiRepresentationUnderneath(); |
587 } while (true); | 582 } while (true); |
588 UNREACHABLE(); | 583 UNREACHABLE(); |
589 return RE_EXCEPTION; | 584 return RE_EXCEPTION; |
590 #else // V8_INTERPRETED_REGEXP | 585 #else // V8_INTERPRETED_REGEXP |
591 | 586 |
592 ASSERT(output.length() >= IrregexpNumberOfRegisters(*irregexp)); | 587 ASSERT(output.length() >= IrregexpNumberOfRegisters(*irregexp)); |
593 // We must have done EnsureCompiledIrregexp, so we can get the number of | 588 // We must have done EnsureCompiledIrregexp, so we can get the number of |
594 // registers. | 589 // registers. |
595 int* register_vector = output.start(); | 590 int* register_vector = output.start(); |
(...skipping 14 matching lines...) Expand all Loading... |
610 isolate->StackOverflow(); | 605 isolate->StackOverflow(); |
611 } | 606 } |
612 return result; | 607 return result; |
613 #endif // V8_INTERPRETED_REGEXP | 608 #endif // V8_INTERPRETED_REGEXP |
614 } | 609 } |
615 | 610 |
616 | 611 |
617 Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> jsregexp, | 612 Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> jsregexp, |
618 Handle<String> subject, | 613 Handle<String> subject, |
619 int previous_index, | 614 int previous_index, |
620 Handle<JSArray> last_match_info, | 615 Handle<JSArray> last_match_info) { |
621 Zone* zone) { | |
622 Isolate* isolate = jsregexp->GetIsolate(); | 616 Isolate* isolate = jsregexp->GetIsolate(); |
623 ASSERT_EQ(jsregexp->TypeTag(), JSRegExp::IRREGEXP); | 617 ASSERT_EQ(jsregexp->TypeTag(), JSRegExp::IRREGEXP); |
624 | 618 |
625 // Prepare space for the return values. | 619 // Prepare space for the return values. |
626 #ifdef V8_INTERPRETED_REGEXP | 620 #ifdef V8_INTERPRETED_REGEXP |
627 #ifdef DEBUG | 621 #ifdef DEBUG |
628 if (FLAG_trace_regexp_bytecodes) { | 622 if (FLAG_trace_regexp_bytecodes) { |
629 String* pattern = jsregexp->Pattern(); | 623 String* pattern = jsregexp->Pattern(); |
630 PrintF("\n\nRegexp match: /%s/\n\n", *(pattern->ToCString())); | 624 PrintF("\n\nRegexp match: /%s/\n\n", *(pattern->ToCString())); |
631 PrintF("\n\nSubject string: '%s'\n\n", *(subject->ToCString())); | 625 PrintF("\n\nSubject string: '%s'\n\n", *(subject->ToCString())); |
632 } | 626 } |
633 #endif | 627 #endif |
634 #endif | 628 #endif |
635 int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject, zone); | 629 int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject); |
636 if (required_registers < 0) { | 630 if (required_registers < 0) { |
637 // Compiling failed with an exception. | 631 // Compiling failed with an exception. |
638 ASSERT(isolate->has_pending_exception()); | 632 ASSERT(isolate->has_pending_exception()); |
639 return Handle<Object>::null(); | 633 return Handle<Object>::null(); |
640 } | 634 } |
641 | 635 |
642 OffsetsVector registers(required_registers, isolate); | 636 OffsetsVector registers(required_registers, isolate); |
643 | 637 |
644 int res = RegExpImpl::IrregexpExecRaw(jsregexp, subject, previous_index, | 638 int res = RegExpImpl::IrregexpExecRaw(jsregexp, subject, previous_index, |
645 Vector<int>(registers.vector(), | 639 Vector<int>(registers.vector(), |
646 registers.length()), | 640 registers.length())); |
647 zone); | |
648 if (res == RE_SUCCESS) { | 641 if (res == RE_SUCCESS) { |
649 int capture_register_count = | 642 int capture_register_count = |
650 (IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1) * 2; | 643 (IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1) * 2; |
651 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); | 644 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); |
652 AssertNoAllocation no_gc; | 645 AssertNoAllocation no_gc; |
653 int* register_vector = registers.vector(); | 646 int* register_vector = registers.vector(); |
654 FixedArray* array = FixedArray::cast(last_match_info->elements()); | 647 FixedArray* array = FixedArray::cast(last_match_info->elements()); |
655 for (int i = 0; i < capture_register_count; i += 2) { | 648 for (int i = 0; i < capture_register_count; i += 2) { |
656 SetCapture(array, i, register_vector[i]); | 649 SetCapture(array, i, register_vector[i]); |
657 SetCapture(array, i + 1, register_vector[i + 1]); | 650 SetCapture(array, i + 1, register_vector[i + 1]); |
(...skipping 5322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5980 RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2, | 5973 RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2, |
5981 zone); | 5974 zone); |
5982 #elif V8_TARGET_ARCH_MIPS | 5975 #elif V8_TARGET_ARCH_MIPS |
5983 RegExpMacroAssemblerMIPS macro_assembler(mode, (data->capture_count + 1) * 2, | 5976 RegExpMacroAssemblerMIPS macro_assembler(mode, (data->capture_count + 1) * 2, |
5984 zone); | 5977 zone); |
5985 #endif | 5978 #endif |
5986 | 5979 |
5987 #else // V8_INTERPRETED_REGEXP | 5980 #else // V8_INTERPRETED_REGEXP |
5988 // Interpreted regexp implementation. | 5981 // Interpreted regexp implementation. |
5989 EmbeddedVector<byte, 1024> codes; | 5982 EmbeddedVector<byte, 1024> codes; |
5990 RegExpMacroAssemblerIrregexp macro_assembler(codes); | 5983 RegExpMacroAssemblerIrregexp macro_assembler(codes, zone); |
5991 #endif // V8_INTERPRETED_REGEXP | 5984 #endif // V8_INTERPRETED_REGEXP |
5992 | 5985 |
5993 // Inserted here, instead of in Assembler, because it depends on information | 5986 // Inserted here, instead of in Assembler, because it depends on information |
5994 // in the AST that isn't replicated in the Node structure. | 5987 // in the AST that isn't replicated in the Node structure. |
5995 static const int kMaxBacksearchLimit = 1024; | 5988 static const int kMaxBacksearchLimit = 1024; |
5996 if (is_end_anchored && | 5989 if (is_end_anchored && |
5997 !is_start_anchored && | 5990 !is_start_anchored && |
5998 max_length < kMaxBacksearchLimit) { | 5991 max_length < kMaxBacksearchLimit) { |
5999 macro_assembler.SetCurrentPositionFromEnd(max_length); | 5992 macro_assembler.SetCurrentPositionFromEnd(max_length); |
6000 } | 5993 } |
6001 | 5994 |
6002 if (is_global) { | 5995 if (is_global) { |
6003 macro_assembler.set_global_mode( | 5996 macro_assembler.set_global_mode( |
6004 (data->tree->min_match() > 0) | 5997 (data->tree->min_match() > 0) |
6005 ? RegExpMacroAssembler::GLOBAL_NO_ZERO_LENGTH_CHECK | 5998 ? RegExpMacroAssembler::GLOBAL_NO_ZERO_LENGTH_CHECK |
6006 : RegExpMacroAssembler::GLOBAL); | 5999 : RegExpMacroAssembler::GLOBAL); |
6007 } | 6000 } |
6008 | 6001 |
6009 return compiler.Assemble(¯o_assembler, | 6002 return compiler.Assemble(¯o_assembler, |
6010 node, | 6003 node, |
6011 data->capture_count, | 6004 data->capture_count, |
6012 pattern); | 6005 pattern); |
6013 } | 6006 } |
6014 | 6007 |
6015 | 6008 |
6016 }} // namespace v8::internal | 6009 }} // namespace v8::internal |
OLD | NEW |