Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2008-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2008-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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 // Compare original value to 0x2028 and 0x2029, using the already | 532 // Compare original value to 0x2028 and 0x2029, using the already |
| 533 // computed (current_char ^ 0x01 - 0x0b). I.e., check for | 533 // computed (current_char ^ 0x01 - 0x0b). I.e., check for |
| 534 // 0x201d (0x2028 - 0x0b) or 0x201e. | 534 // 0x201d (0x2028 - 0x0b) or 0x201e. |
| 535 __ sub(Operand(eax), Immediate(0x2028 - 0x0b)); | 535 __ sub(Operand(eax), Immediate(0x2028 - 0x0b)); |
| 536 __ cmp(eax, 0x2029 - 0x2028); | 536 __ cmp(eax, 0x2029 - 0x2028); |
| 537 BranchOrBacktrack(below_equal, on_no_match); | 537 BranchOrBacktrack(below_equal, on_no_match); |
| 538 } | 538 } |
| 539 return true; | 539 return true; |
| 540 } | 540 } |
| 541 case 'w': { | 541 case 'w': { |
| 542 Label done, check_digits; | 542 if (mode_ != ASCII) { |
| 543 __ cmp(Operand(current_character()), Immediate('9')); | 543 // Table is 128 bits, so all ASCII characters can be tested. |
|
Erik Corry
2010/01/15 12:02:09
bytes.
| |
| 544 __ j(less_equal, &check_digits); | 544 __ cmp(Operand(current_character()), Immediate('z')); |
| 545 __ cmp(Operand(current_character()), Immediate('_')); | 545 BranchOrBacktrack(above, on_no_match); |
| 546 __ j(equal, &done); | 546 } |
| 547 // Convert to lower case if letter. | 547 ASSERT_EQ(0, word_character_map[0]); // Character '\0' is not a word char. |
|
Erik Corry
2010/01/15 12:02:09
Perhaps also assert that word_character_map['a'] i
Lasse Reichstein
2010/01/18 09:56:52
I'll put it in the comment at the table declaratio
| |
| 548 __ mov(Operand(eax), current_character()); | 548 ExternalReference word_map = ExternalReference::re_word_character_map(); |
| 549 __ or_(eax, 0x20); | 549 __ test_b(current_character(), |
| 550 // check current character in range ['a'..'z'], nondestructively. | 550 Operand::StaticArray(current_character(), times_1, word_map)); |
| 551 __ sub(Operand(eax), Immediate('a')); | 551 BranchOrBacktrack(zero, on_no_match); |
| 552 __ cmp(Operand(eax), Immediate('z' - 'a')); | |
| 553 BranchOrBacktrack(above, on_no_match); | |
| 554 __ jmp(&done); | |
| 555 __ bind(&check_digits); | |
| 556 // Check current character in range ['0'..'9']. | |
| 557 __ cmp(Operand(current_character()), Immediate('0')); | |
| 558 BranchOrBacktrack(below, on_no_match); | |
| 559 __ bind(&done); | |
| 560 | |
| 561 return true; | 552 return true; |
| 562 } | 553 } |
| 563 case 'W': { | 554 case 'W': { |
| 564 Label done, check_digits; | 555 Label done; |
| 565 __ cmp(Operand(current_character()), Immediate('9')); | 556 if (mode_ != ASCII) { |
| 566 __ j(less_equal, &check_digits); | 557 // Table is 128 bits, so all ASCII characters can be tested. |
|
Erik Corry
2010/01/15 12:02:09
bytes
| |
| 567 __ cmp(Operand(current_character()), Immediate('_')); | 558 __ cmp(Operand(current_character()), Immediate('z')); |
| 568 BranchOrBacktrack(equal, on_no_match); | 559 __ j(above, &done); |
| 569 // Convert to lower case if letter. | 560 } |
| 570 __ mov(Operand(eax), current_character()); | 561 ASSERT_EQ(0, word_character_map[0]); // Character '\0' is not a word char. |
| 571 __ or_(eax, 0x20); | 562 ExternalReference word_map = ExternalReference::re_word_character_map(); |
| 572 // check current character in range ['a'..'z'], nondestructively. | 563 __ test_b(current_character(), |
| 573 __ sub(Operand(eax), Immediate('a')); | 564 Operand::StaticArray(current_character(), times_1, word_map)); |
| 574 __ cmp(Operand(eax), Immediate('z' - 'a')); | 565 BranchOrBacktrack(not_zero, on_no_match); |
| 575 BranchOrBacktrack(below_equal, on_no_match); | 566 if (mode_ != ASCII) { |
| 576 __ jmp(&done); | 567 __ bind(&done); |
| 577 __ bind(&check_digits); | 568 } |
| 578 // Check current character in range ['0'..'9']. | |
| 579 __ cmp(Operand(current_character()), Immediate('0')); | |
| 580 BranchOrBacktrack(above_equal, on_no_match); | |
| 581 __ bind(&done); | |
| 582 return true; | 569 return true; |
| 583 } | 570 } |
| 584 // Non-standard classes (with no syntactic shorthand) used internally. | 571 // Non-standard classes (with no syntactic shorthand) used internally. |
| 585 case '*': | 572 case '*': |
| 586 // Match any character. | 573 // Match any character. |
| 587 return true; | 574 return true; |
| 588 case 'n': { | 575 case 'n': { |
| 589 // Match newlines (0x0a('\n'), 0x0d('\r'), 0x2028 or 0x2029). | 576 // Match newlines (0x0a('\n'), 0x0d('\r'), 0x2028 or 0x2029). |
| 590 // The opposite of '.'. | 577 // The opposite of '.'. |
| 591 __ mov(Operand(eax), current_character()); | 578 __ mov(Operand(eax), current_character()); |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1210 } | 1197 } |
| 1211 } | 1198 } |
| 1212 } | 1199 } |
| 1213 | 1200 |
| 1214 | 1201 |
| 1215 #undef __ | 1202 #undef __ |
| 1216 | 1203 |
| 1217 #endif // V8_NATIVE_REGEXP | 1204 #endif // V8_NATIVE_REGEXP |
| 1218 | 1205 |
| 1219 }} // namespace v8::internal | 1206 }} // namespace v8::internal |
| OLD | NEW |