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

Side by Side Diff: src/interpreter-re2k.cc

Issue 9457: Fix lint issues.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 1 month 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
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 21 matching lines...) Expand all
32 #include "utils.h" 32 #include "utils.h"
33 #include "ast.h" 33 #include "ast.h"
34 #include "bytecodes-re2k.h" 34 #include "bytecodes-re2k.h"
35 #include "interpreter-re2k.h" 35 #include "interpreter-re2k.h"
36 36
37 37
38 namespace v8 { namespace internal { 38 namespace v8 { namespace internal {
39 39
40 40
41 template <typename Char> 41 template <typename Char>
42 static bool RawMatch(const byte* code_base, Vector<const Char> subject, int* cap tures, int current) { 42 static bool RawMatch(const byte* code_base,
43 Vector<const Char> subject,
44 int* registers,
45 int current) {
43 const byte* pc = code_base; 46 const byte* pc = code_base;
44 int backtrack_stack[1000]; 47 int backtrack_stack[1000];
45 int backtrack_stack_space = 1000; 48 int backtrack_stack_space = 1000;
46 int* backtrack_sp = backtrack_stack; 49 int* backtrack_sp = backtrack_stack;
47 int current_char = -1; 50 int current_char = -1;
48 while (true) { 51 while (true) {
49 switch (*pc) { 52 switch (*pc) {
50 case BC_BREAK: 53 case BC_BREAK:
51 UNREACHABLE(); 54 UNREACHABLE();
52 return false; 55 return false;
53 case BC_PUSH_CP: 56 case BC_PUSH_CP:
54 if (--backtrack_stack_space < 0) { 57 if (--backtrack_stack_space < 0) {
55 return false; // No match on backtrack stack overflow. 58 return false; // No match on backtrack stack overflow.
56 } 59 }
57 *backtrack_sp++ = current + Load32(pc + 1); 60 *backtrack_sp++ = current + Load32(pc + 1);
58 pc += 5; 61 pc += 5;
59 break; 62 break;
60 case BC_PUSH_BT: 63 case BC_PUSH_BT:
61 if (--backtrack_stack_space < 0) { 64 if (--backtrack_stack_space < 0) {
62 return false; // No match on backtrack stack overflow. 65 return false; // No match on backtrack stack overflow.
63 } 66 }
64 *backtrack_sp++ = Load32(pc + 1); 67 *backtrack_sp++ = Load32(pc + 1);
65 pc += 5; 68 pc += 5;
66 break; 69 break;
67 case BC_PUSH_CAPTURE: 70 case BC_PUSH_REGISTER:
68 if (--backtrack_stack_space < 0) { 71 if (--backtrack_stack_space < 0) {
69 return false; // No match on backtrack stack overflow. 72 return false; // No match on backtrack stack overflow.
70 } 73 }
71 *backtrack_sp++ = captures[pc[1]]; 74 *backtrack_sp++ = registers[pc[1]];
72 pc += 2; 75 pc += 2;
73 break; 76 break;
74 case BC_SET_CAPTURE: 77 case BC_SET_REGISTER:
75 captures[pc[1]] = current + Load32(pc + 2); 78 registers[pc[1]] = current + Load32(pc + 2);
76 pc += 6; 79 pc += 6;
77 break; 80 break;
78 case BC_POP_CP: 81 case BC_POP_CP:
79 backtrack_stack_space++; 82 backtrack_stack_space++;
80 --backtrack_sp; 83 --backtrack_sp;
81 current = *backtrack_sp; 84 current = *backtrack_sp;
82 pc += 1; 85 pc += 1;
83 break; 86 break;
84 case BC_POP_BT: 87 case BC_POP_BT:
85 backtrack_stack_space++; 88 backtrack_stack_space++;
86 --backtrack_sp; 89 --backtrack_sp;
87 pc = code_base + *backtrack_sp; 90 pc = code_base + *backtrack_sp;
88 break; 91 break;
89 case BC_POP_CAPTURE: 92 case BC_POP_REGISTER:
90 backtrack_stack_space++; 93 backtrack_stack_space++;
91 --backtrack_sp; 94 --backtrack_sp;
92 captures[pc[1]] = *backtrack_sp; 95 registers[pc[1]] = *backtrack_sp;
93 pc += 2; 96 pc += 2;
94 break; 97 break;
95 case BC_FAIL: 98 case BC_FAIL:
96 return false; 99 return false;
97 case BC_FAIL_IF_WITHIN: 100 case BC_FAIL_IF_WITHIN:
98 if (current + Load32(pc + 1) >= subject.length()) { 101 if (current + Load32(pc + 1) >= subject.length()) {
99 return false; 102 return false;
100 } 103 }
101 pc += 5; 104 pc += 5;
102 break; 105 break;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 case BC_CHECK_NOT_RANGE: { 153 case BC_CHECK_NOT_RANGE: {
151 int start = Load16(pc + 1); 154 int start = Load16(pc + 1);
152 int end = Load16(pc + 3); 155 int end = Load16(pc + 3);
153 if (current_char < start || current_char > end || current_char == -1) { 156 if (current_char < start || current_char > end || current_char == -1) {
154 pc = code_base + Load32(pc + 5); 157 pc = code_base + Load32(pc + 5);
155 } else { 158 } else {
156 pc += 9; 159 pc += 9;
157 } 160 }
158 break; 161 break;
159 } 162 }
163 case BC_CHECK_REGISTER_EQ:
164 if (registers[pc[1]] == Load16(pc + 2)) {
165 pc = code_base + Load32(pc + 4);
166 } else {
167 pc += 8;
168 }
169 break;
170 case BC_CHECK_REGISTER_LE:
171 if (registers[pc[1]] <= Load16(pc + 2)) {
172 pc = code_base + Load32(pc + 4);
173 } else {
174 pc += 8;
175 }
176 break;
177 case BC_CHECK_REGISTER_LT:
178 if (registers[pc[1]] < Load16(pc + 2)) {
179 pc = code_base + Load32(pc + 4);
180 } else {
181 pc += 8;
182 }
183 break;
184 case BC_CHECK_REGISTER_GE:
185 if (registers[pc[1]] >= Load16(pc + 2)) {
186 pc = code_base + Load32(pc + 4);
187 } else {
188 pc += 8;
189 }
190 break;
191 case BC_CHECK_REGISTER_GT:
192 if (registers[pc[1]] > Load16(pc + 2)) {
193 pc = code_base + Load32(pc + 4);
194 } else {
195 pc += 8;
196 }
197 break;
198 case BC_CHECK_REGISTER_NE:
199 if (registers[pc[1]] != Load16(pc + 2)) {
200 pc = code_base + Load32(pc + 4);
201 } else {
202 pc += 8;
203 }
204 break;
160 case BC_CHECK_BACKREF: 205 case BC_CHECK_BACKREF:
161 case BC_CHECK_NOT_BACKREF: 206 case BC_CHECK_NOT_BACKREF:
162 case BC_CHECK_BITMAP: 207 case BC_CHECK_BITMAP:
163 case BC_CHECK_NOT_BITMAP: 208 case BC_CHECK_NOT_BITMAP:
164 default: 209 default:
165 UNREACHABLE(); 210 UNREACHABLE();
166 break; 211 break;
167 } 212 }
168 } 213 }
169 } 214 }
170 215
171 216
172 bool Re2kInterpreter::Match(ByteArray* code_array, String* subject, int* capture s, int start_position) { 217 bool Re2kInterpreter::Match(ByteArray* code_array,
218 String* subject,
219 int* registers,
220 int start_position) {
173 const byte* code_base = code_array->GetDataStartAddress(); 221 const byte* code_base = code_array->GetDataStartAddress();
174 StringShape shape(subject); 222 StringShape shape(subject);
175 ASSERT(subject->IsFlat(shape)); 223 ASSERT(subject->IsFlat(shape));
176 if (shape.IsAsciiRepresentation()) { 224 if (shape.IsAsciiRepresentation()) {
177 return RawMatch(code_base, subject->ToAsciiVector(), captures, start_positio n); 225 return RawMatch(code_base,
226 subject->ToAsciiVector(),
227 registers,
228 start_position);
178 } else { 229 } else {
179 return RawMatch(code_base, subject->ToUC16Vector(), captures, start_position ); 230 return RawMatch(code_base,
231 subject->ToUC16Vector(),
232 registers,
233 start_position);
180 } 234 }
181 } 235 }
182 236
183 } } // namespace v8::internal 237 } } // namespace v8::internal
OLDNEW
« src/assembler-re2k.h ('K') | « src/interpreter-re2k.h ('k') | src/regexp-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698