| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 __ bind(&success); | 803 __ bind(&success); |
| 804 __ mov(eax, Operand(esp, kJSRegExpOffset)); | 804 __ mov(eax, Operand(esp, kJSRegExpOffset)); |
| 805 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); | 805 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); |
| 806 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); | 806 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); |
| 807 // Calculate number of capture registers (number_of_captures + 1) * 2. | 807 // Calculate number of capture registers (number_of_captures + 1) * 2. |
| 808 STATIC_ASSERT(kSmiTag == 0); | 808 STATIC_ASSERT(kSmiTag == 0); |
| 809 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 809 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
| 810 __ add(edx, Immediate(2)); // edx was a smi. | 810 __ add(edx, Immediate(2)); // edx was a smi. |
| 811 | 811 |
| 812 // edx: Number of capture registers | 812 // edx: Number of capture registers |
| 813 // Load last_match_info which is still known to be a fast-elements JSObject. | 813 // Check that the last match info is a FixedArray. |
| 814 // Check that the fourth object is a JSObject. | 814 __ mov(ebx, Operand(esp, kLastMatchInfoOffset)); |
| 815 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); | 815 __ JumpIfSmi(ebx, &runtime); |
| 816 __ JumpIfSmi(eax, &runtime); | |
| 817 __ CmpObjectType(eax, JS_OBJECT_TYPE, ebx); | |
| 818 __ j(not_equal, &runtime); | |
| 819 // Check that the object has fast elements. | 816 // Check that the object has fast elements. |
| 820 __ mov(ebx, FieldOperand(eax, JSArray::kElementsOffset)); | |
| 821 __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset)); | 817 __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset)); |
| 822 __ cmp(eax, factory->fixed_array_map()); | 818 __ cmp(eax, factory->fixed_array_map()); |
| 823 __ j(not_equal, &runtime); | 819 __ j(not_equal, &runtime); |
| 824 // Check that the last match info has space for the capture registers and the | 820 // Check that the last match info has space for the capture registers and the |
| 825 // additional information. | 821 // additional information. |
| 826 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset)); | 822 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset)); |
| 827 __ SmiUntag(eax); | 823 __ SmiUntag(eax); |
| 828 __ sub(eax, Immediate(RegExpImpl::kLastMatchOverhead)); | 824 __ sub(eax, Immediate(RegExpMatchInfo::kLastMatchOverhead)); |
| 829 __ cmp(edx, eax); | 825 __ cmp(edx, eax); |
| 830 __ j(greater, &runtime); | 826 __ j(greater, &runtime); |
| 831 | 827 |
| 832 // ebx: last_match_info backing store (FixedArray) | 828 // ebx: last_match_info (FixedArray) |
| 833 // edx: number of capture registers | 829 // edx: number of capture registers |
| 834 // Store the capture count. | 830 // Store the capture count. |
| 835 __ SmiTag(edx); // Number of capture registers to smi. | 831 __ SmiTag(edx); // Number of capture registers to smi. |
| 836 __ mov(FieldOperand(ebx, RegExpImpl::kLastCaptureCountOffset), edx); | 832 __ mov(FieldOperand(ebx, RegExpMatchInfo::kNumberOfCapturesOffset), edx); |
| 837 __ SmiUntag(edx); // Number of capture registers back from smi. | 833 __ SmiUntag(edx); // Number of capture registers back from smi. |
| 838 // Store last subject and last input. | 834 // Store last subject and last input. |
| 839 __ mov(eax, Operand(esp, kSubjectOffset)); | 835 __ mov(eax, Operand(esp, kSubjectOffset)); |
| 840 __ mov(ecx, eax); | 836 __ mov(ecx, eax); |
| 841 __ mov(FieldOperand(ebx, RegExpImpl::kLastSubjectOffset), eax); | 837 __ mov(FieldOperand(ebx, RegExpMatchInfo::kLastSubjectOffset), eax); |
| 842 __ RecordWriteField(ebx, | 838 __ RecordWriteField(ebx, RegExpMatchInfo::kLastSubjectOffset, eax, edi, |
| 843 RegExpImpl::kLastSubjectOffset, | |
| 844 eax, | |
| 845 edi, | |
| 846 kDontSaveFPRegs); | 839 kDontSaveFPRegs); |
| 847 __ mov(eax, ecx); | 840 __ mov(eax, ecx); |
| 848 __ mov(FieldOperand(ebx, RegExpImpl::kLastInputOffset), eax); | 841 __ mov(FieldOperand(ebx, RegExpMatchInfo::kLastInputOffset), eax); |
| 849 __ RecordWriteField(ebx, | 842 __ RecordWriteField(ebx, RegExpMatchInfo::kLastInputOffset, eax, edi, |
| 850 RegExpImpl::kLastInputOffset, | |
| 851 eax, | |
| 852 edi, | |
| 853 kDontSaveFPRegs); | 843 kDontSaveFPRegs); |
| 854 | 844 |
| 855 // Get the static offsets vector filled by the native regexp code. | 845 // Get the static offsets vector filled by the native regexp code. |
| 856 ExternalReference address_of_static_offsets_vector = | 846 ExternalReference address_of_static_offsets_vector = |
| 857 ExternalReference::address_of_static_offsets_vector(isolate()); | 847 ExternalReference::address_of_static_offsets_vector(isolate()); |
| 858 __ mov(ecx, Immediate(address_of_static_offsets_vector)); | 848 __ mov(ecx, Immediate(address_of_static_offsets_vector)); |
| 859 | 849 |
| 860 // ebx: last_match_info backing store (FixedArray) | 850 // ebx: last_match_info (FixedArray) |
| 861 // ecx: offsets vector | 851 // ecx: offsets vector |
| 862 // edx: number of capture registers | 852 // edx: number of capture registers |
| 863 Label next_capture, done; | 853 Label next_capture, done; |
| 864 // Capture register counter starts from number of capture registers and | 854 // Capture register counter starts from number of capture registers and |
| 865 // counts down until wraping after zero. | 855 // counts down until wrapping after zero. |
| 866 __ bind(&next_capture); | 856 __ bind(&next_capture); |
| 867 __ sub(edx, Immediate(1)); | 857 __ sub(edx, Immediate(1)); |
| 868 __ j(negative, &done, Label::kNear); | 858 __ j(negative, &done, Label::kNear); |
| 869 // Read the value from the static offsets vector buffer. | 859 // Read the value from the static offsets vector buffer. |
| 870 __ mov(edi, Operand(ecx, edx, times_int_size, 0)); | 860 __ mov(edi, Operand(ecx, edx, times_int_size, 0)); |
| 871 __ SmiTag(edi); | 861 __ SmiTag(edi); |
| 872 // Store the smi value in the last match info. | 862 // Store the smi value in the last match info. |
| 873 __ mov(FieldOperand(ebx, | 863 __ mov(FieldOperand(ebx, edx, times_pointer_size, |
| 874 edx, | 864 RegExpMatchInfo::kFirstCaptureOffset), |
| 875 times_pointer_size, | 865 edi); |
| 876 RegExpImpl::kFirstCaptureOffset), | |
| 877 edi); | |
| 878 __ jmp(&next_capture); | 866 __ jmp(&next_capture); |
| 879 __ bind(&done); | 867 __ bind(&done); |
| 880 | 868 |
| 881 // Return last match info. | 869 // Return last match info. |
| 882 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); | 870 __ mov(eax, ebx); |
| 883 __ ret(4 * kPointerSize); | 871 __ ret(4 * kPointerSize); |
| 884 | 872 |
| 885 // Do the runtime call to execute the regexp. | 873 // Do the runtime call to execute the regexp. |
| 886 __ bind(&runtime); | 874 __ bind(&runtime); |
| 887 __ TailCallRuntime(Runtime::kRegExpExec); | 875 __ TailCallRuntime(Runtime::kRegExpExec); |
| 888 | 876 |
| 889 // Deferred code for string handling. | 877 // Deferred code for string handling. |
| 890 // (6) Long external string? If not, go to (10). | 878 // (6) Long external string? If not, go to (10). |
| 891 __ bind(¬_seq_nor_cons); | 879 __ bind(¬_seq_nor_cons); |
| 892 // Compare flags are still set from (3). | 880 // Compare flags are still set from (3). |
| (...skipping 4048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4941 kStackUnwindSpace, nullptr, return_value_operand, | 4929 kStackUnwindSpace, nullptr, return_value_operand, |
| 4942 NULL); | 4930 NULL); |
| 4943 } | 4931 } |
| 4944 | 4932 |
| 4945 #undef __ | 4933 #undef __ |
| 4946 | 4934 |
| 4947 } // namespace internal | 4935 } // namespace internal |
| 4948 } // namespace v8 | 4936 } // namespace v8 |
| 4949 | 4937 |
| 4950 #endif // V8_TARGET_ARCH_IA32 | 4938 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |