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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 12210143: Refactor RegExpStub to check lazily. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 10 months 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 | « src/arm/code-stubs-arm.cc ('k') | src/objects.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 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 3809 matching lines...) Expand 10 before | Expand all | Expand 10 after
3820 // esp[4]: last_match_info (expected JSArray) 3820 // esp[4]: last_match_info (expected JSArray)
3821 // esp[8]: previous index 3821 // esp[8]: previous index
3822 // esp[12]: subject string 3822 // esp[12]: subject string
3823 // esp[16]: JSRegExp object 3823 // esp[16]: JSRegExp object
3824 3824
3825 static const int kLastMatchInfoOffset = 1 * kPointerSize; 3825 static const int kLastMatchInfoOffset = 1 * kPointerSize;
3826 static const int kPreviousIndexOffset = 2 * kPointerSize; 3826 static const int kPreviousIndexOffset = 2 * kPointerSize;
3827 static const int kSubjectOffset = 3 * kPointerSize; 3827 static const int kSubjectOffset = 3 * kPointerSize;
3828 static const int kJSRegExpOffset = 4 * kPointerSize; 3828 static const int kJSRegExpOffset = 4 * kPointerSize;
3829 3829
3830 Label runtime, invoke_regexp; 3830 Label runtime;
3831 Factory* factory = masm->isolate()->factory();
3831 3832
3832 // Ensure that a RegExp stack is allocated. 3833 // Ensure that a RegExp stack is allocated.
3833 ExternalReference address_of_regexp_stack_memory_address = 3834 ExternalReference address_of_regexp_stack_memory_address =
3834 ExternalReference::address_of_regexp_stack_memory_address( 3835 ExternalReference::address_of_regexp_stack_memory_address(
3835 masm->isolate()); 3836 masm->isolate());
3836 ExternalReference address_of_regexp_stack_memory_size = 3837 ExternalReference address_of_regexp_stack_memory_size =
3837 ExternalReference::address_of_regexp_stack_memory_size(masm->isolate()); 3838 ExternalReference::address_of_regexp_stack_memory_size(masm->isolate());
3838 __ mov(ebx, Operand::StaticVariable(address_of_regexp_stack_memory_size)); 3839 __ mov(ebx, Operand::StaticVariable(address_of_regexp_stack_memory_size));
3839 __ test(ebx, ebx); 3840 __ test(ebx, ebx);
3840 __ j(zero, &runtime); 3841 __ j(zero, &runtime);
3841 3842
3842 // Check that the first argument is a JSRegExp object. 3843 // Check that the first argument is a JSRegExp object.
3843 __ mov(eax, Operand(esp, kJSRegExpOffset)); 3844 __ mov(eax, Operand(esp, kJSRegExpOffset));
3844 STATIC_ASSERT(kSmiTag == 0); 3845 STATIC_ASSERT(kSmiTag == 0);
3845 __ JumpIfSmi(eax, &runtime); 3846 __ JumpIfSmi(eax, &runtime);
3846 __ CmpObjectType(eax, JS_REGEXP_TYPE, ecx); 3847 __ CmpObjectType(eax, JS_REGEXP_TYPE, ecx);
3847 __ j(not_equal, &runtime); 3848 __ j(not_equal, &runtime);
3849
3848 // Check that the RegExp has been compiled (data contains a fixed array). 3850 // Check that the RegExp has been compiled (data contains a fixed array).
3849 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); 3851 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset));
3850 if (FLAG_debug_code) { 3852 if (FLAG_debug_code) {
3851 __ test(ecx, Immediate(kSmiTagMask)); 3853 __ test(ecx, Immediate(kSmiTagMask));
3852 __ Check(not_zero, "Unexpected type for RegExp data, FixedArray expected"); 3854 __ Check(not_zero, "Unexpected type for RegExp data, FixedArray expected");
3853 __ CmpObjectType(ecx, FIXED_ARRAY_TYPE, ebx); 3855 __ CmpObjectType(ecx, FIXED_ARRAY_TYPE, ebx);
3854 __ Check(equal, "Unexpected type for RegExp data, FixedArray expected"); 3856 __ Check(equal, "Unexpected type for RegExp data, FixedArray expected");
3855 } 3857 }
3856 3858
3857 // ecx: RegExp data (FixedArray) 3859 // ecx: RegExp data (FixedArray)
3858 // Check the type of the RegExp. Only continue if type is JSRegExp::IRREGEXP. 3860 // Check the type of the RegExp. Only continue if type is JSRegExp::IRREGEXP.
3859 __ mov(ebx, FieldOperand(ecx, JSRegExp::kDataTagOffset)); 3861 __ mov(ebx, FieldOperand(ecx, JSRegExp::kDataTagOffset));
3860 __ cmp(ebx, Immediate(Smi::FromInt(JSRegExp::IRREGEXP))); 3862 __ cmp(ebx, Immediate(Smi::FromInt(JSRegExp::IRREGEXP)));
3861 __ j(not_equal, &runtime); 3863 __ j(not_equal, &runtime);
3862 3864
3863 // ecx: RegExp data (FixedArray) 3865 // ecx: RegExp data (FixedArray)
3864 // Check that the number of captures fit in the static offsets vector buffer. 3866 // Check that the number of captures fit in the static offsets vector buffer.
3865 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); 3867 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset));
3866 // Calculate number of capture registers (number_of_captures + 1) * 2. This 3868 // Check (number_of_captures + 1) * 2 <= offsets vector size
3867 // uses the asumption that smis are 2 * their untagged value. 3869 // Or number_of_captures * 2 <= offsets vector size - 2
3870 // Multiplying by 2 comes for free since edx is smi-tagged.
3868 STATIC_ASSERT(kSmiTag == 0); 3871 STATIC_ASSERT(kSmiTag == 0);
3869 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); 3872 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1);
3870 __ add(edx, Immediate(2)); // edx was a smi. 3873 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2);
3871 // Check that the static offsets vector buffer is large enough. 3874 __ cmp(edx, Isolate::kJSRegexpStaticOffsetsVectorSize - 2);
3872 __ cmp(edx, Isolate::kJSRegexpStaticOffsetsVectorSize);
3873 __ j(above, &runtime); 3875 __ j(above, &runtime);
3874 3876
3875 // ecx: RegExp data (FixedArray)
3876 // edx: Number of capture registers
3877 // Check that the second argument is a string.
3878 __ mov(eax, Operand(esp, kSubjectOffset));
3879 __ JumpIfSmi(eax, &runtime);
3880 Condition is_string = masm->IsObjectStringType(eax, ebx, ebx);
3881 __ j(NegateCondition(is_string), &runtime);
3882 // Get the length of the string to ebx.
3883 __ mov(ebx, FieldOperand(eax, String::kLengthOffset));
3884
3885 // ebx: Length of subject string as a smi
3886 // ecx: RegExp data (FixedArray)
3887 // edx: Number of capture registers
3888 // Check that the third argument is a positive smi less than the subject
3889 // string length. A negative value will be greater (unsigned comparison).
3890 __ mov(eax, Operand(esp, kPreviousIndexOffset));
3891 __ JumpIfNotSmi(eax, &runtime);
3892 __ cmp(eax, ebx);
3893 __ j(above_equal, &runtime);
3894
3895 // ecx: RegExp data (FixedArray)
3896 // edx: Number of capture registers
3897 // Check that the fourth object is a JSArray object.
3898 __ mov(eax, Operand(esp, kLastMatchInfoOffset));
3899 __ JumpIfSmi(eax, &runtime);
3900 __ CmpObjectType(eax, JS_ARRAY_TYPE, ebx);
3901 __ j(not_equal, &runtime);
3902 // Check that the JSArray is in fast case.
3903 __ mov(ebx, FieldOperand(eax, JSArray::kElementsOffset));
3904 __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset));
3905 Factory* factory = masm->isolate()->factory();
3906 __ cmp(eax, factory->fixed_array_map());
3907 __ j(not_equal, &runtime);
3908 // Check that the last match info has space for the capture registers and the
3909 // additional information.
3910 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset));
3911 __ SmiUntag(eax);
3912 __ add(edx, Immediate(RegExpImpl::kLastMatchOverhead));
3913 __ cmp(edx, eax);
3914 __ j(greater, &runtime);
3915
3916 // Reset offset for possibly sliced string. 3877 // Reset offset for possibly sliced string.
3917 __ Set(edi, Immediate(0)); 3878 __ Set(edi, Immediate(0));
3918 // ecx: RegExp data (FixedArray)
3919 // Check the representation and encoding of the subject string.
3920 Label seq_ascii_string, seq_two_byte_string, check_code;
3921 __ mov(eax, Operand(esp, kSubjectOffset)); 3879 __ mov(eax, Operand(esp, kSubjectOffset));
3880 __ JumpIfSmi(eax, &runtime);
3881 __ mov(edx, eax); // Make a copy of the original subject string.
3922 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 3882 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
3923 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); 3883 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
3924 // First check for flat two byte string. 3884
3885 // eax: subject string
3886 // edx: subject string
3887 // ebx: subject string instance type
3888 // ecx: RegExp data (FixedArray)
3889 // Handle subject string according to its encoding and representation:
3890 // (1) Sequential two byte? If yes, go to (9).
3891 // (2) Sequential one byte? If yes, go to (6).
3892 // (3) Anything but sequential or cons? If yes, go to (7).
3893 // (4) Cons string. If the string is flat, replace subject with first string.
3894 // Otherwise bailout.
3895 // (5a) Is subject sequential two byte? If yes, go to (9).
3896 // (5b) Is subject external? If yes, go to (8).
3897 // (6) One byte sequential. Load regexp code for one byte.
3898 // (E) Carry on.
3899 /// [...]
3900
3901 // Deferred code at the end of the stub:
3902 // (7) Not a long external string? If yes, go to (10).
3903 // (8) External string. Make it, offset-wise, look like a sequential string.
3904 // (8a) Is the external string one byte? If yes, go to (6).
3905 // (9) Two byte sequential. Load regexp code for one byte. Go to (E).
3906 // (10) Short external string or not a string? If yes, bail out to runtime.
3907 // (11) Sliced string. Replace subject with parent. Go to (5a).
3908
3909 Label seq_one_byte_string /* 6 */, seq_two_byte_string /* 9 */,
3910 external_string /* 8 */, check_underlying /* 5a */,
3911 not_seq_nor_cons /* 7 */, check_code /* E */,
3912 not_long_external /* 10 */;
3913
3914 // (1) Sequential two byte? If yes, go to (9).
3925 __ and_(ebx, kIsNotStringMask | 3915 __ and_(ebx, kIsNotStringMask |
3926 kStringRepresentationMask | 3916 kStringRepresentationMask |
3927 kStringEncodingMask | 3917 kStringEncodingMask |
3928 kShortExternalStringMask); 3918 kShortExternalStringMask);
3929 STATIC_ASSERT((kStringTag | kSeqStringTag | kTwoByteStringTag) == 0); 3919 STATIC_ASSERT((kStringTag | kSeqStringTag | kTwoByteStringTag) == 0);
3930 __ j(zero, &seq_two_byte_string, Label::kNear); 3920 __ j(zero, &seq_two_byte_string); // Go to (9).
3931 // Any other flat string must be a flat ASCII string. None of the following 3921
3932 // string type tests will succeed if subject is not a string or a short 3922 // (2) Sequential one byte? If yes, go to (6).
3933 // external string. 3923 // Any other sequential string must be one byte.
3934 __ and_(ebx, Immediate(kIsNotStringMask | 3924 __ and_(ebx, Immediate(kIsNotStringMask |
3935 kStringRepresentationMask | 3925 kStringRepresentationMask |
3936 kShortExternalStringMask)); 3926 kShortExternalStringMask));
3937 __ j(zero, &seq_ascii_string, Label::kNear); 3927 __ j(zero, &seq_one_byte_string, Label::kNear); // Go to (6).
3938 3928
3939 // ebx: whether subject is a string and if yes, its string representation 3929 // (3) Anything but sequential or cons? If yes, go to (7).
3940 // Check for flat cons string or sliced string. 3930 // We check whether the subject string is a cons, since sequential strings
3941 // A flat cons string is a cons string where the second part is the empty 3931 // have already been covered.
3942 // string. In that case the subject string is just the first part of the cons
3943 // string. Also in this case the first part of the cons string is known to be
3944 // a sequential string or an external string.
3945 // In the case of a sliced string its offset has to be taken into account.
3946 Label cons_string, external_string, check_encoding;
3947 STATIC_ASSERT(kConsStringTag < kExternalStringTag); 3932 STATIC_ASSERT(kConsStringTag < kExternalStringTag);
3948 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); 3933 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag);
3949 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); 3934 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag);
3950 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); 3935 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag);
3951 __ cmp(ebx, Immediate(kExternalStringTag)); 3936 __ cmp(ebx, Immediate(kExternalStringTag));
3952 __ j(less, &cons_string); 3937 __ j(greater_equal, &not_seq_nor_cons); // Go to (7).
3953 __ j(equal, &external_string);
3954 3938
3955 // Catch non-string subject or short external string. 3939 // (4) Cons string. Check that it's flat.
3956 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); 3940 // Replace subject with first string and reload instance type.
3957 __ test(ebx, Immediate(kIsNotStringMask | kShortExternalStringTag));
3958 __ j(not_zero, &runtime);
3959
3960 // String is sliced.
3961 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset));
3962 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset));
3963 // edi: offset of sliced string, smi-tagged.
3964 // eax: parent string.
3965 __ jmp(&check_encoding, Label::kNear);
3966 // String is a cons string, check whether it is flat.
3967 __ bind(&cons_string);
3968 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), factory->empty_string()); 3941 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), factory->empty_string());
3969 __ j(not_equal, &runtime); 3942 __ j(not_equal, &runtime);
3970 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); 3943 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset));
3971 __ bind(&check_encoding); 3944 __ bind(&check_underlying);
3972 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 3945 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
3973 // eax: first part of cons string or parent of sliced string. 3946 __ mov(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
3974 // ebx: map of first part of cons string or map of parent of sliced string. 3947
3975 // Is first part of cons or parent of slice a flat two byte string? 3948 // (5a) Is subject sequential two byte? If yes, go to (9).
3976 __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), 3949 __ test_b(ebx, kStringRepresentationMask | kStringEncodingMask);
3977 kStringRepresentationMask | kStringEncodingMask);
3978 STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); 3950 STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0);
3979 __ j(zero, &seq_two_byte_string, Label::kNear); 3951 __ j(zero, &seq_two_byte_string); // Go to (9).
3980 // Any other flat string must be sequential ASCII or external. 3952 // (5b) Is subject external? If yes, go to (8).
3981 __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), 3953 __ test_b(ebx, kStringRepresentationMask);
3982 kStringRepresentationMask); 3954 // The underlying external string is never a short external string.
3983 __ j(not_zero, &external_string); 3955 STATIC_CHECK(ExternalString::kMaxShortLength < ConsString::kMinLength);
3956 STATIC_CHECK(ExternalString::kMaxShortLength < SlicedString::kMinLength);
3957 __ j(not_zero, &external_string); // Go to (8).
3984 3958
3985 __ bind(&seq_ascii_string); 3959 // eax: sequential subject string (or look-alike, external string)
3986 // eax: subject string (flat ASCII) 3960 // edx: original subject string
3987 // ecx: RegExp data (FixedArray) 3961 // ecx: RegExp data (FixedArray)
3962 // (6) One byte sequential. Load regexp code for one byte.
3963 __ bind(&seq_one_byte_string);
3964 // Load previous index and check range before edx is overwritten. We have
3965 // to use edx instead of eax here because it might have been only made to
3966 // look like a sequential string when it actually is an external string.
3967 __ mov(ebx, Operand(esp, kPreviousIndexOffset));
3968 __ JumpIfNotSmi(ebx, &runtime);
3969 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset));
3970 __ j(above_equal, &runtime);
3988 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset)); 3971 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset));
3989 __ Set(ecx, Immediate(1)); // Type is ASCII. 3972 __ Set(ecx, Immediate(1)); // Type is one byte.
3990 __ jmp(&check_code, Label::kNear);
3991 3973
3992 __ bind(&seq_two_byte_string); 3974 // (E) Carry on. String handling is done.
3993 // eax: subject string (flat two byte)
3994 // ecx: RegExp data (FixedArray)
3995 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset));
3996 __ Set(ecx, Immediate(0)); // Type is two byte.
3997
3998 __ bind(&check_code); 3975 __ bind(&check_code);
3976 // edx: irregexp code
3999 // Check that the irregexp code has been generated for the actual string 3977 // Check that the irregexp code has been generated for the actual string
4000 // encoding. If it has, the field contains a code object otherwise it contains 3978 // encoding. If it has, the field contains a code object otherwise it contains
4001 // a smi (code flushing support). 3979 // a smi (code flushing support).
4002 __ JumpIfSmi(edx, &runtime); 3980 __ JumpIfSmi(edx, &runtime);
4003 3981
4004 // eax: subject string 3982 // eax: subject string
3983 // ebx: previous index (smi)
4005 // edx: code 3984 // edx: code
4006 // ecx: encoding of subject string (1 if ASCII, 0 if two_byte); 3985 // ecx: encoding of subject string (1 if ASCII, 0 if two_byte);
4007 // Load used arguments before starting to push arguments for call to native
4008 // RegExp code to avoid handling changing stack height.
4009 __ mov(ebx, Operand(esp, kPreviousIndexOffset));
4010 __ SmiUntag(ebx); // Previous index from smi.
4011
4012 // eax: subject string
4013 // ebx: previous index
4014 // edx: code
4015 // ecx: encoding of subject string (1 if ASCII 0 if two_byte);
4016 // All checks done. Now push arguments for native regexp code. 3986 // All checks done. Now push arguments for native regexp code.
4017 Counters* counters = masm->isolate()->counters(); 3987 Counters* counters = masm->isolate()->counters();
4018 __ IncrementCounter(counters->regexp_entry_native(), 1); 3988 __ IncrementCounter(counters->regexp_entry_native(), 1);
4019 3989
4020 // Isolates: note we add an additional parameter here (isolate pointer). 3990 // Isolates: note we add an additional parameter here (isolate pointer).
4021 static const int kRegExpExecuteArguments = 9; 3991 static const int kRegExpExecuteArguments = 9;
4022 __ EnterApiExitFrame(kRegExpExecuteArguments); 3992 __ EnterApiExitFrame(kRegExpExecuteArguments);
4023 3993
4024 // Argument 9: Pass current isolate address. 3994 // Argument 9: Pass current isolate address.
4025 __ mov(Operand(esp, 8 * kPointerSize), 3995 __ mov(Operand(esp, 8 * kPointerSize),
(...skipping 10 matching lines...) Expand all
4036 // Argument 6: Set the number of capture registers to zero to force global 4006 // Argument 6: Set the number of capture registers to zero to force global
4037 // regexps to behave as non-global. This does not affect non-global regexps. 4007 // regexps to behave as non-global. This does not affect non-global regexps.
4038 __ mov(Operand(esp, 5 * kPointerSize), Immediate(0)); 4008 __ mov(Operand(esp, 5 * kPointerSize), Immediate(0));
4039 4009
4040 // Argument 5: static offsets vector buffer. 4010 // Argument 5: static offsets vector buffer.
4041 __ mov(Operand(esp, 4 * kPointerSize), 4011 __ mov(Operand(esp, 4 * kPointerSize),
4042 Immediate(ExternalReference::address_of_static_offsets_vector( 4012 Immediate(ExternalReference::address_of_static_offsets_vector(
4043 masm->isolate()))); 4013 masm->isolate())));
4044 4014
4045 // Argument 2: Previous index. 4015 // Argument 2: Previous index.
4016 __ SmiUntag(ebx);
4046 __ mov(Operand(esp, 1 * kPointerSize), ebx); 4017 __ mov(Operand(esp, 1 * kPointerSize), ebx);
4047 4018
4048 // Argument 1: Original subject string. 4019 // Argument 1: Original subject string.
4049 // The original subject is in the previous stack frame. Therefore we have to 4020 // The original subject is in the previous stack frame. Therefore we have to
4050 // use ebp, which points exactly to one pointer size below the previous esp. 4021 // use ebp, which points exactly to one pointer size below the previous esp.
4051 // (Because creating a new stack frame pushes the previous ebp onto the stack 4022 // (Because creating a new stack frame pushes the previous ebp onto the stack
4052 // and thereby moves up esp by one kPointerSize.) 4023 // and thereby moves up esp by one kPointerSize.)
4053 __ mov(esi, Operand(ebp, kSubjectOffset + kPointerSize)); 4024 __ mov(esi, Operand(ebp, kSubjectOffset + kPointerSize));
4054 __ mov(Operand(esp, 0 * kPointerSize), esi); 4025 __ mov(Operand(esp, 0 * kPointerSize), esi);
4055 4026
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
4145 __ mov(eax, Operand(esp, kJSRegExpOffset)); 4116 __ mov(eax, Operand(esp, kJSRegExpOffset));
4146 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); 4117 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset));
4147 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); 4118 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset));
4148 // Calculate number of capture registers (number_of_captures + 1) * 2. 4119 // Calculate number of capture registers (number_of_captures + 1) * 2.
4149 STATIC_ASSERT(kSmiTag == 0); 4120 STATIC_ASSERT(kSmiTag == 0);
4150 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); 4121 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1);
4151 __ add(edx, Immediate(2)); // edx was a smi. 4122 __ add(edx, Immediate(2)); // edx was a smi.
4152 4123
4153 // edx: Number of capture registers 4124 // edx: Number of capture registers
4154 // Load last_match_info which is still known to be a fast case JSArray. 4125 // Load last_match_info which is still known to be a fast case JSArray.
4126 // Check that the fourth object is a JSArray object.
4155 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); 4127 __ mov(eax, Operand(esp, kLastMatchInfoOffset));
4128 __ JumpIfSmi(eax, &runtime);
4129 __ CmpObjectType(eax, JS_ARRAY_TYPE, ebx);
4130 __ j(not_equal, &runtime);
4131 // Check that the JSArray is in fast case.
4156 __ mov(ebx, FieldOperand(eax, JSArray::kElementsOffset)); 4132 __ mov(ebx, FieldOperand(eax, JSArray::kElementsOffset));
4133 __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset));
4134 __ cmp(eax, factory->fixed_array_map());
4135 __ j(not_equal, &runtime);
4136 // Check that the last match info has space for the capture registers and the
4137 // additional information.
4138 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset));
4139 __ SmiUntag(eax);
4140 __ sub(eax, Immediate(RegExpImpl::kLastMatchOverhead));
4141 __ cmp(edx, eax);
4142 __ j(greater, &runtime);
4157 4143
4158 // ebx: last_match_info backing store (FixedArray) 4144 // ebx: last_match_info backing store (FixedArray)
4159 // edx: number of capture registers 4145 // edx: number of capture registers
4160 // Store the capture count. 4146 // Store the capture count.
4161 __ SmiTag(edx); // Number of capture registers to smi. 4147 __ SmiTag(edx); // Number of capture registers to smi.
4162 __ mov(FieldOperand(ebx, RegExpImpl::kLastCaptureCountOffset), edx); 4148 __ mov(FieldOperand(ebx, RegExpImpl::kLastCaptureCountOffset), edx);
4163 __ SmiUntag(edx); // Number of capture registers back from smi. 4149 __ SmiUntag(edx); // Number of capture registers back from smi.
4164 // Store last subject and last input. 4150 // Store last subject and last input.
4165 __ mov(eax, Operand(esp, kSubjectOffset)); 4151 __ mov(eax, Operand(esp, kSubjectOffset));
4152 __ mov(ecx, eax);
4166 __ mov(FieldOperand(ebx, RegExpImpl::kLastSubjectOffset), eax); 4153 __ mov(FieldOperand(ebx, RegExpImpl::kLastSubjectOffset), eax);
4167 __ RecordWriteField(ebx, 4154 __ RecordWriteField(ebx,
4168 RegExpImpl::kLastSubjectOffset, 4155 RegExpImpl::kLastSubjectOffset,
4169 eax, 4156 eax,
4170 edi, 4157 edi,
4171 kDontSaveFPRegs); 4158 kDontSaveFPRegs);
4172 __ mov(eax, Operand(esp, kSubjectOffset)); 4159 __ mov(eax, ecx);
4173 __ mov(FieldOperand(ebx, RegExpImpl::kLastInputOffset), eax); 4160 __ mov(FieldOperand(ebx, RegExpImpl::kLastInputOffset), eax);
4174 __ RecordWriteField(ebx, 4161 __ RecordWriteField(ebx,
4175 RegExpImpl::kLastInputOffset, 4162 RegExpImpl::kLastInputOffset,
4176 eax, 4163 eax,
4177 edi, 4164 edi,
4178 kDontSaveFPRegs); 4165 kDontSaveFPRegs);
4179 4166
4180 // Get the static offsets vector filled by the native regexp code. 4167 // Get the static offsets vector filled by the native regexp code.
4181 ExternalReference address_of_static_offsets_vector = 4168 ExternalReference address_of_static_offsets_vector =
4182 ExternalReference::address_of_static_offsets_vector(masm->isolate()); 4169 ExternalReference::address_of_static_offsets_vector(masm->isolate());
(...skipping 17 matching lines...) Expand all
4200 times_pointer_size, 4187 times_pointer_size,
4201 RegExpImpl::kFirstCaptureOffset), 4188 RegExpImpl::kFirstCaptureOffset),
4202 edi); 4189 edi);
4203 __ jmp(&next_capture); 4190 __ jmp(&next_capture);
4204 __ bind(&done); 4191 __ bind(&done);
4205 4192
4206 // Return last match info. 4193 // Return last match info.
4207 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); 4194 __ mov(eax, Operand(esp, kLastMatchInfoOffset));
4208 __ ret(4 * kPointerSize); 4195 __ ret(4 * kPointerSize);
4209 4196
4210 // External string. Short external strings have already been ruled out. 4197 // Do the runtime call to execute the regexp.
4211 // eax: subject string (expected to be external) 4198 __ bind(&runtime);
4212 // ebx: scratch 4199 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
4200
4201 // Deferred code for string handling.
4202 // (7) Not a long external string? If yes, go to (10).
4203 __ bind(&not_seq_nor_cons);
4204 // Compare flags are still set from (3).
4205 __ j(greater, &not_long_external, Label::kNear); // Go to (10).
4206
4207 // (8) External string. Short external strings have been ruled out.
4213 __ bind(&external_string); 4208 __ bind(&external_string);
4209 // Reload instance type.
4214 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 4210 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
4215 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); 4211 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
4216 if (FLAG_debug_code) { 4212 if (FLAG_debug_code) {
4217 // Assert that we do not have a cons or slice (indirect strings) here. 4213 // Assert that we do not have a cons or slice (indirect strings) here.
4218 // Sequential strings have already been ruled out. 4214 // Sequential strings have already been ruled out.
4219 __ test_b(ebx, kIsIndirectStringMask); 4215 __ test_b(ebx, kIsIndirectStringMask);
4220 __ Assert(zero, "external string expected, but not found"); 4216 __ Assert(zero, "external string expected, but not found");
4221 } 4217 }
4222 __ mov(eax, FieldOperand(eax, ExternalString::kResourceDataOffset)); 4218 __ mov(eax, FieldOperand(eax, ExternalString::kResourceDataOffset));
4223 // Move the pointer so that offset-wise, it looks like a sequential string. 4219 // Move the pointer so that offset-wise, it looks like a sequential string.
4224 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); 4220 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize);
4225 __ sub(eax, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); 4221 __ sub(eax, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
4226 STATIC_ASSERT(kTwoByteStringTag == 0); 4222 STATIC_ASSERT(kTwoByteStringTag == 0);
4223 // (8a) Is the external string one byte? If yes, go to (6).
4227 __ test_b(ebx, kStringEncodingMask); 4224 __ test_b(ebx, kStringEncodingMask);
4228 __ j(not_zero, &seq_ascii_string); 4225 __ j(not_zero, &seq_one_byte_string); // Goto (6).
4229 __ jmp(&seq_two_byte_string);
4230 4226
4231 // Do the runtime call to execute the regexp. 4227 // eax: sequential subject string (or look-alike, external string)
4232 __ bind(&runtime); 4228 // edx: original subject string
4233 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); 4229 // ecx: RegExp data (FixedArray)
4230 // (9) Two byte sequential. Load regexp code for one byte. Go to (E).
4231 __ bind(&seq_two_byte_string);
4232 // Load previous index and check range before edx is overwritten. We have
4233 // to use edx instead of eax here because it might have been only made to
4234 // look like a sequential string when it actually is an external string.
4235 __ mov(ebx, Operand(esp, kPreviousIndexOffset));
4236 __ JumpIfNotSmi(ebx, &runtime);
4237 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset));
4238 __ j(above_equal, &runtime);
4239 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset));
4240 __ Set(ecx, Immediate(0)); // Type is two byte.
4241 __ jmp(&check_code); // Go to (E).
4242
4243 // (10) Not a string or a short external string? If yes, bail out to runtime.
4244 __ bind(&not_long_external);
4245 // Catch non-string subject or short external string.
4246 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0);
4247 __ test(ebx, Immediate(kIsNotStringMask | kShortExternalStringTag));
4248 __ j(not_zero, &runtime);
4249
4250 // (11) Sliced string. Replace subject with parent. Go to (5a).
4251 // Load offset into edi and replace subject string with parent.
4252 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset));
4253 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset));
4254 __ jmp(&check_underlying); // Go to (5a).
4234 #endif // V8_INTERPRETED_REGEXP 4255 #endif // V8_INTERPRETED_REGEXP
4235 } 4256 }
4236 4257
4237 4258
4238 void RegExpConstructResultStub::Generate(MacroAssembler* masm) { 4259 void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
4239 const int kMaxInlineLength = 100; 4260 const int kMaxInlineLength = 100;
4240 Label slowcase; 4261 Label slowcase;
4241 Label done; 4262 Label done;
4242 __ mov(ebx, Operand(esp, kPointerSize * 3)); 4263 __ mov(ebx, Operand(esp, kPointerSize * 3));
4243 __ JumpIfNotSmi(ebx, &slowcase); 4264 __ JumpIfNotSmi(ebx, &slowcase);
(...skipping 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after
7696 // Restore ecx. 7717 // Restore ecx.
7697 __ pop(ecx); 7718 __ pop(ecx);
7698 __ ret(0); 7719 __ ret(0);
7699 } 7720 }
7700 7721
7701 #undef __ 7722 #undef __
7702 7723
7703 } } // namespace v8::internal 7724 } } // namespace v8::internal
7704 7725
7705 #endif // V8_TARGET_ARCH_IA32 7726 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698