| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 bool RegExpMacroAssemblerX64::CheckSpecialCharacterClass(uc16 type, | 633 bool RegExpMacroAssemblerX64::CheckSpecialCharacterClass(uc16 type, |
| 634 Label* on_no_match) { | 634 Label* on_no_match) { |
| 635 // Range checks (c in min..max) are generally implemented by an unsigned | 635 // Range checks (c in min..max) are generally implemented by an unsigned |
| 636 // (c - min) <= (max - min) check, using the sequence: | 636 // (c - min) <= (max - min) check, using the sequence: |
| 637 // lea(rax, Operand(current_character(), -min)) or sub(rax, Immediate(min)) | 637 // lea(rax, Operand(current_character(), -min)) or sub(rax, Immediate(min)) |
| 638 // cmp(rax, Immediate(max - min)) | 638 // cmp(rax, Immediate(max - min)) |
| 639 switch (type) { | 639 switch (type) { |
| 640 case 's': | 640 case 's': |
| 641 // Match space-characters | 641 // Match space-characters |
| 642 if (mode_ == ASCII) { | 642 if (mode_ == ASCII) { |
| 643 // ASCII space characters are '\t'..'\r' and ' '. | 643 // One byte space characters are '\t'..'\r', ' ' and \u00a0. |
| 644 Label success; | 644 Label success; |
| 645 __ cmpl(current_character(), Immediate(' ')); | 645 __ cmpl(current_character(), Immediate(' ')); |
| 646 __ j(equal, &success); | 646 __ j(equal, &success, Label::kNear); |
| 647 // Check range 0x09..0x0d | 647 // Check range 0x09..0x0d |
| 648 __ lea(rax, Operand(current_character(), -'\t')); | 648 __ lea(rax, Operand(current_character(), -'\t')); |
| 649 __ cmpl(rax, Immediate('\r' - '\t')); | 649 __ cmpl(rax, Immediate('\r' - '\t')); |
| 650 BranchOrBacktrack(above, on_no_match); | 650 __ j(below_equal, &success, Label::kNear); |
| 651 // \u00a0 (NBSP). |
| 652 __ cmpl(rax, Immediate(0x00a0 - '\t')); |
| 653 BranchOrBacktrack(not_equal, on_no_match); |
| 651 __ bind(&success); | 654 __ bind(&success); |
| 652 return true; | 655 return true; |
| 653 } | 656 } |
| 654 return false; | 657 return false; |
| 655 case 'S': | 658 case 'S': |
| 656 // Match non-space characters. | 659 // The emitted code for generic character classes is good enough. |
| 657 if (mode_ == ASCII) { | |
| 658 // ASCII space characters are '\t'..'\r' and ' '. | |
| 659 __ cmpl(current_character(), Immediate(' ')); | |
| 660 BranchOrBacktrack(equal, on_no_match); | |
| 661 __ lea(rax, Operand(current_character(), -'\t')); | |
| 662 __ cmpl(rax, Immediate('\r' - '\t')); | |
| 663 BranchOrBacktrack(below_equal, on_no_match); | |
| 664 return true; | |
| 665 } | |
| 666 return false; | 660 return false; |
| 667 case 'd': | 661 case 'd': |
| 668 // Match ASCII digits ('0'..'9') | 662 // Match ASCII digits ('0'..'9') |
| 669 __ lea(rax, Operand(current_character(), -'0')); | 663 __ lea(rax, Operand(current_character(), -'0')); |
| 670 __ cmpl(rax, Immediate('9' - '0')); | 664 __ cmpl(rax, Immediate('9' - '0')); |
| 671 BranchOrBacktrack(above, on_no_match); | 665 BranchOrBacktrack(above, on_no_match); |
| 672 return true; | 666 return true; |
| 673 case 'D': | 667 case 'D': |
| 674 // Match non ASCII-digits | 668 // Match non ASCII-digits |
| 675 __ lea(rax, Operand(current_character(), -'0')); | 669 __ lea(rax, Operand(current_character(), -'0')); |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 } | 1538 } |
| 1545 } | 1539 } |
| 1546 | 1540 |
| 1547 #undef __ | 1541 #undef __ |
| 1548 | 1542 |
| 1549 #endif // V8_INTERPRETED_REGEXP | 1543 #endif // V8_INTERPRETED_REGEXP |
| 1550 | 1544 |
| 1551 }} // namespace v8::internal | 1545 }} // namespace v8::internal |
| 1552 | 1546 |
| 1553 #endif // V8_TARGET_ARCH_X64 | 1547 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |