| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 void RegExpMacroAssemblerIA32::CheckNotCharacter(uint32_t c, | 494 void RegExpMacroAssemblerIA32::CheckNotCharacter(uint32_t c, |
| 495 Label* on_not_equal) { | 495 Label* on_not_equal) { |
| 496 __ cmp(current_character(), c); | 496 __ cmp(current_character(), c); |
| 497 BranchOrBacktrack(not_equal, on_not_equal); | 497 BranchOrBacktrack(not_equal, on_not_equal); |
| 498 } | 498 } |
| 499 | 499 |
| 500 | 500 |
| 501 void RegExpMacroAssemblerIA32::CheckCharacterAfterAnd(uint32_t c, | 501 void RegExpMacroAssemblerIA32::CheckCharacterAfterAnd(uint32_t c, |
| 502 uint32_t mask, | 502 uint32_t mask, |
| 503 Label* on_equal) { | 503 Label* on_equal) { |
| 504 __ mov(eax, current_character()); | 504 if (c == 0) { |
| 505 __ and_(eax, mask); | 505 __ test(current_character(), Immediate(mask)); |
| 506 __ cmp(eax, c); | 506 } else { |
| 507 __ mov(eax, current_character()); |
| 508 __ and_(eax, mask); |
| 509 __ cmp(eax, c); |
| 510 } |
| 507 BranchOrBacktrack(equal, on_equal); | 511 BranchOrBacktrack(equal, on_equal); |
| 508 } | 512 } |
| 509 | 513 |
| 510 | 514 |
| 511 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterAnd(uint32_t c, | 515 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterAnd(uint32_t c, |
| 512 uint32_t mask, | 516 uint32_t mask, |
| 513 Label* on_not_equal) { | 517 Label* on_not_equal) { |
| 514 __ mov(eax, current_character()); | 518 if (c == 0) { |
| 515 __ and_(eax, mask); | 519 __ test(current_character(), Immediate(mask)); |
| 516 __ cmp(eax, c); | 520 } else { |
| 521 __ mov(eax, current_character()); |
| 522 __ and_(eax, mask); |
| 523 __ cmp(eax, c); |
| 524 } |
| 517 BranchOrBacktrack(not_equal, on_not_equal); | 525 BranchOrBacktrack(not_equal, on_not_equal); |
| 518 } | 526 } |
| 519 | 527 |
| 520 | 528 |
| 521 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterMinusAnd( | 529 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterMinusAnd( |
| 522 uc16 c, | 530 uc16 c, |
| 523 uc16 minus, | 531 uc16 minus, |
| 524 uc16 mask, | 532 uc16 mask, |
| 525 Label* on_not_equal) { | 533 Label* on_not_equal) { |
| 526 ASSERT(minus < String::kMaxUtf16CodeUnit); | 534 ASSERT(minus < String::kMaxUtf16CodeUnit); |
| 527 __ lea(eax, Operand(current_character(), -minus)); | 535 __ lea(eax, Operand(current_character(), -minus)); |
| 528 __ and_(eax, mask); | 536 if (c == 0) { |
| 529 __ cmp(eax, c); | 537 __ test(eax, Immediate(mask)); |
| 538 } else { |
| 539 __ and_(eax, mask); |
| 540 __ cmp(eax, c); |
| 541 } |
| 530 BranchOrBacktrack(not_equal, on_not_equal); | 542 BranchOrBacktrack(not_equal, on_not_equal); |
| 531 } | 543 } |
| 532 | 544 |
| 533 | 545 |
| 546 void RegExpMacroAssemblerIA32::CheckCharacterInRange( |
| 547 uc16 from, |
| 548 uc16 to, |
| 549 Label* on_in_range) { |
| 550 __ lea(eax, Operand(current_character(), -from)); |
| 551 __ cmp(eax, to - from); |
| 552 BranchOrBacktrack(below_equal, on_in_range); |
| 553 } |
| 554 |
| 555 |
| 556 void RegExpMacroAssemblerIA32::CheckCharacterNotInRange( |
| 557 uc16 from, |
| 558 uc16 to, |
| 559 Label* on_not_in_range) { |
| 560 __ lea(eax, Operand(current_character(), -from)); |
| 561 __ cmp(eax, to - from); |
| 562 BranchOrBacktrack(above, on_not_in_range); |
| 563 } |
| 564 |
| 565 |
| 566 void RegExpMacroAssemblerIA32::CheckBitInTable( |
| 567 Handle<ByteArray> table, |
| 568 Label* on_bit_set) { |
| 569 __ mov(eax, Immediate(table)); |
| 570 __ mov(ebx, current_character()); |
| 571 __ and_(ebx, kTableSize - 1); |
| 572 __ cmpb(FieldOperand(eax, ebx, times_1, ByteArray::kHeaderSize), 0); |
| 573 BranchOrBacktrack(not_equal, on_bit_set); |
| 574 } |
| 575 |
| 576 |
| 534 bool RegExpMacroAssemblerIA32::CheckSpecialCharacterClass(uc16 type, | 577 bool RegExpMacroAssemblerIA32::CheckSpecialCharacterClass(uc16 type, |
| 535 Label* on_no_match) { | 578 Label* on_no_match) { |
| 536 // Range checks (c in min..max) are generally implemented by an unsigned | 579 // Range checks (c in min..max) are generally implemented by an unsigned |
| 537 // (c - min) <= (max - min) check | 580 // (c - min) <= (max - min) check |
| 538 switch (type) { | 581 switch (type) { |
| 539 case 's': | 582 case 's': |
| 540 // Match space-characters | 583 // Match space-characters |
| 541 if (mode_ == ASCII) { | 584 if (mode_ == ASCII) { |
| 542 // ASCII space characters are '\t'..'\r' and ' '. | 585 // ASCII space characters are '\t'..'\r' and ' '. |
| 543 Label success; | 586 Label success; |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 } | 1324 } |
| 1282 | 1325 |
| 1283 | 1326 |
| 1284 #undef __ | 1327 #undef __ |
| 1285 | 1328 |
| 1286 #endif // V8_INTERPRETED_REGEXP | 1329 #endif // V8_INTERPRETED_REGEXP |
| 1287 | 1330 |
| 1288 }} // namespace v8::internal | 1331 }} // namespace v8::internal |
| 1289 | 1332 |
| 1290 #endif // V8_TARGET_ARCH_IA32 | 1333 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |