Backed out changeset 0c0a5a6b57d9 (bug 616491) for jsreftest failures
authorWes Kocher <wkocher@mozilla.com>
Mon, 21 Apr 2014 16:11:20 -0700
changeset 197973 1a2d8d974ca737603f8344aee07d2fb9634bafc8
parent 197972 5ad5f92387a2887c6681a631d66a538e94d1a92b
child 197974 36879243d685e4f2427ed8d4558ea3ac63bc1348
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs616491
milestone31.0a1
backs out0c0a5a6b57d96b88c8de42268ed43137f4f249fb
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 0c0a5a6b57d9 (bug 616491) for jsreftest failures
js/src/yarr/YarrPattern.cpp
--- a/js/src/yarr/YarrPattern.cpp
+++ b/js/src/yarr/YarrPattern.cpp
@@ -299,32 +299,16 @@ public:
         m_pattern.reset();
         m_characterClassConstructor.reset();
 
         m_pattern.m_body = newOrCrash<PatternDisjunction>();
         m_alternative = m_pattern.m_body->addNewAlternative();
         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) {
             m_alternative->m_startsWithBOL = true;
             m_alternative->m_containsBOL = true;
             m_pattern.m_containsBOL = true;
         }
         m_alternative->m_terms.append(PatternTerm::BOL());
@@ -585,17 +569,22 @@ public:
     void disjunction()
     {
         m_alternative = m_alternative->m_parent->addNewAlternative();
     }
 
     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;
         Checked<unsigned> currentInputPosition = initialInputPosition;
 
         for (unsigned i = 0; i < alternative->m_terms.size(); ++i) {
             PatternTerm& term = alternative->m_terms[i];
 
@@ -680,19 +669,16 @@ public:
 
         alternative->m_minimumSize = (currentInputPosition - initialInputPosition).unsafeGet();
         *callFrameSizeOut = currentCallFrameSize;
         return NoError;
     }
 
     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;
 
         unsigned minimumInputSize = UINT_MAX;
         unsigned maximumCallFrameSize = 0;
         bool hasFixedSize = true;
 
         for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) {
@@ -859,32 +845,33 @@ public:
 
                 terms.append(PatternTerm(startsWithBOL, endsWithEOL));
 
                 m_pattern.m_containsBOL = false;
             }
         }
     }
 
+    void setStackBase(uint8_t *stackBase) {
+        m_stackBase = stackBase;
+    }
+
 private:
     YarrPattern& m_pattern;
     uint8_t * m_stackBase;
     PatternAlternative* m_alternative;
     CharacterClassConstructor m_characterClassConstructor;
     bool m_invertCharacterClass;
     bool m_invertParentheticalAssertion;
 };
 
 ErrorCode YarrPattern::compile(const String& patternString)
 {
     YarrPatternConstructor constructor(*this);
 
-    uint8_t stackDummy_;
-    constructor.setStackBase(&stackDummy_);
-
     if (ErrorCode error = parse(constructor, patternString))
         return error;
 
     // If the pattern contains illegal backreferences reset & reparse.
     // Quoting Netscape's "What's new in JavaScript 1.2",
     //      "Note: if the number of left parentheses is less than the number specified
     //       in \#, the \# is taken as an octal escape as described in the next row."
     if (containsIllegalBackReference()) {
@@ -895,16 +882,19 @@ ErrorCode YarrPattern::compile(const Str
         ErrorCode error =
 #endif
             parse(constructor, patternString, numSubpatterns);
 
         ASSERT(!error);
         ASSERT(numSubpatterns == m_numSubpatterns);
     }
 
+    uint8_t stackDummy_;
+    constructor.setStackBase(&stackDummy_);
+
     constructor.checkForTerminalParentheses();
     constructor.optimizeDotStarWrappedExpressions();
     constructor.optimizeBOL();
 
     if (ErrorCode error = constructor.setupOffsets())
         return error;
 
     return NoError;