Changeset 294411 in webkit
- Timestamp:
- May 18, 2022, 11:33:44 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/stress/regexp-large-quantifier.js
r233451 r294411 1 function testRegExp(pattern, string, expected Match) {1 function testRegExp(pattern, string, expectedParseError, expectedMatch) { 2 2 const r = new RegExp(pattern); 3 const actualResult = r.exec(string); 3 let actualResult = null; 4 let actualParseError = null; 5 try { 6 actualResult = r.exec(string); 7 } catch(e) { 8 actualParseError = e; 9 } 10 11 if (expectedParseError && expectedParseError != actualParseError) 12 throw("Expected \"" + expectedParseError + "\", but got \"" + actualParseError + "\""); 13 4 14 if (expectedMatch === undefined) { 5 15 if (actualResult !== null) … … 11 21 } 12 22 13 testRegExp("a{0,4294967295}", "a", "a"); 14 testRegExp("a{0,4294967296}", "a", "a"); 15 testRegExp("^a{0,4294967296}$", "a{0,4294967296}", undefined); 16 testRegExp("(?:a{0,340282366920}?){0,1}a", "aa", "aa"); 23 testRegExp("a{0,4294967295}", "a", undefined, "a"); 24 testRegExp("a{0,4294967296}", "a", undefined, "a"); 25 testRegExp("^a{0,4294967296}$", "a{0,4294967296}", undefined, undefined); 26 testRegExp("(?:a{0,340282366920}?){0,1}a", "aa", undefined, "aa"); 27 testRegExp("((.{100000000})*.{2100000000})+", "x", "SyntaxError: Invalid regular expression: pattern exceeds string length limits", undefined); -
trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp
r291997 r294411 3597 3597 if ((term->quantityType == QuantifierType::FixedCount) && (term->type != PatternTerm::Type::ParentheticalAssertion)) 3598 3598 lastOp.m_checkAdjust -= disjunction->m_minimumSize; 3599 lastOp.m_checkedOffset = checkedOffset + lastOp.m_checkAdjust; 3599 3600 Checked<unsigned, RecordOverflow> checkedOffsetResult(checkedOffset); 3601 checkedOffsetResult += lastOp.m_checkAdjust; 3602 3603 if (UNLIKELY(checkedOffsetResult.hasOverflowed())) { 3604 m_failureReason = JITFailureReason::OffsetTooLarge; 3605 return; 3606 } 3607 3608 lastOp.m_checkedOffset = checkedOffsetResult; 3600 3609 } 3601 3610 opCompileAlternative(m_ops[lastOpIndex].m_checkedOffset, nestedAlternative); … … 4722 4731 dataLog("Can't JIT because of failure of allocation of executable memory\n"); 4723 4732 break; 4733 case JITFailureReason::OffsetTooLarge: 4734 dataLog("Can't JIT because pattern exceeds string length limits\n"); 4735 break; 4724 4736 } 4725 4737 } -
trunk/Source/JavaScriptCore/yarr/YarrJIT.h
r291972 r294411 63 63 ParenthesisNestedTooDeep, 64 64 ExecutableMemoryAllocationFailure, 65 OffsetTooLarge, 65 66 }; 66 67
Note:
See TracChangeset
for help on using the changeset viewer.