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

Side by Side Diff: src/regexp-macro-assembler.cc

Issue 173567: ARM native regexps. (Closed)
Patch Set: Created 11 years, 3 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
OLDNEW
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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 #include "ast.h" 29 #include "ast.h"
30 #include "assembler.h" 30 #include "assembler.h"
31 #include "regexp-stack.h" 31 #include "regexp-stack.h"
32 #include "regexp-macro-assembler.h" 32 #include "regexp-macro-assembler.h"
33 #if V8_TARGET_ARCH_ARM
34 #include "arm/simulator-arm.h"
35 #elif V8_TARGET_ARCH_IA32
36 #include "ia32/simulator-ia32.h"
37 #elif V8_TARGET_ARCH_X64
38 #include "x64/simulator-x64.h"
39 #endif
33 40
34 namespace v8 { 41 namespace v8 {
35 namespace internal { 42 namespace internal {
36 43
37 RegExpMacroAssembler::RegExpMacroAssembler() { 44 RegExpMacroAssembler::RegExpMacroAssembler() {
38 } 45 }
39 46
40 47
41 RegExpMacroAssembler::~RegExpMacroAssembler() { 48 RegExpMacroAssembler::~RegExpMacroAssembler() {
42 } 49 }
43 50
44 51
45 #ifdef V8_NATIVE_REGEXP // Avoid unused code, e.g., on ARM. 52 #ifdef V8_NATIVE_REGEXP // Avoid unused code, e.g., on ARM.
46 53
47 NativeRegExpMacroAssembler::NativeRegExpMacroAssembler() { 54 NativeRegExpMacroAssembler::NativeRegExpMacroAssembler() {
48 } 55 }
49 56
50 57
51 NativeRegExpMacroAssembler::~NativeRegExpMacroAssembler() { 58 NativeRegExpMacroAssembler::~NativeRegExpMacroAssembler() {
52 } 59 }
53 60
61
54 const byte* NativeRegExpMacroAssembler::StringCharacterPosition( 62 const byte* NativeRegExpMacroAssembler::StringCharacterPosition(
55 String* subject, 63 String* subject,
56 int start_index) { 64 int start_index) {
57 // Not just flat, but ultra flat. 65 // Not just flat, but ultra flat.
58 ASSERT(subject->IsExternalString() || subject->IsSeqString()); 66 ASSERT(subject->IsExternalString() || subject->IsSeqString());
59 ASSERT(start_index >= 0); 67 ASSERT(start_index >= 0);
60 ASSERT(start_index <= subject->length()); 68 ASSERT(start_index <= subject->length());
61 if (subject->IsAsciiRepresentation()) { 69 if (subject->IsAsciiRepresentation()) {
62 const byte* address; 70 const byte* address;
63 if (StringShape(subject).IsExternal()) { 71 if (StringShape(subject).IsExternal()) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 typedef int (*matcher)(String*, int, const byte*, 163 typedef int (*matcher)(String*, int, const byte*,
156 const byte*, int*, int, Address); 164 const byte*, int*, int, Address);
157 matcher matcher_func = FUNCTION_CAST<matcher>(code->entry()); 165 matcher matcher_func = FUNCTION_CAST<matcher>(code->entry());
158 166
159 int at_start_val = at_start ? 1 : 0; 167 int at_start_val = at_start ? 1 : 0;
160 168
161 // Ensure that the minimum stack has been allocated. 169 // Ensure that the minimum stack has been allocated.
162 RegExpStack stack; 170 RegExpStack stack;
163 Address stack_base = RegExpStack::stack_base(); 171 Address stack_base = RegExpStack::stack_base();
164 172
165 int result = matcher_func(input, 173 int result = CALL_GENERATED_REGEXP_CODE(matcher_func,
166 start_offset, 174 input,
167 input_start, 175 start_offset,
168 input_end, 176 input_start,
169 output, 177 input_end,
170 at_start_val, 178 output,
171 stack_base); 179 at_start_val,
180 stack_base);
172 ASSERT(result <= SUCCESS); 181 ASSERT(result <= SUCCESS);
173 ASSERT(result >= RETRY); 182 ASSERT(result >= RETRY);
174 183
175 if (result == EXCEPTION && !Top::has_pending_exception()) { 184 if (result == EXCEPTION && !Top::has_pending_exception()) {
176 // We detected a stack overflow (on the backtrack stack) in RegExp code, 185 // We detected a stack overflow (on the backtrack stack) in RegExp code,
177 // but haven't created the exception yet. 186 // but haven't created the exception yet.
178 Top::StackOverflow(); 187 Top::StackOverflow();
179 } 188 }
180 return static_cast<Result>(result); 189 return static_cast<Result>(result);
181 } 190 }
(...skipping 24 matching lines...) Expand all
206 canonicalize.get(c2, '\0', s2); 215 canonicalize.get(c2, '\0', s2);
207 if (s1[0] != s2[0]) { 216 if (s1[0] != s2[0]) {
208 return 0; 217 return 0;
209 } 218 }
210 } 219 }
211 } 220 }
212 } 221 }
213 return 1; 222 return 1;
214 } 223 }
215 224
225
226 Address NativeRegExpMacroAssembler::GrowStack(Address stack_pointer,
227 Address* stack_base) {
228 size_t size = RegExpStack::stack_capacity();
229 Address old_stack_base = RegExpStack::stack_base();
230 ASSERT(old_stack_base == *stack_base);
231 ASSERT(stack_pointer <= old_stack_base);
232 ASSERT(static_cast<size_t>(old_stack_base - stack_pointer) <= size);
233 Address new_stack_base = RegExpStack::EnsureCapacity(size * 2);
234 if (new_stack_base == NULL) {
235 return NULL;
236 }
237 *stack_base = new_stack_base;
238 intptr_t stack_content_size = old_stack_base - stack_pointer;
239 return new_stack_base - stack_content_size;
240 }
241
216 #endif // V8_NATIVE_REGEXP 242 #endif // V8_NATIVE_REGEXP
217 } } // namespace v8::internal 243 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698