Repository navigation
Commit 4681ea8
committed
[JSC] DFG should not turn a call to RegExp into NewRegExpUntyped
https://bugs.webkit.org/show_bug.cgi?id=327458
rdar://189954203
Reviewed by Dan Hecht.
ByteCodeParser::handleConstantFunction lowered RegExp to NewRegExpUntyped without
checking whether the site is a construct. For a call, argument 0 is `this`, so
`RegExp.call(RegExp, re, undefined)` passed the new.target == callee check and
allocated a fresh RegExp. Called as a function, RegExp returns the pattern itself
when it is a RegExp, the flags are undefined, and pattern.constructor is RegExp.
This patch restricts the lowering to construct sites.
Test: JSTests/stress/regexp-constructor-call-is-not-construct.js
* JSTests/stress/regexp-constructor-call-is-not-construct.js: Added.
(shouldBe):
(callWithCalleeAsThis):
(construct):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleConstantFunction):
Canonical link: https://commits.webkit.org/323678@main1 parent 9f54364 commit 4681ea8
2 files changed
Lines changed: 21 additions & 1 deletion
File tree
- JSTests/stress
- Source/JavaScriptCore/dfg
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6741 | 6741 | | |
6742 | 6742 | | |
6743 | 6743 | | |
6744 | | - | |
| 6744 | + | |
6745 | 6745 | | |
6746 | 6746 | | |
6747 | 6747 | | |
| |||
0 commit comments