OLD | NEW |
---|---|
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 // computed (current_char ^ 0x01 - 0x0b). I.e., check for | 575 // computed (current_char ^ 0x01 - 0x0b). I.e., check for |
576 // 0x201d (0x2028 - 0x0b) or 0x201e. | 576 // 0x201d (0x2028 - 0x0b) or 0x201e. |
577 __ subl(rax, Immediate(0x2028 - 0x0b)); | 577 __ subl(rax, Immediate(0x2028 - 0x0b)); |
578 __ cmpl(rax, Immediate(0x2029 - 0x2028)); | 578 __ cmpl(rax, Immediate(0x2029 - 0x2028)); |
579 BranchOrBacktrack(above, on_no_match); | 579 BranchOrBacktrack(above, on_no_match); |
580 __ bind(&done); | 580 __ bind(&done); |
581 } | 581 } |
582 return true; | 582 return true; |
583 } | 583 } |
584 case 'w': { | 584 case 'w': { |
585 Label done, check_digits; | 585 if (mode_ != ASCII) { |
586 __ cmpl(current_character(), Immediate('9')); | 586 // Table is 128 bits, so all ASCII characters can be tested. |
Erik Corry
2010/01/15 12:02:09
bytes!
| |
587 __ j(less_equal, &check_digits); | 587 __ cmpl(current_character(), Immediate('z')); |
588 __ cmpl(current_character(), Immediate('_')); | 588 BranchOrBacktrack(above, on_no_match); |
589 __ j(equal, &done); | 589 } |
590 // Convert to lower case if letter. | 590 __ movq(rbx, ExternalReference::re_word_character_map()); |
591 __ movl(rax, current_character()); | 591 ASSERT_EQ(0, word_character_map[0]); // Character '\0' is not a word char. |
592 __ orl(rax, Immediate(0x20)); | 592 ExternalReference word_map = ExternalReference::re_word_character_map(); |
593 // check rax in range ['a'..'z']. | 593 __ testb(Operand(rbx, current_character(), times_1, 0), |
594 __ subl(rax, Immediate('a')); | 594 current_character()); |
595 __ cmpl(rax, Immediate('z' - 'a')); | 595 BranchOrBacktrack(zero, on_no_match); |
596 BranchOrBacktrack(above, on_no_match); | |
597 __ jmp(&done); | |
598 __ bind(&check_digits); | |
599 // Check current character in range ['0'..'9']. | |
600 __ cmpl(current_character(), Immediate('0')); | |
601 BranchOrBacktrack(below, on_no_match); | |
602 __ bind(&done); | |
603 | |
604 return true; | 596 return true; |
605 } | 597 } |
606 case 'W': { | 598 case 'W': { |
607 Label done, check_digits; | 599 Label done; |
608 __ cmpl(current_character(), Immediate('9')); | 600 if (mode_ != ASCII) { |
609 __ j(less_equal, &check_digits); | 601 // Table is 128 bits, so all ASCII characters can be tested. |
Erik Corry
2010/01/15 12:02:09
bytes!
| |
610 __ cmpl(current_character(), Immediate('_')); | 602 __ cmpl(current_character(), Immediate('z')); |
611 BranchOrBacktrack(equal, on_no_match); | 603 __ j(above, &done); |
612 // Convert to lower case if letter. | 604 } |
613 __ movl(rax, current_character()); | 605 __ movq(rbx, ExternalReference::re_word_character_map()); |
614 __ orl(rax, Immediate(0x20)); | 606 ASSERT_EQ(0, word_character_map[0]); // Character '\0' is not a word char. |
615 // check current character in range ['a'..'z'], nondestructively. | 607 ExternalReference word_map = ExternalReference::re_word_character_map(); |
616 __ subl(rax, Immediate('a')); | 608 __ testb(Operand(rbx, current_character(), times_1, 0), |
617 __ cmpl(rax, Immediate('z' - 'a')); | 609 current_character()); |
618 BranchOrBacktrack(below_equal, on_no_match); | 610 BranchOrBacktrack(not_zero, on_no_match); |
619 __ jmp(&done); | 611 if (mode_ != ASCII) { |
620 __ bind(&check_digits); | 612 __ bind(&done); |
621 // Check current character in range ['0'..'9']. | 613 } |
622 __ cmpl(current_character(), Immediate('0')); | |
623 BranchOrBacktrack(above_equal, on_no_match); | |
624 __ bind(&done); | |
625 | |
626 return true; | 614 return true; |
627 } | 615 } |
616 | |
628 case '*': | 617 case '*': |
629 // Match any character. | 618 // Match any character. |
630 return true; | 619 return true; |
631 // No custom implementation (yet): s(UC16), S(UC16). | 620 // No custom implementation (yet): s(UC16), S(UC16). |
632 default: | 621 default: |
633 return false; | 622 return false; |
634 } | 623 } |
635 } | 624 } |
636 | 625 |
637 | 626 |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1328 Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16))); | 1317 Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16))); |
1329 } | 1318 } |
1330 } | 1319 } |
1331 } | 1320 } |
1332 | 1321 |
1333 #undef __ | 1322 #undef __ |
1334 | 1323 |
1335 #endif // V8_NATIVE_REGEXP | 1324 #endif // V8_NATIVE_REGEXP |
1336 | 1325 |
1337 }} // namespace v8::internal | 1326 }} // namespace v8::internal |
OLD | NEW |