Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: src/ia32/regexp-macro-assembler-ia32.cc

Issue 547024: RegExp bitmap test for word character. (Closed)
Patch Set: Changed to char-map. Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ia32/regexp-macro-assembler-ia32.cc
diff --git a/src/ia32/regexp-macro-assembler-ia32.cc b/src/ia32/regexp-macro-assembler-ia32.cc
index e41f9c3f0c2321291a5b832982ff79c27f7a69b3..7d6056de5f94f80a701d00dddfe97d9ff423e3d0 100644
--- a/src/ia32/regexp-macro-assembler-ia32.cc
+++ b/src/ia32/regexp-macro-assembler-ia32.cc
@@ -539,46 +539,33 @@ bool RegExpMacroAssemblerIA32::CheckSpecialCharacterClass(uc16 type,
return true;
}
case 'w': {
- Label done, check_digits;
- __ cmp(Operand(current_character()), Immediate('9'));
- __ j(less_equal, &check_digits);
- __ cmp(Operand(current_character()), Immediate('_'));
- __ j(equal, &done);
- // Convert to lower case if letter.
- __ mov(Operand(eax), current_character());
- __ or_(eax, 0x20);
- // check current character in range ['a'..'z'], nondestructively.
- __ sub(Operand(eax), Immediate('a'));
- __ cmp(Operand(eax), Immediate('z' - 'a'));
- BranchOrBacktrack(above, on_no_match);
- __ jmp(&done);
- __ bind(&check_digits);
- // Check current character in range ['0'..'9'].
- __ cmp(Operand(current_character()), Immediate('0'));
- BranchOrBacktrack(below, on_no_match);
- __ bind(&done);
-
+ if (mode_ != ASCII) {
+ // Table is 128 bits, so all ASCII characters can be tested.
Erik Corry 2010/01/15 12:02:09 bytes.
+ __ cmp(Operand(current_character()), Immediate('z'));
+ BranchOrBacktrack(above, on_no_match);
+ }
+ 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
+ ExternalReference word_map = ExternalReference::re_word_character_map();
+ __ test_b(current_character(),
+ Operand::StaticArray(current_character(), times_1, word_map));
+ BranchOrBacktrack(zero, on_no_match);
return true;
}
case 'W': {
- Label done, check_digits;
- __ cmp(Operand(current_character()), Immediate('9'));
- __ j(less_equal, &check_digits);
- __ cmp(Operand(current_character()), Immediate('_'));
- BranchOrBacktrack(equal, on_no_match);
- // Convert to lower case if letter.
- __ mov(Operand(eax), current_character());
- __ or_(eax, 0x20);
- // check current character in range ['a'..'z'], nondestructively.
- __ sub(Operand(eax), Immediate('a'));
- __ cmp(Operand(eax), Immediate('z' - 'a'));
- BranchOrBacktrack(below_equal, on_no_match);
- __ jmp(&done);
- __ bind(&check_digits);
- // Check current character in range ['0'..'9'].
- __ cmp(Operand(current_character()), Immediate('0'));
- BranchOrBacktrack(above_equal, on_no_match);
- __ bind(&done);
+ Label done;
+ if (mode_ != ASCII) {
+ // Table is 128 bits, so all ASCII characters can be tested.
Erik Corry 2010/01/15 12:02:09 bytes
+ __ cmp(Operand(current_character()), Immediate('z'));
+ __ j(above, &done);
+ }
+ ASSERT_EQ(0, word_character_map[0]); // Character '\0' is not a word char.
+ ExternalReference word_map = ExternalReference::re_word_character_map();
+ __ test_b(current_character(),
+ Operand::StaticArray(current_character(), times_1, word_map));
+ BranchOrBacktrack(not_zero, on_no_match);
+ if (mode_ != ASCII) {
+ __ bind(&done);
+ }
return true;
}
// Non-standard classes (with no syntactic shorthand) used internally.

Powered by Google App Engine
This is Rietveld 408576698