OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 StringCharacterPosition(subject_ptr, start_offset); | 136 StringCharacterPosition(subject_ptr, start_offset); |
137 int byte_length = char_length << char_size_shift; | 137 int byte_length = char_length << char_size_shift; |
138 const byte* input_end = input_start + byte_length; | 138 const byte* input_end = input_start + byte_length; |
139 Result res = Execute(*regexp_code, | 139 Result res = Execute(*regexp_code, |
140 subject_ptr, | 140 subject_ptr, |
141 start_offset, | 141 start_offset, |
142 input_start, | 142 input_start, |
143 input_end, | 143 input_end, |
144 offsets_vector, | 144 offsets_vector, |
145 previous_index == 0); | 145 previous_index == 0); |
146 | |
147 if (res == SUCCESS) { | |
148 // Capture values are relative to start_offset only. | |
149 // Convert them to be relative to start of string. | |
150 for (int i = 0; i < offsets_vector_length; i++) { | |
151 if (offsets_vector[i] >= 0) { | |
152 offsets_vector[i] += previous_index; | |
153 } | |
154 } | |
155 } | |
156 | |
157 return res; | 146 return res; |
158 } | 147 } |
159 | 148 |
160 | 149 |
161 NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute( | 150 NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute( |
162 Code* code, | 151 Code* code, |
163 String* input, | 152 String* input, |
164 int start_offset, | 153 int start_offset, |
165 const byte* input_start, | 154 const byte* input_start, |
166 const byte* input_end, | 155 const byte* input_end, |
167 int* output, | 156 int* output, |
168 bool at_start) { | 157 bool at_start) { |
169 typedef int (*matcher)(String*, int, const byte*, | 158 typedef int (*matcher)(String*, int, const byte*, |
170 const byte*, int*, int, Address); | 159 const byte*, int*, int, Address, int); |
171 matcher matcher_func = FUNCTION_CAST<matcher>(code->entry()); | 160 matcher matcher_func = FUNCTION_CAST<matcher>(code->entry()); |
172 | 161 |
173 int at_start_val = at_start ? 1 : 0; | 162 int at_start_val = at_start ? 1 : 0; |
174 | 163 |
175 // Ensure that the minimum stack has been allocated. | 164 // Ensure that the minimum stack has been allocated. |
176 RegExpStack stack; | 165 RegExpStack stack; |
177 Address stack_base = RegExpStack::stack_base(); | 166 Address stack_base = RegExpStack::stack_base(); |
178 | 167 |
| 168 int direct_call = 0; |
179 int result = CALL_GENERATED_REGEXP_CODE(matcher_func, | 169 int result = CALL_GENERATED_REGEXP_CODE(matcher_func, |
180 input, | 170 input, |
181 start_offset, | 171 start_offset, |
182 input_start, | 172 input_start, |
183 input_end, | 173 input_end, |
184 output, | 174 output, |
185 at_start_val, | 175 at_start_val, |
186 stack_base); | 176 stack_base, |
| 177 direct_call); |
187 ASSERT(result <= SUCCESS); | 178 ASSERT(result <= SUCCESS); |
188 ASSERT(result >= RETRY); | 179 ASSERT(result >= RETRY); |
189 | 180 |
190 if (result == EXCEPTION && !Top::has_pending_exception()) { | 181 if (result == EXCEPTION && !Top::has_pending_exception()) { |
191 // We detected a stack overflow (on the backtrack stack) in RegExp code, | 182 // We detected a stack overflow (on the backtrack stack) in RegExp code, |
192 // but haven't created the exception yet. | 183 // but haven't created the exception yet. |
193 Top::StackOverflow(); | 184 Top::StackOverflow(); |
194 } | 185 } |
195 return static_cast<Result>(result); | 186 return static_cast<Result>(result); |
196 } | 187 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 if (new_stack_base == NULL) { | 231 if (new_stack_base == NULL) { |
241 return NULL; | 232 return NULL; |
242 } | 233 } |
243 *stack_base = new_stack_base; | 234 *stack_base = new_stack_base; |
244 intptr_t stack_content_size = old_stack_base - stack_pointer; | 235 intptr_t stack_content_size = old_stack_base - stack_pointer; |
245 return new_stack_base - stack_content_size; | 236 return new_stack_base - stack_content_size; |
246 } | 237 } |
247 | 238 |
248 #endif // V8_NATIVE_REGEXP | 239 #endif // V8_NATIVE_REGEXP |
249 } } // namespace v8::internal | 240 } } // namespace v8::internal |
OLD | NEW |