Author: [email protected]
Date: Mon Jan 26 05:04:49 2009
New Revision: 1150
Modified:
branches/bleeding_edge/src/jsregexp.cc
branches/bleeding_edge/src/regexp-macro-assembler-ia32.h
branches/bleeding_edge/src/regexp-macro-assembler.h
branches/bleeding_edge/test/mjsunit/regexp.js
Log:
* Remember to check for end of string even where we
know the character class must match.
Thanks to Mads and Christian for finding this bug
Review URL: http://codereview.chromium.org/18750
Modified: branches/bleeding_edge/src/jsregexp.cc
==============================================================================
--- branches/bleeding_edge/src/jsregexp.cc (original)
+++ branches/bleeding_edge/src/jsregexp.cc Mon Jan 26 05:04:49 2009
@@ -1835,6 +1835,9 @@
// ASCII optimizations for us.
macro_assembler->GoTo(on_failure);
}
+ if (check_offset) {
+ macro_assembler->CheckPosition(cp_offset, on_failure);
+ }
return;
}
@@ -1842,10 +1845,8 @@
!cc->is_negated() &&
ranges->at(0).IsEverything(max_char)) {
// This is a common case hit by non-anchored expressions.
- // TODO(erikcorry): We should have a macro assembler instruction that
just
- // checks for end of string without loading the character.
if (check_offset) {
- macro_assembler->LoadCurrentCharacter(cp_offset, on_failure);
+ macro_assembler->CheckPosition(cp_offset, on_failure);
}
return;
}
@@ -2477,7 +2478,7 @@
switch (type_) {
case AT_END: {
Label ok;
- assembler->LoadCurrentCharacter(trace->cp_offset(), &ok);
+ assembler->CheckPosition(trace->cp_offset(), &ok);
assembler->GoTo(trace->backtrack());
assembler->Bind(&ok);
break;
Modified: branches/bleeding_edge/src/regexp-macro-assembler-ia32.h
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler-ia32.h (original)
+++ branches/bleeding_edge/src/regexp-macro-assembler-ia32.h Mon Jan 26
05:04:49 2009
@@ -71,6 +71,9 @@
uc16 minus,
uc16 mask,
Label* on_not_equal);
+ // Checks whether the given offset from the current position is before
+ // the end of the string.
+ virtual void CheckPosition(int cp_offset, Label* on_outside_input);
virtual bool CheckSpecialCharacterClass(uc16 type,
int cp_offset,
bool check_offset,
@@ -170,10 +173,6 @@
// successful, or 0 if unable to grow the stack.
// This function must not trigger a garbage collection.
static Address GrowStack(Address stack_top);
-
- // Checks whether the given offset from the current position is before
- // the end of the string.
- void CheckPosition(int cp_offset, Label* on_outside_input);
// The ebp-relative location of a regexp register.
Operand register_location(int register_index);
Modified: branches/bleeding_edge/src/regexp-macro-assembler.h
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler.h (original)
+++ branches/bleeding_edge/src/regexp-macro-assembler.h Mon Jan 26 05:04:49
2009
@@ -111,6 +111,12 @@
virtual void CheckNotRegistersEqual(int reg1,
int reg2,
Label* on_not_equal) = 0;
+
+ // Checks whether the given offset from the current position is before
+ // the end of the string. May overwrite the current character.
+ virtual void CheckPosition(int cp_offset, Label* on_outside_input) {
+ LoadCurrentCharacter(cp_offset, on_outside_input, true);
+ }
// Check whether a standard/default character class matches the current
// character. Returns false if the type of special character class does
// not have custom support.
Modified: branches/bleeding_edge/test/mjsunit/regexp.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/regexp.js (original)
+++ branches/bleeding_edge/test/mjsunit/regexp.js Mon Jan 26 05:04:49 2009
@@ -332,3 +332,7 @@
assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt6');
assertFalse(/xy([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt7');
assertFalse(/x([0-7]%%%x|[0-6]%%%y)/.test('x7%%%y'), 'qt8');
+
+
+// Don't hang on this one.
+/[^\xfe-\xff]*/.test("");
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---