Index: src/jsregexp.cc |
=================================================================== |
--- src/jsregexp.cc (revision 11684) |
+++ src/jsregexp.cc (working copy) |
@@ -2191,12 +2191,13 @@ |
void ActionNode::FillInBMInfo(int offset, |
+ int recursion_depth, |
BoyerMooreLookahead* bm, |
bool not_at_start) { |
if (type_ == BEGIN_SUBMATCH) { |
bm->SetRest(offset); |
} else if (type_ != POSITIVE_SUBMATCH_SUCCESS) { |
- on_success()->FillInBMInfo(offset, bm, not_at_start); |
+ on_success()->FillInBMInfo(offset, recursion_depth + 1, bm, not_at_start); |
} |
SaveBMInfo(bm, not_at_start, offset); |
} |
@@ -2218,11 +2219,13 @@ |
} |
-void AssertionNode::FillInBMInfo( |
- int offset, BoyerMooreLookahead* bm, bool not_at_start) { |
+void AssertionNode::FillInBMInfo(int offset, |
+ int recursion_depth, |
+ BoyerMooreLookahead* bm, |
+ bool not_at_start) { |
// Match the behaviour of EatsAtLeast on this node. |
if (type() == AT_START && not_at_start) return; |
- on_success()->FillInBMInfo(offset, bm, not_at_start); |
+ on_success()->FillInBMInfo(offset, recursion_depth + 1, bm, not_at_start); |
SaveBMInfo(bm, not_at_start, offset); |
} |
@@ -2803,14 +2806,17 @@ |
} |
-void LoopChoiceNode::FillInBMInfo( |
- int offset, BoyerMooreLookahead* bm, bool not_at_start) { |
- if (body_can_be_zero_length_) { |
+void LoopChoiceNode::FillInBMInfo(int offset, |
+ int recursion_depth, |
+ BoyerMooreLookahead* bm, |
+ bool not_at_start) { |
+ if (body_can_be_zero_length_ || |
+ recursion_depth > RegExpCompiler::kMaxRecursion) { |
bm->SetRest(offset); |
SaveBMInfo(bm, not_at_start, offset); |
return; |
} |
- ChoiceNode::FillInBMInfo(offset, bm, not_at_start); |
+ ChoiceNode::FillInBMInfo(offset, recursion_depth + 1, bm, not_at_start); |
SaveBMInfo(bm, not_at_start, offset); |
} |
@@ -2912,7 +2918,7 @@ |
if (eats_at_least >= 1) { |
BoyerMooreLookahead* bm = |
new BoyerMooreLookahead(eats_at_least, compiler); |
- FillInBMInfo(0, bm, not_at_start); |
+ FillInBMInfo(0, 0, bm, not_at_start); |
if (bm->at(0)->is_non_word()) next_is_word_character = Trace::FALSE; |
if (bm->at(0)->is_word()) next_is_word_character = Trace::TRUE; |
} |
@@ -3850,7 +3856,7 @@ |
BoyerMooreLookahead* bm = |
new BoyerMooreLookahead(eats_at_least, compiler); |
GuardedAlternative alt0 = alternatives_->at(0); |
- alt0.node()->FillInBMInfo(0, bm, not_at_start); |
+ alt0.node()->FillInBMInfo(0, 0, bm, not_at_start); |
skip_was_emitted = bm->EmitSkipInstructions(macro_assembler); |
} |
} else { |
@@ -5589,8 +5595,10 @@ |
} |
-void BackReferenceNode::FillInBMInfo( |
- int offset, BoyerMooreLookahead* bm, bool not_at_start) { |
+void BackReferenceNode::FillInBMInfo(int offset, |
+ int recursion_depth, |
+ BoyerMooreLookahead* bm, |
+ bool not_at_start) { |
// Working out the set of characters that a backreference can match is too |
// hard, so we just say that any character can match. |
bm->SetRest(offset); |
@@ -5602,8 +5610,10 @@ |
RegExpMacroAssembler::kTableSize); |
-void ChoiceNode::FillInBMInfo( |
- int offset, BoyerMooreLookahead* bm, bool not_at_start) { |
+void ChoiceNode::FillInBMInfo(int offset, |
+ int recursion_depth, |
+ BoyerMooreLookahead* bm, |
+ bool not_at_start) { |
ZoneList<GuardedAlternative>* alts = alternatives(); |
ulan
2012/05/31 11:56:23
We don't check recursion_depth here, because nesti
Erik Corry
2012/05/31 13:51:43
Yes, it's only LoopChoiceNodes that can lead to un
|
for (int i = 0; i < alts->length(); i++) { |
GuardedAlternative& alt = alts->at(i); |
@@ -5612,14 +5622,16 @@ |
SaveBMInfo(bm, not_at_start, offset); |
return; |
} |
- alt.node()->FillInBMInfo(offset, bm, not_at_start); |
+ alt.node()->FillInBMInfo(offset, recursion_depth + 1, bm, not_at_start); |
} |
SaveBMInfo(bm, not_at_start, offset); |
} |
-void TextNode::FillInBMInfo( |
- int initial_offset, BoyerMooreLookahead* bm, bool not_at_start) { |
+void TextNode::FillInBMInfo(int initial_offset, |
+ int recursion_depth, |
+ BoyerMooreLookahead* bm, |
+ bool not_at_start) { |
if (initial_offset >= bm->length()) return; |
int offset = initial_offset; |
int max_char = bm->max_char(); |
@@ -5673,6 +5685,7 @@ |
return; |
} |
on_success()->FillInBMInfo(offset, |
+ recursion_depth + 1, |
bm, |
true); // Not at start after a text node. |
if (initial_offset == 0) set_bm_info(not_at_start, bm); |