-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick b0b694f. rdar://problem/100902686
Strength reduction analyzes RegEx.exec incorrectly and generate a hole for the result array https://bugs.webkit.org/show_bug.cgi?id=245464 rdar://100494428 Reviewed by Mark Lam. When employing RegExp.exec strength reductions, we need to create "undefined" entries in the result array instead of null entries per the EcmaScript spec for RegExp.match. * JSTests/stress/regexp-strengthreduce-results-noholes.js: Added. (runRegExp): (assertSameAsFirstResult): * Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp: (JSC::DFG::StrengthReductionPhase::handleNode): Canonical link: https://commits.webkit.org/256241@main Canonical link: https://commits.webkit.org/245886.843@safari-7613.4.1.0-branch
- Loading branch information
Showing
2 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// This teset passes if it doesn't throw. | ||
|
||
function runRegExp() | ||
{ | ||
let m = /ab(c)?d/.exec("abd"); | ||
return m; | ||
} | ||
|
||
noInline(runRegExp); | ||
|
||
let firstResult = undefined; | ||
let firstResultKeys = undefined; | ||
|
||
function assertSameAsFirstResult(testRun, o) | ||
{ | ||
if (firstResult.length != o.length) | ||
throw testRun + " results have different length than the first results"; | ||
|
||
oKeys = Object.keys(o); | ||
|
||
if (firstResultKeys.length != oKeys.length) | ||
throw testRun + " results have different number of keys than the first result, first result keys: " + firstResultKeys + " this result keys: " + oKeys; | ||
|
||
for (let i = 0; i < firstResultKeys.length; i++) | ||
{ | ||
if (firstResultKeys[i] != oKeys[i]) | ||
throw testRun + " results mismatch, first result keys: " + firstResultKeys + " this result keys: " + oKeys; | ||
} | ||
} | ||
|
||
let count = 20000; | ||
|
||
for (let i=0; i < count; i++) { | ||
let result = runRegExp(); | ||
if (i == 0) { | ||
firstResult = result; | ||
firstResultKeys = Object.keys(firstResult); | ||
continue; | ||
} | ||
|
||
assertSameAsFirstResult(i, result); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters