Chromium Code Reviews| Index: src/interpreter-re2k.cc |
| =================================================================== |
| --- src/interpreter-re2k.cc (revision 786) |
| +++ src/interpreter-re2k.cc (working copy) |
| @@ -39,14 +39,21 @@ |
| #ifdef DEBUG |
| -# define BYTECODE(name) break; \ |
| - case BC_##name: \ |
| - if (FLAG_trace_regexp_bytecodes) { \ |
| - PrintF("pc = %d, current = %d, bc = " \ |
| - #name "\n", pc - code_base, current); \ |
| +# define BYTECODE(name) break; \ |
|
Christian Plesner Hansen
2008/11/18 14:07:41
I would prefer if the breaks were written explicit
|
| + case BC_##name: \ |
| + if (FLAG_trace_regexp_bytecodes) { \ |
|
Christian Plesner Hansen
2008/11/18 14:07:41
Couldn't this be factored into a function rather t
|
| + PrintF("pc = %02x, sp = %d, current = %d, bc = " \ |
| + #name, \ |
| + pc - code_base, \ |
| + backtrack_sp - backtrack_stack, \ |
| + current); \ |
| + for (int _i = 1; _i < BC_##name##_LENGTH; _i++) { \ |
| + printf(", %02x", pc[_i]); \ |
| + } \ |
| + printf("\n"); \ |
| } |
| #else |
| -# define BYTECODE(name) break; \ |
| +# define BYTECODE(name) break; \ |
| case BC_##name: |
| #endif |
| @@ -57,8 +64,8 @@ |
| int* registers, |
| int current) { |
| const byte* pc = code_base; |
| - int backtrack_stack[1000]; |
| - int backtrack_stack_space = 1000; |
| + int backtrack_stack[10000]; |
| + int backtrack_stack_space = 10000; |
| int* backtrack_sp = backtrack_stack; |
| int current_char = -1; |
| #ifdef DEBUG |
| @@ -146,22 +153,20 @@ |
| pc += 7; |
| } |
| } |
| - BYTECODE(CHECK_RANGE) { |
| - int start = Load16(pc + 1); |
| - int end = Load16(pc + 3); |
| - if (current_char < start || current_char > end) { |
| - pc = code_base + Load32(pc + 5); |
| + BYTECODE(CHECK_LT) { |
| + int limit = Load16(pc + 1); |
| + if (current_char < limit) { |
| + pc = code_base + Load32(pc + 3); |
| } else { |
| - pc += 9; |
| + pc += 7; |
| } |
| } |
| - BYTECODE(CHECK_NOT_RANGE) { |
| - int start = Load16(pc + 1); |
| - int end = Load16(pc + 3); |
| - if (current_char >= start && current_char <= end) { |
| - pc = code_base + Load32(pc + 5); |
| + BYTECODE(CHECK_GT) { |
| + int limit = Load16(pc + 1); |
| + if (current_char > limit) { |
| + pc = code_base + Load32(pc + 3); |
| } else { |
| - pc += 9; |
| + pc += 7; |
|
Christian Plesner Hansen
2008/11/18 14:07:41
I would suggest using constants for opcode length
|
| } |
| } |
| BYTECODE(CHECK_REGISTER_LT) |
| @@ -239,15 +244,18 @@ |
| bool Re2kInterpreter::Match(Handle<ByteArray> code_array, |
| - Handle<String> subject, |
| + Handle<String> subject16, |
| int* registers, |
| int start_position) { |
| + ASSERT(StringShape(*subject16).IsTwoByteRepresentation()); |
| + ASSERT(subject16->IsFlat(StringShape(*subject16))); |
| + |
| + |
| + AssertNoAllocation a; |
| const byte* code_base = code_array->GetDataStartAddress(); |
| - ASSERT(subject->IsFlat(StringShape(*subject))); |
| - Handle<String> flat_two_byte = RegExpImpl::CachedStringToTwoByte(subject); |
| - ASSERT(StringShape(*flat_two_byte).IsTwoByteRepresentation()); |
| return RawMatch(code_base, |
| - flat_two_byte->ToUC16Vector(), |
| + Vector<const uc16>(subject16->GetTwoByteData(), |
| + subject16->length()), |
| registers, |
| start_position); |
| } |