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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #else | 92 #else |
93 #define BYTECODE(name) \ | 93 #define BYTECODE(name) \ |
94 case BC_##name: | 94 case BC_##name: |
95 #endif | 95 #endif |
96 | 96 |
97 | 97 |
98 | 98 |
99 static bool RawMatch(const byte* code_base, | 99 static bool RawMatch(const byte* code_base, |
100 Vector<const uc16> subject, | 100 Vector<const uc16> subject, |
101 int* registers, | 101 int* registers, |
102 int current) { | 102 int current, |
| 103 int current_char) { |
103 const byte* pc = code_base; | 104 const byte* pc = code_base; |
104 static const int kBacktrackStackSize = 10000; | 105 static const int kBacktrackStackSize = 10000; |
105 int backtrack_stack[kBacktrackStackSize]; | 106 int backtrack_stack[kBacktrackStackSize]; |
106 int backtrack_stack_space = kBacktrackStackSize; | 107 int backtrack_stack_space = kBacktrackStackSize; |
107 int* backtrack_sp = backtrack_stack; | 108 int* backtrack_sp = backtrack_stack; |
108 int current_char = -1; | |
109 #ifdef DEBUG | 109 #ifdef DEBUG |
110 if (FLAG_trace_regexp_bytecodes) { | 110 if (FLAG_trace_regexp_bytecodes) { |
111 PrintF("\n\nStart bytecode interpreter\n\n"); | 111 PrintF("\n\nStart bytecode interpreter\n\n"); |
112 } | 112 } |
113 #endif | 113 #endif |
114 while (true) { | 114 while (true) { |
115 switch (*pc) { | 115 switch (*pc) { |
116 BYTECODE(BREAK) | 116 BYTECODE(BREAK) |
117 UNREACHABLE(); | 117 UNREACHABLE(); |
118 return false; | 118 return false; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 bool IrregexpInterpreter::Match(Handle<ByteArray> code_array, | 376 bool IrregexpInterpreter::Match(Handle<ByteArray> code_array, |
377 Handle<String> subject16, | 377 Handle<String> subject16, |
378 int* registers, | 378 int* registers, |
379 int start_position) { | 379 int start_position) { |
380 ASSERT(StringShape(*subject16).IsTwoByteRepresentation()); | 380 ASSERT(StringShape(*subject16).IsTwoByteRepresentation()); |
381 ASSERT(subject16->IsFlat(StringShape(*subject16))); | 381 ASSERT(subject16->IsFlat(StringShape(*subject16))); |
382 | 382 |
383 AssertNoAllocation a; | 383 AssertNoAllocation a; |
384 const byte* code_base = code_array->GetDataStartAddress(); | 384 const byte* code_base = code_array->GetDataStartAddress(); |
| 385 uc16 previous_char = '\n'; |
| 386 Vector<const uc16> subject_vector = |
| 387 Vector<const uc16>(subject16->GetTwoByteData(), subject16->length()); |
| 388 if (start_position != 0) previous_char = subject_vector[start_position - 1]; |
385 return RawMatch(code_base, | 389 return RawMatch(code_base, |
386 Vector<const uc16>(subject16->GetTwoByteData(), | 390 subject_vector, |
387 subject16->length()), | |
388 registers, | 391 registers, |
389 start_position); | 392 start_position, |
| 393 previous_char); |
390 } | 394 } |
391 | 395 |
392 } } // namespace v8::internal | 396 } } // namespace v8::internal |
OLD | NEW |