From c669a16e2dd2731db9f924b9bc202ef345c5808d Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Mon, 21 Apr 2014 16:11:20 -0700 Subject: [PATCH] Backed out changeset 0c0a5a6b57d9 (bug 616491) for jsreftest failures --- js/src/yarr/YarrPattern.cpp | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/js/src/yarr/YarrPattern.cpp b/js/src/yarr/YarrPattern.cpp index b04be18fe79..60dca3f02ab 100644 --- a/js/src/yarr/YarrPattern.cpp +++ b/js/src/yarr/YarrPattern.cpp @@ -304,22 +304,6 @@ public: m_pattern.m_disjunctions.append(m_pattern.m_body); } - void setStackBase(uint8_t *stackBase) { - m_stackBase = stackBase; - } - - bool isOverRecursed() { - /* - * Bug 616491: attempt detection of over-recursion. - * "256KB should be enough stack for anyone." - */ - uint8_t stackDummy_; - JS_ASSERT(m_stackBase != nullptr); - if (m_stackBase - &stackDummy_ > (1 << 18)) - return true; - return false; - } - void assertionBOL() { if (!m_alternative->m_terms.size() & !m_invertParentheticalAssertion) { @@ -590,7 +574,12 @@ public: ErrorCode setupAlternativeOffsets(PatternAlternative* alternative, unsigned currentCallFrameSize, unsigned initialInputPosition, unsigned *callFrameSizeOut) { - if (isOverRecursed()) + /* + * Attempt detection of over-recursion: + * "1MB should be enough stack for anyone." + */ + uint8_t stackDummy_; + if (m_stackBase - &stackDummy_ > 1024*1024) return PatternTooLarge; alternative->m_hasFixedSize = true; @@ -685,9 +674,6 @@ public: ErrorCode setupDisjunctionOffsets(PatternDisjunction* disjunction, unsigned initialCallFrameSize, unsigned initialInputPosition, unsigned *maximumCallFrameSizeOut) { - if (isOverRecursed()) - return PatternTooLarge; - if ((disjunction != m_pattern.m_body) && (disjunction->m_alternatives.size() > 1)) initialCallFrameSize += YarrStackSpaceForBackTrackInfoAlternative; @@ -864,6 +850,10 @@ public: } } + void setStackBase(uint8_t *stackBase) { + m_stackBase = stackBase; + } + private: YarrPattern& m_pattern; uint8_t * m_stackBase; @@ -877,9 +867,6 @@ ErrorCode YarrPattern::compile(const String& patternString) { YarrPatternConstructor constructor(*this); - uint8_t stackDummy_; - constructor.setStackBase(&stackDummy_); - if (ErrorCode error = parse(constructor, patternString)) return error; @@ -900,6 +887,9 @@ ErrorCode YarrPattern::compile(const String& patternString) ASSERT(numSubpatterns == m_numSubpatterns); } + uint8_t stackDummy_; + constructor.setStackBase(&stackDummy_); + constructor.checkForTerminalParentheses(); constructor.optimizeDotStarWrappedExpressions(); constructor.optimizeBOL();