Chromium Code Reviews| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 uc16 mask, | 565 uc16 mask, |
| 566 Label* on_not_equal) { | 566 Label* on_not_equal) { |
| 567 ASSERT(minus < String::kMaxUtf16CodeUnit); | 567 ASSERT(minus < String::kMaxUtf16CodeUnit); |
| 568 __ lea(rax, Operand(current_character(), -minus)); | 568 __ lea(rax, Operand(current_character(), -minus)); |
| 569 __ and_(rax, Immediate(mask)); | 569 __ and_(rax, Immediate(mask)); |
| 570 __ cmpl(rax, Immediate(c)); | 570 __ cmpl(rax, Immediate(c)); |
| 571 BranchOrBacktrack(not_equal, on_not_equal); | 571 BranchOrBacktrack(not_equal, on_not_equal); |
| 572 } | 572 } |
| 573 | 573 |
| 574 | 574 |
| 575 void RegExpMacroAssemblerX64::CheckCharacterInRange( | |
| 576 uc16 from, | |
| 577 uc16 to, | |
| 578 Label* on_in_range) { | |
|
Lasse Reichstein Nielsen
2012/03/28 14:02:10
Maybe special-case if 'from' is zero (or even if '
Erik Corry
2012/03/29 14:49:00
Never happens.
| |
| 579 __ lea(rax, Operand(current_character(), -from)); | |
|
Lasse Reichstein Nielsen
2012/03/28 14:02:10
lea->leal (saves a byte).
Erik Corry
2012/03/29 14:49:00
I think you mean on x64.
Fixed.
| |
| 580 __ cmpl(rax, Immediate(to - from)); | |
| 581 BranchOrBacktrack(below_equal, on_in_range); | |
| 582 } | |
| 583 | |
| 584 | |
| 585 void RegExpMacroAssemblerX64::CheckCharacterNotInRange( | |
| 586 uc16 from, | |
| 587 uc16 to, | |
| 588 Label* on_not_in_range) { | |
| 589 __ lea(rax, Operand(current_character(), -from)); | |
| 590 __ cmpl(rax, Immediate(to - from)); | |
| 591 BranchOrBacktrack(above, on_not_in_range); | |
| 592 } | |
| 593 | |
| 594 | |
| 595 void RegExpMacroAssemblerX64::CheckBitInTable( | |
| 596 Handle<ByteArray> table, | |
| 597 Label* on_bit_set) { | |
| 598 __ Move(rax, table); | |
| 599 Register index = current_character(); | |
| 600 if (mode_ != ASCII || kTableMask != String::kMaxAsciiCharCode) { | |
| 601 __ movq(rbx, current_character()); | |
| 602 __ and_(rbx, Immediate(kTableMask)); | |
|
Lasse Reichstein Nielsen
2012/03/28 14:02:10
I'd consider swapping these:
movq(rbx, Immediate
Erik Corry
2012/03/29 14:49:00
OTOH a mov can be eliminated completely by the reg
Lasse Reichstein
2012/03/29 15:25:32
I don't think the register renamer will do that si
Erik Corry
2012/03/30 07:46:28
My understanding is that after renaming you have g
Erik Corry
2012/03/31 20:04:04
But I tested it and your version is marginally fas
| |
| 603 index = rbx; | |
| 604 } | |
| 605 __ cmpb(FieldOperand(rax, index, times_1, ByteArray::kHeaderSize), | |
| 606 Immediate(0)); | |
| 607 BranchOrBacktrack(not_equal, on_bit_set); | |
| 608 } | |
| 609 | |
| 610 | |
| 575 bool RegExpMacroAssemblerX64::CheckSpecialCharacterClass(uc16 type, | 611 bool RegExpMacroAssemblerX64::CheckSpecialCharacterClass(uc16 type, |
| 576 Label* on_no_match) { | 612 Label* on_no_match) { |
| 577 // Range checks (c in min..max) are generally implemented by an unsigned | 613 // Range checks (c in min..max) are generally implemented by an unsigned |
| 578 // (c - min) <= (max - min) check, using the sequence: | 614 // (c - min) <= (max - min) check, using the sequence: |
| 579 // lea(rax, Operand(current_character(), -min)) or sub(rax, Immediate(min)) | 615 // lea(rax, Operand(current_character(), -min)) or sub(rax, Immediate(min)) |
| 580 // cmp(rax, Immediate(max - min)) | 616 // cmp(rax, Immediate(max - min)) |
| 581 switch (type) { | 617 switch (type) { |
| 582 case 's': | 618 case 's': |
| 583 // Match space-characters | 619 // Match space-characters |
| 584 if (mode_ == ASCII) { | 620 if (mode_ == ASCII) { |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1416 } | 1452 } |
| 1417 } | 1453 } |
| 1418 | 1454 |
| 1419 #undef __ | 1455 #undef __ |
| 1420 | 1456 |
| 1421 #endif // V8_INTERPRETED_REGEXP | 1457 #endif // V8_INTERPRETED_REGEXP |
| 1422 | 1458 |
| 1423 }} // namespace v8::internal | 1459 }} // namespace v8::internal |
| 1424 | 1460 |
| 1425 #endif // V8_TARGET_ARCH_X64 | 1461 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |