Changeset 245939 in webkit
- Timestamp:
- May 30, 2019, 5:33:42 PM (7 years ago)
- Location:
- branches/safari-607-branch/Source/JavaScriptCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
yarr/YarrInterpreter.cpp (modified) (1 diff)
-
yarr/YarrJIT.cpp (modified) (4 diffs)
-
yarr/YarrJIT.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-607-branch/Source/JavaScriptCore/ChangeLog
r245933 r245939 1 2019-05-30 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r243237. rdar://problem/51264876 4 5 JSC test crash: stress/dont-strength-reduce-regexp-with-compile-error.js.default 6 https://bugs.webkit.org/show_bug.cgi?id=195906 7 8 Reviewed by Mark Lam. 9 10 The problem here as that we may successfully parsed a RegExp without running out of stack, 11 but later run out of stack when trying to JIT compile the same expression. 12 13 Added a check for available stack space when we call into one of the parenthesis compilation 14 functions that recurse. When we don't have enough stack space to recurse, we fail the JIT 15 compilation and let the interpreter handle the expression. 16 17 From code inspection of the YARR interpreter it has the same issue, but I couldn't cause a failure. 18 Filed a new bug and added a FIXME comment for the Interpreter to have similar checks. 19 Given that we can reproduce a failure, this is sufficient for now. 20 21 This change is covered by the previously added failing test, 22 JSTests/stress/dont-strength-reduce-regexp-with-compile-error.js. 23 24 * yarr/YarrInterpreter.cpp: 25 (JSC::Yarr::Interpreter::interpret): 26 * yarr/YarrJIT.cpp: 27 (JSC::Yarr::YarrGenerator::opCompileParenthesesSubpattern): 28 (JSC::Yarr::YarrGenerator::opCompileParentheticalAssertion): 29 (JSC::Yarr::YarrGenerator::opCompileBody): 30 (JSC::Yarr::dumpCompileFailure): 31 * yarr/YarrJIT.h: 32 33 34 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243237 268f45cc-cd09-0410-ab3c-d52691b4dbfc 35 36 2019-03-20 Michael Saboff <msaboff@apple.com> 37 38 JSC test crash: stress/dont-strength-reduce-regexp-with-compile-error.js.default 39 https://bugs.webkit.org/show_bug.cgi?id=195906 40 41 Reviewed by Mark Lam. 42 43 The problem here as that we may successfully parsed a RegExp without running out of stack, 44 but later run out of stack when trying to JIT compile the same expression. 45 46 Added a check for available stack space when we call into one of the parenthesis compilation 47 functions that recurse. When we don't have enough stack space to recurse, we fail the JIT 48 compilation and let the interpreter handle the expression. 49 50 From code inspection of the YARR interpreter it has the same issue, but I couldn't cause a failure. 51 Filed a new bug and added a FIXME comment for the Interpreter to have similar checks. 52 Given that we can reproduce a failure, this is sufficient for now. 53 54 This change is covered by the previously added failing test, 55 JSTests/stress/dont-strength-reduce-regexp-with-compile-error.js. 56 57 * yarr/YarrInterpreter.cpp: 58 (JSC::Yarr::Interpreter::interpret): 59 * yarr/YarrJIT.cpp: 60 (JSC::Yarr::YarrGenerator::opCompileParenthesesSubpattern): 61 (JSC::Yarr::YarrGenerator::opCompileParentheticalAssertion): 62 (JSC::Yarr::YarrGenerator::opCompileBody): 63 (JSC::Yarr::dumpCompileFailure): 64 * yarr/YarrJIT.h: 65 1 66 2019-05-30 Kocsen Chung <kocsen_chung@apple.com> 2 67 -
branches/safari-607-branch/Source/JavaScriptCore/yarr/YarrInterpreter.cpp
r234916 r245939 1609 1609 unsigned interpret() 1610 1610 { 1611 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195970 1612 // [Yarr Interpreter] The interpreter doesn't have checks for stack overflow due to deep recursion 1611 1613 if (!input.isAvailableInput(0)) 1612 1614 return offsetNoMatch; -
branches/safari-607-branch/Source/JavaScriptCore/yarr/YarrJIT.cpp
r245928 r245939 3390 3390 YarrOpCode alternativeEndOpCode = OpSimpleNestedAlternativeEnd; 3391 3391 3392 if (UNLIKELY(!m_vm->isSafeToRecurse())) { 3393 m_failureReason = JITFailureReason::ParenthesisNestedTooDeep; 3394 return; 3395 } 3396 3392 3397 // We can currently only compile quantity 1 subpatterns that are 3393 3398 // not copies. We generate a copy in the case of a range quantifier, … … 3496 3501 void opCompileParentheticalAssertion(PatternTerm* term) 3497 3502 { 3503 if (UNLIKELY(!m_vm->isSafeToRecurse())) { 3504 m_failureReason = JITFailureReason::ParenthesisNestedTooDeep; 3505 return; 3506 } 3507 3498 3508 size_t parenBegin = m_ops.size(); 3499 3509 m_ops.append(OpParentheticalAssertionBegin); … … 3576 3586 void opCompileBody(PatternDisjunction* disjunction) 3577 3587 { 3588 if (UNLIKELY(!m_vm->isSafeToRecurse())) { 3589 m_failureReason = JITFailureReason::ParenthesisNestedTooDeep; 3590 return; 3591 } 3592 3578 3593 Vector<std::unique_ptr<PatternAlternative>>& alternatives = disjunction->m_alternatives; 3579 3594 size_t currentAlternativeIndex = 0; … … 4209 4224 dataLog("Can't JIT a pattern containing fixed count parenthesized subpatterns\n"); 4210 4225 break; 4226 case JITFailureReason::ParenthesisNestedTooDeep: 4227 dataLog("Can't JIT pattern due to parentheses nested too deeply\n"); 4228 break; 4211 4229 case JITFailureReason::ExecutableMemoryAllocationFailure: 4212 4230 dataLog("Can't JIT because of failure of allocation of executable memory\n"); -
branches/safari-607-branch/Source/JavaScriptCore/yarr/YarrJIT.h
r245926 r245939 53 53 ParenthesizedSubpattern, 54 54 FixedCountParenthesizedSubpattern, 55 ParenthesisNestedTooDeep, 55 56 ExecutableMemoryAllocationFailure, 56 57 };
Note:
See TracChangeset
for help on using the changeset viewer.