Index: src/arm/regexp-macro-assembler-arm.cc |
diff --git a/src/arm/regexp-macro-assembler-arm.cc b/src/arm/regexp-macro-assembler-arm.cc |
index 252d7839fbf4e863e12eebcf4f2d659a19580ed3..2e75a61a846cc94f14fb3b7353b7b8b68f1307f5 100644 |
--- a/src/arm/regexp-macro-assembler-arm.cc |
+++ b/src/arm/regexp-macro-assembler-arm.cc |
@@ -216,25 +216,29 @@ void RegExpMacroAssemblerARM::CheckCharacters(Vector<const uc16> str, |
int cp_offset, |
Label* on_failure, |
bool check_end_of_string) { |
- int byte_length = str.length() * char_size(); |
- int byte_offset = cp_offset * char_size(); |
- if (check_end_of_string) { |
- // Check that there are at least str.length() characters left in the input. |
- __ cmp(end_of_input_address(), Operand(-(byte_offset + byte_length))); |
- BranchOrBacktrack(gt, on_failure); |
- } |
- |
if (on_failure == NULL) { |
- // Instead of inlining a backtrack, (re)use the global backtrack target. |
+ // Instead of inlining a backtrack for each test, (re)use the global |
+ // backtrack target. |
on_failure = &backtrack_label_; |
} |
+ if (check_end_of_string) { |
+ // Is last character of required match inside string. |
+ CheckPosition(cp_offset + str.length() - 1, on_failure); |
+ } |
+ |
__ add(r0, end_of_input_address(), Operand(current_input_offset())); |
+ if (cp_offset != 0) { |
+ int byte_offset = cp_offset * char_size(); |
+ __ add(r0, r0, Operand(byte_offset)); |
+ } |
+ |
+ // r0 : Address of characters to match against str. |
int stored_high_byte = 0; |
for (int i = 0; i < str.length(); i++) { |
if (mode_ == ASCII) { |
__ ldrb(r1, MemOperand(r0, char_size(), PostIndex)); |
- // str[i] is known to be an ASCII character. |
+ ASSERT(str[i] <= String::kMaxAsciiCharCode); |
__ cmp(r1, Operand(str[i])); |
} else { |
__ ldrh(r1, MemOperand(r0, char_size(), PostIndex)); |