Reviewers: danno, Erik Corry, Paul Lind, kisg,
Description:
MIPS: Regexp: Improve the speed that we scan for an initial point
Port r11204 (f20b1723).
Original commit message:
Regexp: Improve the speed that we scan for an initial point where a
non-anchored
regexp can match by using a Boyer-Moore-like table. This is done by
identifying
non-greedy non-capturing loops in the nodes that eat any character one at a
time.
For example in the middle of the regexp /foo[\s\S]*?bar/ we find such a
loop.
There is also such a loop implicitly inserted at the start of any
non-anchored
regexp.
When we have found such a loop we look ahead in the nodes to find the set of
characters that can come at given distances. For example for the regexp
/.?foo/ we know that there are at least 3 characters ahead of us, and the
sets
of characters that can occur are [any, [f, o], [o]]. We find a range in the
lookahead info where the set of characters is reasonably constrained. In
our
example this is from index 1 to 2 (0 is not constrained). We can now look 3
characters ahead and if we don't find one of [f, o] (the union of [f, o] and
[o]) then we can skip forwards by the range size (in this case 2).
For Unicode input strings we do the same, but modulo 128.
We also look at the first string fed to the regexp and use that to get a
hint
of the character frequencies in the inputs. This affects the assessment of
whether the set of characters is 'reasonably constrained'.
We still have the old lookahead mechanism, which uses a wide load of
multiple
characters followed by a mask and compare to determine whether a match is
possible at this point.
BUG=
TEST=
Please review this at http://codereview.chromium.org/9965107/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/mips/regexp-macro-assembler-mips.cc
Index: src/mips/regexp-macro-assembler-mips.cc
diff --git a/src/mips/regexp-macro-assembler-mips.cc
b/src/mips/regexp-macro-assembler-mips.cc
index
00461a7aeb523139c16d3459a6ba8d59be09127c..d11b904826369554dee2195b67cf7bdecf2e777d
100644
--- a/src/mips/regexp-macro-assembler-mips.cc
+++ b/src/mips/regexp-macro-assembler-mips.cc
@@ -461,7 +461,8 @@ void
RegExpMacroAssemblerMIPS::CheckCharacterAfterAnd(uint32_t c,
uint32_t mask,
Label* on_equal) {
__ And(a0, current_character(), Operand(mask));
- BranchOrBacktrack(on_equal, eq, a0, Operand(c));
+ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c);
+ BranchOrBacktrack(on_equal, eq, a0, rhs);
}
@@ -469,7 +470,8 @@ void
RegExpMacroAssemblerMIPS::CheckNotCharacterAfterAnd(uint32_t c,
uint32_t mask,
Label*
on_not_equal) {
__ And(a0, current_character(), Operand(mask));
- BranchOrBacktrack(on_not_equal, ne, a0, Operand(c));
+ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c);
+ BranchOrBacktrack(on_not_equal, ne, a0, rhs);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev