OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 __ bind(&success); | 624 __ bind(&success); |
625 __ mov(eax, Operand(esp, kJSRegExpOffset)); | 625 __ mov(eax, Operand(esp, kJSRegExpOffset)); |
626 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); | 626 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); |
627 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); | 627 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); |
628 // Calculate number of capture registers (number_of_captures + 1) * 2. | 628 // Calculate number of capture registers (number_of_captures + 1) * 2. |
629 STATIC_ASSERT(kSmiTag == 0); | 629 STATIC_ASSERT(kSmiTag == 0); |
630 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 630 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
631 __ add(edx, Immediate(2)); // edx was a smi. | 631 __ add(edx, Immediate(2)); // edx was a smi. |
632 | 632 |
633 // edx: Number of capture registers | 633 // edx: Number of capture registers |
634 // Load last_match_info which is still known to be a fast-elements JSObject. | 634 // Check that the last match info is a FixedArray. |
635 // Check that the fourth object is a JSObject. | 635 __ mov(ebx, Operand(esp, kLastMatchInfoOffset)); |
636 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); | 636 __ JumpIfSmi(ebx, &runtime); |
637 __ JumpIfSmi(eax, &runtime); | 637 __ CmpObjectType(ebx, FIXED_ARRAY_TYPE, eax); |
638 __ CmpObjectType(eax, JS_OBJECT_TYPE, ebx); | |
639 __ j(not_equal, &runtime); | 638 __ j(not_equal, &runtime); |
640 // Check that the object has fast elements. | 639 // Check that the object has fast elements. |
641 __ mov(ebx, FieldOperand(eax, JSArray::kElementsOffset)); | |
642 __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset)); | 640 __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset)); |
643 __ cmp(eax, factory->fixed_array_map()); | 641 __ cmp(eax, factory->fixed_array_map()); |
644 __ j(not_equal, &runtime); | 642 __ j(not_equal, &runtime); |
645 // Check that the last match info has space for the capture registers and the | 643 // Check that the last match info has space for the capture registers and the |
646 // additional information. | 644 // additional information. |
647 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset)); | 645 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset)); |
648 __ SmiUntag(eax); | 646 __ SmiUntag(eax); |
649 __ sub(eax, Immediate(RegExpImpl::kLastMatchOverhead)); | 647 __ sub(eax, Immediate(RegExpMatchInfo::kLastMatchOverhead)); |
650 __ cmp(edx, eax); | 648 __ cmp(edx, eax); |
651 __ j(greater, &runtime); | 649 __ j(greater, &runtime); |
652 | 650 |
653 // ebx: last_match_info backing store (FixedArray) | 651 // ebx: last_match_info backing store (FixedArray) |
654 // edx: number of capture registers | 652 // edx: number of capture registers |
655 // Store the capture count. | 653 // Store the capture count. |
656 __ SmiTag(edx); // Number of capture registers to smi. | 654 __ SmiTag(edx); // Number of capture registers to smi. |
657 __ mov(FieldOperand(ebx, RegExpImpl::kLastCaptureCountOffset), edx); | 655 __ mov(FieldOperand(ebx, RegExpMatchInfo::kNumberOfCapturesOffset), edx); |
658 __ SmiUntag(edx); // Number of capture registers back from smi. | 656 __ SmiUntag(edx); // Number of capture registers back from smi. |
659 // Store last subject and last input. | 657 // Store last subject and last input. |
660 __ mov(eax, Operand(esp, kSubjectOffset)); | 658 __ mov(eax, Operand(esp, kSubjectOffset)); |
661 __ mov(ecx, eax); | 659 __ mov(ecx, eax); |
662 __ mov(FieldOperand(ebx, RegExpImpl::kLastSubjectOffset), eax); | 660 __ mov(FieldOperand(ebx, RegExpMatchInfo::kLastSubjectOffset), eax); |
663 __ RecordWriteField(ebx, RegExpImpl::kLastSubjectOffset, eax, edi, | 661 __ RecordWriteField(ebx, RegExpMatchInfo::kLastSubjectOffset, eax, edi, |
664 kDontSaveFPRegs); | 662 kDontSaveFPRegs); |
665 __ mov(eax, ecx); | 663 __ mov(eax, ecx); |
666 __ mov(FieldOperand(ebx, RegExpImpl::kLastInputOffset), eax); | 664 __ mov(FieldOperand(ebx, RegExpMatchInfo::kLastInputOffset), eax); |
667 __ RecordWriteField(ebx, RegExpImpl::kLastInputOffset, eax, edi, | 665 __ RecordWriteField(ebx, RegExpMatchInfo::kLastInputOffset, eax, edi, |
668 kDontSaveFPRegs); | 666 kDontSaveFPRegs); |
669 | 667 |
670 // Get the static offsets vector filled by the native regexp code. | 668 // Get the static offsets vector filled by the native regexp code. |
671 ExternalReference address_of_static_offsets_vector = | 669 ExternalReference address_of_static_offsets_vector = |
672 ExternalReference::address_of_static_offsets_vector(isolate()); | 670 ExternalReference::address_of_static_offsets_vector(isolate()); |
673 __ mov(ecx, Immediate(address_of_static_offsets_vector)); | 671 __ mov(ecx, Immediate(address_of_static_offsets_vector)); |
674 | 672 |
675 // ebx: last_match_info backing store (FixedArray) | 673 // ebx: last_match_info backing store (FixedArray) |
676 // ecx: offsets vector | 674 // ecx: offsets vector |
677 // edx: number of capture registers | 675 // edx: number of capture registers |
678 Label next_capture, done; | 676 Label next_capture, done; |
679 // Capture register counter starts from number of capture registers and | 677 // Capture register counter starts from number of capture registers and |
680 // counts down until wraping after zero. | 678 // counts down until wrapping after zero. |
681 __ bind(&next_capture); | 679 __ bind(&next_capture); |
682 __ sub(edx, Immediate(1)); | 680 __ sub(edx, Immediate(1)); |
683 __ j(negative, &done, Label::kNear); | 681 __ j(negative, &done, Label::kNear); |
684 // Read the value from the static offsets vector buffer. | 682 // Read the value from the static offsets vector buffer. |
685 __ mov(edi, Operand(ecx, edx, times_int_size, 0)); | 683 __ mov(edi, Operand(ecx, edx, times_int_size, 0)); |
686 __ SmiTag(edi); | 684 __ SmiTag(edi); |
687 // Store the smi value in the last match info. | 685 // Store the smi value in the last match info. |
688 __ mov(FieldOperand(ebx, | 686 __ mov(FieldOperand(ebx, edx, times_pointer_size, |
689 edx, | 687 RegExpMatchInfo::kFirstCaptureOffset), |
690 times_pointer_size, | 688 edi); |
691 RegExpImpl::kFirstCaptureOffset), | |
692 edi); | |
693 __ jmp(&next_capture); | 689 __ jmp(&next_capture); |
694 __ bind(&done); | 690 __ bind(&done); |
695 | 691 |
696 // Return last match info. | 692 // Return last match info. |
697 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); | 693 __ mov(eax, ebx); |
698 __ ret(4 * kPointerSize); | 694 __ ret(4 * kPointerSize); |
699 | 695 |
700 // Do the runtime call to execute the regexp. | 696 // Do the runtime call to execute the regexp. |
701 __ bind(&runtime); | 697 __ bind(&runtime); |
702 __ TailCallRuntime(Runtime::kRegExpExec); | 698 __ TailCallRuntime(Runtime::kRegExpExec); |
703 | 699 |
704 // Deferred code for string handling. | 700 // Deferred code for string handling. |
705 // (6) Long external string? If not, go to (10). | 701 // (6) Long external string? If not, go to (10). |
706 __ bind(¬_seq_nor_cons); | 702 __ bind(¬_seq_nor_cons); |
707 // Compare flags are still set from (3). | 703 // Compare flags are still set from (3). |
(...skipping 4027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4735 kStackUnwindSpace, nullptr, return_value_operand, | 4731 kStackUnwindSpace, nullptr, return_value_operand, |
4736 NULL); | 4732 NULL); |
4737 } | 4733 } |
4738 | 4734 |
4739 #undef __ | 4735 #undef __ |
4740 | 4736 |
4741 } // namespace internal | 4737 } // namespace internal |
4742 } // namespace v8 | 4738 } // namespace v8 |
4743 | 4739 |
4744 #endif // V8_TARGET_ARCH_X87 | 4740 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |