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

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

Issue 18363: * Irregexp: Move from a byte-oriented bytecode format to a 32-bit oriented... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 11 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 | 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 printable ? 90 printable ?
91 "pc = %02x, sp = %d, curpos = %d, curchar = %08x (%c), bc = %s" : 91 "pc = %02x, sp = %d, curpos = %d, curchar = %08x (%c), bc = %s" :
92 "pc = %02x, sp = %d, curpos = %d, curchar = %08x .%c., bc = %s"; 92 "pc = %02x, sp = %d, curpos = %d, curchar = %08x .%c., bc = %s";
93 PrintF(format, 93 PrintF(format,
94 pc - code_base, 94 pc - code_base,
95 stack_depth, 95 stack_depth,
96 current_position, 96 current_position,
97 current_char, 97 current_char,
98 printable ? current_char : '.', 98 printable ? current_char : '.',
99 bytecode_name); 99 bytecode_name);
100 for (int i = 1; i < bytecode_length; i++) { 100 for (int i = 0; i < bytecode_length; i++) {
101 printf(", %02x", pc[i]); 101 printf(", %02x", pc[i]);
102 } 102 }
103 printf(" "); 103 printf(" ");
104 for (int i = 1; i < bytecode_length; i++) { 104 for (int i = 1; i < bytecode_length; i++) {
105 unsigned char b = pc[i]; 105 unsigned char b = pc[i];
106 if (b < 127 && b >= 32) { 106 if (b < 127 && b >= 32) {
107 printf("%c", b); 107 printf("%c", b);
108 } else { 108 } else {
109 printf("."); 109 printf(".");
110 } 110 }
(...skipping 11 matching lines...) Expand all
122 current, \ 122 current, \
123 current_char, \ 123 current_char, \
124 BC_##name##_LENGTH, \ 124 BC_##name##_LENGTH, \
125 #name); 125 #name);
126 #else 126 #else
127 #define BYTECODE(name) \ 127 #define BYTECODE(name) \
128 case BC_##name: 128 case BC_##name:
129 #endif 129 #endif
130 130
131 131
132 static int32_t Load32Aligned(const byte* pc) {
133 ASSERT((reinterpret_cast<int>(pc) & 3) == 0);
134 return *reinterpret_cast<const int32_t *>(pc);
135 }
136
137
138 static int32_t Load16Aligned(const byte* pc) {
139 ASSERT((reinterpret_cast<int>(pc) & 1) == 0);
140 return *reinterpret_cast<const uint16_t *>(pc);
141 }
142
132 143
133 template <typename Char> 144 template <typename Char>
134 static bool RawMatch(const byte* code_base, 145 static bool RawMatch(const byte* code_base,
135 Vector<const Char> subject, 146 Vector<const Char> subject,
136 int* registers, 147 int* registers,
137 int current, 148 int current,
138 uint32_t current_char) { 149 uint32_t current_char) {
139 const byte* pc = code_base; 150 const byte* pc = code_base;
140 static const int kBacktrackStackSize = 10000; 151 static const int kBacktrackStackSize = 10000;
141 int backtrack_stack[kBacktrackStackSize]; 152 int backtrack_stack[kBacktrackStackSize];
142 int backtrack_stack_space = kBacktrackStackSize; 153 int backtrack_stack_space = kBacktrackStackSize;
143 int* backtrack_sp = backtrack_stack; 154 int* backtrack_sp = backtrack_stack;
144 #ifdef DEBUG 155 #ifdef DEBUG
145 if (FLAG_trace_regexp_bytecodes) { 156 if (FLAG_trace_regexp_bytecodes) {
146 PrintF("\n\nStart bytecode interpreter\n\n"); 157 PrintF("\n\nStart bytecode interpreter\n\n");
147 } 158 }
148 #endif 159 #endif
149 while (true) { 160 while (true) {
150 switch (*pc) { 161 int32_t insn = Load32Aligned(pc);
162 switch (insn & BYTECODE_MASK) {
151 BYTECODE(BREAK) 163 BYTECODE(BREAK)
152 UNREACHABLE(); 164 UNREACHABLE();
153 return false; 165 return false;
154 BYTECODE(PUSH_CP) 166 BYTECODE(PUSH_CP)
155 if (--backtrack_stack_space < 0) { 167 if (--backtrack_stack_space < 0) {
156 return false; // No match on backtrack stack overflow. 168 return false; // No match on backtrack stack overflow.
157 } 169 }
158 *backtrack_sp++ = current + Load32(pc + 1); 170 *backtrack_sp++ = current;
159 pc += BC_PUSH_CP_LENGTH; 171 pc += BC_PUSH_CP_LENGTH;
160 break; 172 break;
161 BYTECODE(PUSH_BT) 173 BYTECODE(PUSH_BT)
162 if (--backtrack_stack_space < 0) { 174 if (--backtrack_stack_space < 0) {
163 return false; // No match on backtrack stack overflow. 175 return false; // No match on backtrack stack overflow.
164 } 176 }
165 *backtrack_sp++ = Load32(pc + 1); 177 *backtrack_sp++ = Load32Aligned(pc + 4);
166 pc += BC_PUSH_BT_LENGTH; 178 pc += BC_PUSH_BT_LENGTH;
167 break; 179 break;
168 BYTECODE(PUSH_REGISTER) 180 BYTECODE(PUSH_REGISTER)
169 if (--backtrack_stack_space < 0) { 181 if (--backtrack_stack_space < 0) {
170 return false; // No match on backtrack stack overflow. 182 return false; // No match on backtrack stack overflow.
171 } 183 }
172 *backtrack_sp++ = registers[pc[1]]; 184 *backtrack_sp++ = registers[insn >> BYTECODE_SHIFT];
173 pc += BC_PUSH_REGISTER_LENGTH; 185 pc += BC_PUSH_REGISTER_LENGTH;
174 break; 186 break;
175 BYTECODE(SET_REGISTER) 187 BYTECODE(SET_REGISTER)
176 registers[pc[1]] = Load32(pc + 2); 188 registers[insn >> BYTECODE_SHIFT] = Load32Aligned(pc + 4);
177 pc += BC_SET_REGISTER_LENGTH; 189 pc += BC_SET_REGISTER_LENGTH;
178 break; 190 break;
179 BYTECODE(ADVANCE_REGISTER) 191 BYTECODE(ADVANCE_REGISTER)
180 registers[pc[1]] += Load32(pc + 2); 192 registers[insn >> BYTECODE_SHIFT] += Load32Aligned(pc + 4);
181 pc += BC_ADVANCE_REGISTER_LENGTH; 193 pc += BC_ADVANCE_REGISTER_LENGTH;
182 break; 194 break;
183 BYTECODE(SET_REGISTER_TO_CP) 195 BYTECODE(SET_REGISTER_TO_CP)
184 registers[pc[1]] = current + Load32(pc + 2); 196 registers[insn >> BYTECODE_SHIFT] = current + Load32Aligned(pc + 4);
185 pc += BC_SET_REGISTER_TO_CP_LENGTH; 197 pc += BC_SET_REGISTER_TO_CP_LENGTH;
186 break; 198 break;
187 BYTECODE(SET_CP_TO_REGISTER) 199 BYTECODE(SET_CP_TO_REGISTER)
188 current = registers[pc[1]]; 200 current = registers[insn >> BYTECODE_SHIFT];
189 pc += BC_SET_CP_TO_REGISTER_LENGTH; 201 pc += BC_SET_CP_TO_REGISTER_LENGTH;
190 break; 202 break;
191 BYTECODE(SET_REGISTER_TO_SP) 203 BYTECODE(SET_REGISTER_TO_SP)
192 registers[pc[1]] = backtrack_sp - backtrack_stack; 204 registers[insn >> BYTECODE_SHIFT] = backtrack_sp - backtrack_stack;
193 pc += BC_SET_REGISTER_TO_SP_LENGTH; 205 pc += BC_SET_REGISTER_TO_SP_LENGTH;
194 break; 206 break;
195 BYTECODE(SET_SP_TO_REGISTER) 207 BYTECODE(SET_SP_TO_REGISTER)
196 backtrack_sp = backtrack_stack + registers[pc[1]]; 208 backtrack_sp = backtrack_stack + registers[insn >> BYTECODE_SHIFT];
197 backtrack_stack_space = kBacktrackStackSize - 209 backtrack_stack_space = kBacktrackStackSize -
198 (backtrack_sp - backtrack_stack); 210 (backtrack_sp - backtrack_stack);
199 pc += BC_SET_SP_TO_REGISTER_LENGTH; 211 pc += BC_SET_SP_TO_REGISTER_LENGTH;
200 break; 212 break;
201 BYTECODE(POP_CP) 213 BYTECODE(POP_CP)
202 backtrack_stack_space++; 214 backtrack_stack_space++;
203 --backtrack_sp; 215 --backtrack_sp;
204 current = *backtrack_sp; 216 current = *backtrack_sp;
205 pc += BC_POP_CP_LENGTH; 217 pc += BC_POP_CP_LENGTH;
206 break; 218 break;
207 BYTECODE(POP_BT) 219 BYTECODE(POP_BT)
208 backtrack_stack_space++; 220 backtrack_stack_space++;
209 --backtrack_sp; 221 --backtrack_sp;
210 pc = code_base + *backtrack_sp; 222 pc = code_base + *backtrack_sp;
211 break; 223 break;
212 BYTECODE(POP_REGISTER) 224 BYTECODE(POP_REGISTER)
213 backtrack_stack_space++; 225 backtrack_stack_space++;
214 --backtrack_sp; 226 --backtrack_sp;
215 registers[pc[1]] = *backtrack_sp; 227 registers[insn >> BYTECODE_SHIFT] = *backtrack_sp;
216 pc += BC_POP_REGISTER_LENGTH; 228 pc += BC_POP_REGISTER_LENGTH;
217 break; 229 break;
218 BYTECODE(FAIL) 230 BYTECODE(FAIL)
219 return false; 231 return false;
220 BYTECODE(SUCCEED) 232 BYTECODE(SUCCEED)
221 return true; 233 return true;
222 BYTECODE(ADVANCE_CP) 234 BYTECODE(ADVANCE_CP)
223 current += Load32(pc + 1); 235 current += insn >> BYTECODE_SHIFT;
224 pc += BC_ADVANCE_CP_LENGTH; 236 pc += BC_ADVANCE_CP_LENGTH;
225 break; 237 break;
226 BYTECODE(GOTO) 238 BYTECODE(GOTO)
227 pc = code_base + Load32(pc + 1); 239 pc = code_base + Load32Aligned(pc + 4);
228 break; 240 break;
229 BYTECODE(CHECK_GREEDY) 241 BYTECODE(CHECK_GREEDY)
230 if (current == backtrack_sp[-1]) { 242 if (current == backtrack_sp[-1]) {
231 backtrack_sp--; 243 backtrack_sp--;
232 backtrack_stack_space++; 244 backtrack_stack_space++;
233 pc = code_base + Load32(pc + 1); 245 pc = code_base + Load32Aligned(pc + 4);
234 } else { 246 } else {
235 pc += BC_CHECK_GREEDY_LENGTH; 247 pc += BC_CHECK_GREEDY_LENGTH;
236 } 248 }
237 break; 249 break;
238 BYTECODE(LOAD_CURRENT_CHAR) { 250 BYTECODE(LOAD_CURRENT_CHAR) {
239 int pos = current + Load32(pc + 1); 251 int pos = current + (insn >> BYTECODE_SHIFT);
240 if (pos >= subject.length()) { 252 if (pos >= subject.length()) {
241 pc = code_base + Load32(pc + 5); 253 pc = code_base + Load32Aligned(pc + 4);
242 } else { 254 } else {
243 current_char = subject[pos]; 255 current_char = subject[pos];
244 pc += BC_LOAD_CURRENT_CHAR_LENGTH; 256 pc += BC_LOAD_CURRENT_CHAR_LENGTH;
245 } 257 }
246 break; 258 break;
247 } 259 }
248 BYTECODE(LOAD_CURRENT_CHAR_UNCHECKED) { 260 BYTECODE(LOAD_CURRENT_CHAR_UNCHECKED) {
249 int pos = current + Load32(pc + 1); 261 int pos = current + (insn >> BYTECODE_SHIFT);
250 current_char = subject[pos]; 262 current_char = subject[pos];
251 pc += BC_LOAD_CURRENT_CHAR_UNCHECKED_LENGTH; 263 pc += BC_LOAD_CURRENT_CHAR_UNCHECKED_LENGTH;
252 break; 264 break;
253 } 265 }
254 BYTECODE(LOAD_2_CURRENT_CHARS) { 266 BYTECODE(LOAD_2_CURRENT_CHARS) {
255 int pos = current + Load32(pc + 1); 267 int pos = current + (insn >> BYTECODE_SHIFT);
256 if (pos + 2 > subject.length()) { 268 if (pos + 2 > subject.length()) {
257 pc = code_base + Load32(pc + 5); 269 pc = code_base + Load32Aligned(pc + 4);
258 } else { 270 } else {
259 Char next = subject[pos + 1]; 271 Char next = subject[pos + 1];
260 current_char = 272 current_char =
261 (subject[pos] | (next << (kBitsPerByte * sizeof(Char)))); 273 (subject[pos] | (next << (kBitsPerByte * sizeof(Char))));
262 pc += BC_LOAD_2_CURRENT_CHARS_LENGTH; 274 pc += BC_LOAD_2_CURRENT_CHARS_LENGTH;
263 } 275 }
264 break; 276 break;
265 } 277 }
266 BYTECODE(LOAD_2_CURRENT_CHARS_UNCHECKED) { 278 BYTECODE(LOAD_2_CURRENT_CHARS_UNCHECKED) {
267 int pos = current + Load32(pc + 1); 279 int pos = current + (insn >> BYTECODE_SHIFT);
268 Char next = subject[pos + 1]; 280 Char next = subject[pos + 1];
269 current_char = (subject[pos] | (next << (kBitsPerByte * sizeof(Char)))); 281 current_char = (subject[pos] | (next << (kBitsPerByte * sizeof(Char))));
270 pc += BC_LOAD_2_CURRENT_CHARS_UNCHECKED_LENGTH; 282 pc += BC_LOAD_2_CURRENT_CHARS_UNCHECKED_LENGTH;
271 break; 283 break;
272 } 284 }
273 BYTECODE(LOAD_4_CURRENT_CHARS) { 285 BYTECODE(LOAD_4_CURRENT_CHARS) {
274 ASSERT(sizeof(Char) == 1); 286 ASSERT(sizeof(Char) == 1);
275 int pos = current + Load32(pc + 1); 287 int pos = current + (insn >> BYTECODE_SHIFT);
276 if (pos + 4 > subject.length()) { 288 if (pos + 4 > subject.length()) {
277 pc = code_base + Load32(pc + 5); 289 pc = code_base + Load32Aligned(pc + 4);
278 } else { 290 } else {
279 Char next1 = subject[pos + 1]; 291 Char next1 = subject[pos + 1];
280 Char next2 = subject[pos + 2]; 292 Char next2 = subject[pos + 2];
281 Char next3 = subject[pos + 3]; 293 Char next3 = subject[pos + 3];
282 current_char = (subject[pos] | 294 current_char = (subject[pos] |
283 (next1 << 8) | 295 (next1 << 8) |
284 (next2 << 16) | 296 (next2 << 16) |
285 (next3 << 24)); 297 (next3 << 24));
286 pc += BC_LOAD_4_CURRENT_CHARS_LENGTH; 298 pc += BC_LOAD_4_CURRENT_CHARS_LENGTH;
287 } 299 }
288 break; 300 break;
289 } 301 }
290 BYTECODE(LOAD_4_CURRENT_CHARS_UNCHECKED) { 302 BYTECODE(LOAD_4_CURRENT_CHARS_UNCHECKED) {
291 ASSERT(sizeof(Char) == 1); 303 ASSERT(sizeof(Char) == 1);
292 int pos = current + Load32(pc + 1); 304 int pos = current + (insn >> BYTECODE_SHIFT);
293 Char next1 = subject[pos + 1]; 305 Char next1 = subject[pos + 1];
294 Char next2 = subject[pos + 2]; 306 Char next2 = subject[pos + 2];
295 Char next3 = subject[pos + 3]; 307 Char next3 = subject[pos + 3];
296 current_char = (subject[pos] | 308 current_char = (subject[pos] |
297 (next1 << 8) | 309 (next1 << 8) |
298 (next2 << 16) | 310 (next2 << 16) |
299 (next3 << 24)); 311 (next3 << 24));
300 pc += BC_LOAD_4_CURRENT_CHARS_UNCHECKED_LENGTH; 312 pc += BC_LOAD_4_CURRENT_CHARS_UNCHECKED_LENGTH;
301 break; 313 break;
302 } 314 }
315 BYTECODE(CHECK_4_CHARS) {
316 uint32_t c = Load32Aligned(pc + 4);
317 if (c == current_char) {
318 pc = code_base + Load32Aligned(pc + 8);
319 } else {
320 pc += BC_CHECK_4_CHARS_LENGTH;
321 }
322 break;
323 }
303 BYTECODE(CHECK_CHAR) { 324 BYTECODE(CHECK_CHAR) {
304 uint32_t c = Load32(pc + 1); 325 uint32_t c = (insn >> BYTECODE_SHIFT);
305 if (c == current_char) { 326 if (c == current_char) {
306 pc = code_base + Load32(pc + 5); 327 pc = code_base + Load32Aligned(pc + 4);
307 } else { 328 } else {
308 pc += BC_CHECK_CHAR_LENGTH; 329 pc += BC_CHECK_CHAR_LENGTH;
309 } 330 }
310 break; 331 break;
311 } 332 }
333 BYTECODE(CHECK_NOT_4_CHARS) {
334 uint32_t c = Load32Aligned(pc + 4);
335 if (c != current_char) {
336 pc = code_base + Load32Aligned(pc + 8);
337 } else {
338 pc += BC_CHECK_NOT_4_CHARS_LENGTH;
339 }
340 break;
341 }
312 BYTECODE(CHECK_NOT_CHAR) { 342 BYTECODE(CHECK_NOT_CHAR) {
313 uint32_t c = Load32(pc + 1); 343 uint32_t c = (insn >> BYTECODE_SHIFT);
314 if (c != current_char) { 344 if (c != current_char) {
315 pc = code_base + Load32(pc + 5); 345 pc = code_base + Load32Aligned(pc + 4);
316 } else { 346 } else {
317 pc += BC_CHECK_NOT_CHAR_LENGTH; 347 pc += BC_CHECK_NOT_CHAR_LENGTH;
318 } 348 }
319 break; 349 break;
320 } 350 }
351 BYTECODE(AND_CHECK_4_CHARS) {
352 uint32_t c = Load32Aligned(pc + 4);
353 if (c == (current_char & Load32Aligned(pc + 8))) {
354 pc = code_base + Load32Aligned(pc + 12);
355 } else {
356 pc += BC_AND_CHECK_4_CHARS_LENGTH;
357 }
358 break;
359 }
321 BYTECODE(AND_CHECK_CHAR) { 360 BYTECODE(AND_CHECK_CHAR) {
322 uint32_t c = Load32(pc + 1); 361 uint32_t c = (insn >> BYTECODE_SHIFT);
323 if (c == (current_char & Load32(pc + 5))) { 362 if (c == (current_char & Load32Aligned(pc + 4))) {
324 pc = code_base + Load32(pc + 9); 363 pc = code_base + Load32Aligned(pc + 8);
325 } else { 364 } else {
326 pc += BC_AND_CHECK_CHAR_LENGTH; 365 pc += BC_AND_CHECK_CHAR_LENGTH;
327 } 366 }
328 break; 367 break;
329 } 368 }
369 BYTECODE(AND_CHECK_NOT_4_CHARS) {
370 uint32_t c = Load32Aligned(pc + 4);
371 if (c != (current_char & Load32Aligned(pc + 8))) {
372 pc = code_base + Load32Aligned(pc + 12);
373 } else {
374 pc += BC_AND_CHECK_NOT_4_CHARS_LENGTH;
375 }
376 break;
377 }
330 BYTECODE(AND_CHECK_NOT_CHAR) { 378 BYTECODE(AND_CHECK_NOT_CHAR) {
331 uint32_t c = Load32(pc + 1); 379 uint32_t c = (insn >> BYTECODE_SHIFT);
332 if (c != (current_char & Load32(pc + 5))) { 380 if (c != (current_char & Load32Aligned(pc + 4))) {
333 pc = code_base + Load32(pc + 9); 381 pc = code_base + Load32Aligned(pc + 8);
334 } else { 382 } else {
335 pc += BC_AND_CHECK_NOT_CHAR_LENGTH; 383 pc += BC_AND_CHECK_NOT_CHAR_LENGTH;
336 } 384 }
337 break; 385 break;
338 } 386 }
339 BYTECODE(MINUS_AND_CHECK_NOT_CHAR) { 387 BYTECODE(MINUS_AND_CHECK_NOT_CHAR) {
340 uint32_t c = Load16(pc + 1); 388 uint32_t c = (insn >> BYTECODE_SHIFT);
341 uint32_t minus = Load16(pc + 3); 389 uint32_t minus = Load16Aligned(pc + 4);
342 uint32_t mask = Load16(pc + 5); 390 uint32_t mask = Load16Aligned(pc + 6);
343 if (c != ((current_char - minus) & mask)) { 391 if (c != ((current_char - minus) & mask)) {
344 pc = code_base + Load32(pc + 7); 392 pc = code_base + Load32Aligned(pc + 8);
345 } else { 393 } else {
346 pc += BC_MINUS_AND_CHECK_NOT_CHAR_LENGTH; 394 pc += BC_MINUS_AND_CHECK_NOT_CHAR_LENGTH;
347 } 395 }
348 break; 396 break;
349 } 397 }
350 BYTECODE(CHECK_LT) { 398 BYTECODE(CHECK_LT) {
351 uint32_t limit = Load16(pc + 1); 399 uint32_t limit = (insn >> BYTECODE_SHIFT);
352 if (current_char < limit) { 400 if (current_char < limit) {
353 pc = code_base + Load32(pc + 3); 401 pc = code_base + Load32Aligned(pc + 4);
354 } else { 402 } else {
355 pc += BC_CHECK_LT_LENGTH; 403 pc += BC_CHECK_LT_LENGTH;
356 } 404 }
357 break; 405 break;
358 } 406 }
359 BYTECODE(CHECK_GT) { 407 BYTECODE(CHECK_GT) {
360 uint32_t limit = Load16(pc + 1); 408 uint32_t limit = (insn >> BYTECODE_SHIFT);
361 if (current_char > limit) { 409 if (current_char > limit) {
362 pc = code_base + Load32(pc + 3); 410 pc = code_base + Load32Aligned(pc + 4);
363 } else { 411 } else {
364 pc += BC_CHECK_GT_LENGTH; 412 pc += BC_CHECK_GT_LENGTH;
365 } 413 }
366 break; 414 break;
367 } 415 }
368 BYTECODE(CHECK_REGISTER_LT) 416 BYTECODE(CHECK_REGISTER_LT)
369 if (registers[pc[1]] < Load16(pc + 2)) { 417 if (registers[insn >> BYTECODE_SHIFT] < Load32Aligned(pc + 4)) {
370 pc = code_base + Load32(pc + 4); 418 pc = code_base + Load32Aligned(pc + 8);
371 } else { 419 } else {
372 pc += BC_CHECK_REGISTER_LT_LENGTH; 420 pc += BC_CHECK_REGISTER_LT_LENGTH;
373 } 421 }
374 break; 422 break;
375 BYTECODE(CHECK_REGISTER_GE) 423 BYTECODE(CHECK_REGISTER_GE)
376 if (registers[pc[1]] >= Load16(pc + 2)) { 424 if (registers[insn >> BYTECODE_SHIFT] >= Load32Aligned(pc + 4)) {
377 pc = code_base + Load32(pc + 4); 425 pc = code_base + Load32Aligned(pc + 8);
378 } else { 426 } else {
379 pc += BC_CHECK_REGISTER_GE_LENGTH; 427 pc += BC_CHECK_REGISTER_GE_LENGTH;
380 } 428 }
381 break; 429 break;
382 BYTECODE(CHECK_REGISTER_EQ_POS) 430 BYTECODE(CHECK_REGISTER_EQ_POS)
383 if (registers[pc[1]] == current) { 431 if (registers[insn >> BYTECODE_SHIFT] == current) {
384 pc = code_base + Load32(pc + 2); 432 pc = code_base + Load32Aligned(pc + 4);
385 } else { 433 } else {
386 pc += BC_CHECK_REGISTER_EQ_POS_LENGTH; 434 pc += BC_CHECK_REGISTER_EQ_POS_LENGTH;
387 } 435 }
388 break; 436 break;
389 BYTECODE(LOOKUP_MAP1) { 437 BYTECODE(LOOKUP_MAP1) {
390 // Look up character in a bitmap. If we find a 0, then jump to the 438 // Look up character in a bitmap. If we find a 0, then jump to the
391 // location at pc + 7. Otherwise fall through! 439 // location at pc + 8. Otherwise fall through!
392 int index = current_char - Load16(pc + 1); 440 int index = current_char - (insn >> BYTECODE_SHIFT);
393 byte map = code_base[Load32(pc + 3) + (index >> 3)]; 441 byte map = code_base[Load32Aligned(pc + 4) + (index >> 3)];
394 map = ((map >> (index & 7)) & 1); 442 map = ((map >> (index & 7)) & 1);
395 if (map == 0) { 443 if (map == 0) {
396 pc = code_base + Load32(pc + 7); 444 pc = code_base + Load32Aligned(pc + 8);
397 } else { 445 } else {
398 pc += BC_LOOKUP_MAP1_LENGTH; 446 pc += BC_LOOKUP_MAP1_LENGTH;
399 } 447 }
400 break; 448 break;
401 } 449 }
402 BYTECODE(LOOKUP_MAP2) { 450 BYTECODE(LOOKUP_MAP2) {
403 // Look up character in a half-nibble map. If we find 00, then jump to 451 // Look up character in a half-nibble map. If we find 00, then jump to
404 // the location at pc + 7. If we find 01 then jump to location at 452 // the location at pc + 8. If we find 01 then jump to location at
405 // pc + 11, etc. 453 // pc + 11, etc.
406 int index = (current_char - Load16(pc + 1)) << 1; 454 int index = (current_char - (insn >> BYTECODE_SHIFT)) << 1;
407 byte map = code_base[Load32(pc + 3) + (index >> 3)]; 455 byte map = code_base[Load32Aligned(pc + 3) + (index >> 3)];
408 map = ((map >> (index & 7)) & 3); 456 map = ((map >> (index & 7)) & 3);
409 if (map < 2) { 457 if (map < 2) {
410 if (map == 0) { 458 if (map == 0) {
411 pc = code_base + Load32(pc + 7); 459 pc = code_base + Load32Aligned(pc + 8);
412 } else { 460 } else {
413 pc = code_base + Load32(pc + 11); 461 pc = code_base + Load32Aligned(pc + 12);
414 } 462 }
415 } else { 463 } else {
416 if (map == 2) { 464 if (map == 2) {
417 pc = code_base + Load32(pc + 15); 465 pc = code_base + Load32Aligned(pc + 16);
418 } else { 466 } else {
419 pc = code_base + Load32(pc + 19); 467 pc = code_base + Load32Aligned(pc + 20);
420 } 468 }
421 } 469 }
422 break; 470 break;
423 } 471 }
424 BYTECODE(LOOKUP_MAP8) { 472 BYTECODE(LOOKUP_MAP8) {
425 // Look up character in a byte map. Use the byte as an index into a 473 // Look up character in a byte map. Use the byte as an index into a
426 // table that follows this instruction immediately. 474 // table that follows this instruction immediately.
427 int index = current_char - Load16(pc + 1); 475 int index = current_char - (insn >> BYTECODE_SHIFT);
428 byte map = code_base[Load32(pc + 3) + index]; 476 byte map = code_base[Load32Aligned(pc + 4) + index];
429 const byte* new_pc = code_base + Load32(pc + 7) + (map << 2); 477 const byte* new_pc = code_base + Load32Aligned(pc + 8) + (map << 2);
430 pc = code_base + Load32(new_pc); 478 pc = code_base + Load32Aligned(new_pc);
431 break; 479 break;
432 } 480 }
433 BYTECODE(LOOKUP_HI_MAP8) { 481 BYTECODE(LOOKUP_HI_MAP8) {
434 // Look up high byte of this character in a byte map. Use the byte as 482 // Look up high byte of this character in a byte map. Use the byte as
435 // an index into a table that follows this instruction immediately. 483 // an index into a table that follows this instruction immediately.
436 int index = (current_char >> 8) - pc[1]; 484 int index = (current_char >> 8) - (insn >> BYTECODE_SHIFT);
437 byte map = code_base[Load32(pc + 2) + index]; 485 byte map = code_base[Load32Aligned(pc + 4) + index];
438 const byte* new_pc = code_base + Load32(pc + 6) + (map << 2); 486 const byte* new_pc = code_base + Load32Aligned(pc + 8) + (map << 2);
439 pc = code_base + Load32(new_pc); 487 pc = code_base + Load32Aligned(new_pc);
440 break; 488 break;
441 } 489 }
442 BYTECODE(CHECK_NOT_REGS_EQUAL) 490 BYTECODE(CHECK_NOT_REGS_EQUAL)
443 if (registers[pc[1]] == registers[pc[2]]) { 491 if (registers[insn >> BYTECODE_SHIFT] == registers[Load32Aligned(pc + 4) ]) {
444 pc += BC_CHECK_NOT_REGS_EQUAL_LENGTH; 492 pc += BC_CHECK_NOT_REGS_EQUAL_LENGTH;
445 } else { 493 } else {
446 pc = code_base + Load32(pc + 3); 494 pc = code_base + Load32Aligned(pc + 8);
447 } 495 }
448 break; 496 break;
449 BYTECODE(CHECK_NOT_BACK_REF) { 497 BYTECODE(CHECK_NOT_BACK_REF) {
450 int from = registers[pc[1]]; 498 int from = registers[insn >> BYTECODE_SHIFT];
451 int len = registers[pc[1] + 1] - from; 499 int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from;
452 if (from < 0 || len <= 0) { 500 if (from < 0 || len <= 0) {
453 pc += BC_CHECK_NOT_BACK_REF_LENGTH; 501 pc += BC_CHECK_NOT_BACK_REF_LENGTH;
454 break; 502 break;
455 } 503 }
456 if (current + len > subject.length()) { 504 if (current + len > subject.length()) {
457 pc = code_base + Load32(pc + 2); 505 pc = code_base + Load32Aligned(pc + 4);
458 break; 506 break;
459 } else { 507 } else {
460 int i; 508 int i;
461 for (i = 0; i < len; i++) { 509 for (i = 0; i < len; i++) {
462 if (subject[from + i] != subject[current + i]) { 510 if (subject[from + i] != subject[current + i]) {
463 pc = code_base + Load32(pc + 2); 511 pc = code_base + Load32Aligned(pc + 4);
464 break; 512 break;
465 } 513 }
466 } 514 }
467 if (i < len) break; 515 if (i < len) break;
468 current += len; 516 current += len;
469 } 517 }
470 pc += BC_CHECK_NOT_BACK_REF_LENGTH; 518 pc += BC_CHECK_NOT_BACK_REF_LENGTH;
471 break; 519 break;
472 } 520 }
473 BYTECODE(CHECK_NOT_BACK_REF_NO_CASE) { 521 BYTECODE(CHECK_NOT_BACK_REF_NO_CASE) {
474 int from = registers[pc[1]]; 522 int from = registers[insn >> BYTECODE_SHIFT];
475 int len = registers[pc[1] + 1] - from; 523 int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from;
476 if (from < 0 || len <= 0) { 524 if (from < 0 || len <= 0) {
477 pc += BC_CHECK_NOT_BACK_REF_NO_CASE_LENGTH; 525 pc += BC_CHECK_NOT_BACK_REF_NO_CASE_LENGTH;
478 break; 526 break;
479 } 527 }
480 if (current + len > subject.length()) { 528 if (current + len > subject.length()) {
481 pc = code_base + Load32(pc + 2); 529 pc = code_base + Load32Aligned(pc + 4);
482 break; 530 break;
483 } else { 531 } else {
484 if (BackRefMatchesNoCase(from, current, len, subject)) { 532 if (BackRefMatchesNoCase(from, current, len, subject)) {
485 current += len; 533 current += len;
486 pc += BC_CHECK_NOT_BACK_REF_NO_CASE_LENGTH; 534 pc += BC_CHECK_NOT_BACK_REF_NO_CASE_LENGTH;
487 } else { 535 } else {
488 pc = code_base + Load32(pc + 2); 536 pc = code_base + Load32Aligned(pc + 4);
489 } 537 }
490 } 538 }
491 break; 539 break;
492 } 540 }
493 BYTECODE(CHECK_AT_START) 541 BYTECODE(CHECK_AT_START)
494 if (current == 0) { 542 if (current == 0) {
495 pc = code_base + Load32(pc + 1); 543 pc = code_base + Load32Aligned(pc + 4);
496 } else { 544 } else {
497 pc += BC_CHECK_AT_START_LENGTH; 545 pc += BC_CHECK_AT_START_LENGTH;
498 } 546 }
499 break; 547 break;
500 BYTECODE(CHECK_NOT_AT_START) 548 BYTECODE(CHECK_NOT_AT_START)
501 if (current == 0) { 549 if (current == 0) {
502 pc += BC_CHECK_NOT_AT_START_LENGTH; 550 pc += BC_CHECK_NOT_AT_START_LENGTH;
503 } else { 551 } else {
504 pc = code_base + Load32(pc + 1); 552 pc = code_base + Load32Aligned(pc + 4);
505 } 553 }
506 break; 554 break;
507 default: 555 default:
508 UNREACHABLE(); 556 UNREACHABLE();
509 break; 557 break;
510 } 558 }
511 } 559 }
512 } 560 }
513 561
514 562
(...skipping 20 matching lines...) Expand all
535 if (start_position != 0) previous_char = subject_vector[start_position - 1]; 583 if (start_position != 0) previous_char = subject_vector[start_position - 1];
536 return RawMatch(code_base, 584 return RawMatch(code_base,
537 subject_vector, 585 subject_vector,
538 registers, 586 registers,
539 start_position, 587 start_position,
540 previous_char); 588 previous_char);
541 } 589 }
542 } 590 }
543 591
544 } } // namespace v8::internal 592 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698