| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 273 } |
| 274 BYTECODE(LOOKUP_HI_MAP8) { | 274 BYTECODE(LOOKUP_HI_MAP8) { |
| 275 // Look up high byte of this character in a byte map. Use the byte as | 275 // Look up high byte of this character in a byte map. Use the byte as |
| 276 // an index into a table that follows this instruction immediately. | 276 // an index into a table that follows this instruction immediately. |
| 277 int index = (current_char >> 8) - pc[1]; | 277 int index = (current_char >> 8) - pc[1]; |
| 278 byte map = code_base[Load32(pc + 2) + index]; | 278 byte map = code_base[Load32(pc + 2) + index]; |
| 279 const byte* new_pc = code_base + Load32(pc + 6) + (map << 2); | 279 const byte* new_pc = code_base + Load32(pc + 6) + (map << 2); |
| 280 pc = code_base + Load32(new_pc); | 280 pc = code_base + Load32(new_pc); |
| 281 break; | 281 break; |
| 282 } | 282 } |
| 283 BYTECODE(CHECK_BACKREF) | 283 BYTECODE(CHECK_NOT_BACK_REF) { |
| 284 UNREACHABLE(); | 284 int from = registers[pc[1]]; |
| 285 int len = registers[pc[1] + 1] - from; |
| 286 if (current + len > subject.length()) { |
| 287 pc = code_base + Load32(pc + 2); |
| 288 break; |
| 289 } else { |
| 290 int i; |
| 291 for (i = 0; i < len; i++) { |
| 292 if (subject[from + i] != subject[current + i]) { |
| 293 pc = code_base + Load32(pc + 2); |
| 294 break; |
| 295 } |
| 296 } |
| 297 if (i < len) break; |
| 298 current += len; |
| 299 } |
| 300 pc += BC_CHECK_NOT_BACK_REF_LENGTH; |
| 285 break; | 301 break; |
| 286 BYTECODE(CHECK_NOT_BACKREF) | 302 } |
| 287 UNREACHABLE(); | |
| 288 break; | |
| 289 default: | 303 default: |
| 290 UNREACHABLE(); | 304 UNREACHABLE(); |
| 291 break; | 305 break; |
| 292 } | 306 } |
| 293 } | 307 } |
| 294 } | 308 } |
| 295 | 309 |
| 296 | 310 |
| 297 bool Re2kInterpreter::Match(Handle<ByteArray> code_array, | 311 bool Re2kInterpreter::Match(Handle<ByteArray> code_array, |
| 298 Handle<String> subject16, | 312 Handle<String> subject16, |
| 299 int* registers, | 313 int* registers, |
| 300 int start_position) { | 314 int start_position) { |
| 301 ASSERT(StringShape(*subject16).IsTwoByteRepresentation()); | 315 ASSERT(StringShape(*subject16).IsTwoByteRepresentation()); |
| 302 ASSERT(subject16->IsFlat(StringShape(*subject16))); | 316 ASSERT(subject16->IsFlat(StringShape(*subject16))); |
| 303 | 317 |
| 304 | 318 |
| 305 AssertNoAllocation a; | 319 AssertNoAllocation a; |
| 306 const byte* code_base = code_array->GetDataStartAddress(); | 320 const byte* code_base = code_array->GetDataStartAddress(); |
| 307 return RawMatch(code_base, | 321 return RawMatch(code_base, |
| 308 Vector<const uc16>(subject16->GetTwoByteData(), | 322 Vector<const uc16>(subject16->GetTwoByteData(), |
| 309 subject16->length()), | 323 subject16->length()), |
| 310 registers, | 324 registers, |
| 311 start_position); | 325 start_position); |
| 312 } | 326 } |
| 313 | 327 |
| 314 } } // namespace v8::internal | 328 } } // namespace v8::internal |
| OLD | NEW |