Title: [245928] branches/safari-607-branch
Revision
245928
Author
[email protected]
Date
2019-05-30 17:30:23 -0700 (Thu, 30 May 2019)

Log Message

Cherry-pick r245815. rdar://problem/51264876

    [YARR] Properly handle RegExp's that require large ParenContext space
    https://bugs.webkit.org/show_bug.cgi?id=198065

    Reviewed by Keith Miller.

    JSTests:

    New test.

    * stress/regexp-large-paren-context.js: Added.
    (testLargeRegExp):

    Source/_javascript_Core:

    Changed what happens when we exceed VM::patternContextBufferSize when compiling a RegExp
    that needs ParenCOntextSpace to fail the RegExp JIT compilation and fall back to the YARR
    interpreter.  This can save large amounts of JIT memory for a
    JIT'ed function that cannot ever succeed.

    * yarr/YarrJIT.cpp:
    (JSC::Yarr::YarrGenerator::initParenContextFreeList):
    (JSC::Yarr::YarrGenerator::compile):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245815 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-607-branch/JSTests/ChangeLog (245927 => 245928)


--- branches/safari-607-branch/JSTests/ChangeLog	2019-05-31 00:30:20 UTC (rev 245927)
+++ branches/safari-607-branch/JSTests/ChangeLog	2019-05-31 00:30:23 UTC (rev 245928)
@@ -1,5 +1,47 @@
 2019-05-30  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r245815. rdar://problem/51264876
+
+    [YARR] Properly handle RegExp's that require large ParenContext space
+    https://bugs.webkit.org/show_bug.cgi?id=198065
+    
+    Reviewed by Keith Miller.
+    
+    JSTests:
+    
+    New test.
+    
+    * stress/regexp-large-paren-context.js: Added.
+    (testLargeRegExp):
+    
+    Source/_javascript_Core:
+    
+    Changed what happens when we exceed VM::patternContextBufferSize when compiling a RegExp
+    that needs ParenCOntextSpace to fail the RegExp JIT compilation and fall back to the YARR
+    interpreter.  This can save large amounts of JIT memory for a
+    JIT'ed function that cannot ever succeed.
+    
+    * yarr/YarrJIT.cpp:
+    (JSC::Yarr::YarrGenerator::initParenContextFreeList):
+    (JSC::Yarr::YarrGenerator::compile):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245815 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-05-28  Michael Saboff  <[email protected]>
+
+            [YARR] Properly handle RegExp's that require large ParenContext space
+            https://bugs.webkit.org/show_bug.cgi?id=198065
+
+            Reviewed by Keith Miller.
+
+            New test.
+
+            * stress/regexp-large-paren-context.js: Added.
+            (testLargeRegExp):
+
+2019-05-30  Kocsen Chung  <[email protected]>
+
         Cherry-pick r245586. rdar://problem/51264876
 
     Cleanup Yarr regexp code around paren contexts.

Added: branches/safari-607-branch/JSTests/stress/regexp-large-paren-context.js (0 => 245928)


--- branches/safari-607-branch/JSTests/stress/regexp-large-paren-context.js	                        (rev 0)
+++ branches/safari-607-branch/JSTests/stress/regexp-large-paren-context.js	2019-05-31 00:30:23 UTC (rev 245928)
@@ -0,0 +1,22 @@
+// Test the regular expresions that need lots of parenthesis context space work.
+// This includes falling back to the interpreter.
+
+function testLargeRegExp(terms)
+{
+    let s = '';
+    for (let i = 0; i < terms; i++) {
+        s += '(?:a){0,2}';
+    }
+
+    let r = new RegExp(s);
+    for (let i = 0; i < 10; i++)
+        ''.match(r);
+}
+
+testLargeRegExp(127);
+testLargeRegExp(128);
+testLargeRegExp(255);
+testLargeRegExp(256);
+testLargeRegExp(1000);
+
+

Modified: branches/safari-607-branch/Source/_javascript_Core/ChangeLog (245927 => 245928)


--- branches/safari-607-branch/Source/_javascript_Core/ChangeLog	2019-05-31 00:30:20 UTC (rev 245927)
+++ branches/safari-607-branch/Source/_javascript_Core/ChangeLog	2019-05-31 00:30:23 UTC (rev 245928)
@@ -1,5 +1,51 @@
 2019-05-30  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r245815. rdar://problem/51264876
+
+    [YARR] Properly handle RegExp's that require large ParenContext space
+    https://bugs.webkit.org/show_bug.cgi?id=198065
+    
+    Reviewed by Keith Miller.
+    
+    JSTests:
+    
+    New test.
+    
+    * stress/regexp-large-paren-context.js: Added.
+    (testLargeRegExp):
+    
+    Source/_javascript_Core:
+    
+    Changed what happens when we exceed VM::patternContextBufferSize when compiling a RegExp
+    that needs ParenCOntextSpace to fail the RegExp JIT compilation and fall back to the YARR
+    interpreter.  This can save large amounts of JIT memory for a
+    JIT'ed function that cannot ever succeed.
+    
+    * yarr/YarrJIT.cpp:
+    (JSC::Yarr::YarrGenerator::initParenContextFreeList):
+    (JSC::Yarr::YarrGenerator::compile):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245815 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-05-28  Michael Saboff  <[email protected]>
+
+            [YARR] Properly handle RegExp's that require large ParenContext space
+            https://bugs.webkit.org/show_bug.cgi?id=198065
+
+            Reviewed by Keith Miller.
+
+            Changed what happens when we exceed VM::patternContextBufferSize when compiling a RegExp
+            that needs ParenCOntextSpace to fail the RegExp JIT compilation and fall back to the YARR
+            interpreter.  This can save large amounts of JIT memory for a
+            JIT'ed function that cannot ever succeed.
+
+            * yarr/YarrJIT.cpp:
+            (JSC::Yarr::YarrGenerator::initParenContextFreeList):
+            (JSC::Yarr::YarrGenerator::compile):
+
+2019-05-30  Kocsen Chung  <[email protected]>
+
         Cherry-pick r245586. rdar://problem/51264876
 
     Cleanup Yarr regexp code around paren contexts.

Modified: branches/safari-607-branch/Source/_javascript_Core/yarr/YarrJIT.cpp (245927 => 245928)


--- branches/safari-607-branch/Source/_javascript_Core/yarr/YarrJIT.cpp	2019-05-31 00:30:20 UTC (rev 245927)
+++ branches/safari-607-branch/Source/_javascript_Core/yarr/YarrJIT.cpp	2019-05-31 00:30:23 UTC (rev 245928)
@@ -228,9 +228,10 @@
 
         parenContextSize = WTF::roundUpToMultipleOf<sizeof(uintptr_t)>(parenContextSize);
 
-        // Check that the paren context is a reasonable size.
-        if (parenContextSize > VM::patternContextBufferSize)
-            m_abortExecution.append(jump());
+        if (parenContextSize > VM::patternContextBufferSize) {
+            m_failureReason = JITFailureReason::ParenthesisNestedTooDeep;
+            return;
+        }
 
         Jump emptyFreeList = branchTestPtr(Zero, freelistRegister);
         move(freelistRegister, parenContextPointer);
@@ -3872,8 +3873,13 @@
         initCallFrame();
 
 #if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
-        if (m_containsNestedSubpatterns)
+        if (m_containsNestedSubpatterns) {
             initParenContextFreeList();
+            if (m_failureReason) {
+                codeBlock.setFallBackWithFailureReason(*m_failureReason);
+                return;
+            }
+        }
 #endif
         
         if (m_pattern.m_saveInitialStartValue) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to