Skip to content

Commit d9b3841

Browse files
committed
[JSC] DFG iterator_next / iterator_open should emit Phantom for uses before emitting ForceOSRExit
https://bugs.webkit.org/show_bug.cgi?id=309204 rdar://171766191 Reviewed by Keith Miller. If we would like to emit ForceOSRExit in ByteCodeParser, we need to put Phantom to make sure that used locals are alive in DFG. Otherwise, DFG thinks that this is dead, and emitting undefined when OSR happens. Test: JSTests/stress/iterator-next-liveness.js * JSTests/stress/iterator-next-liveness.js: Added. * Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): Canonical link: https://commits.webkit.org/308677@main
1 parent d6049c2 commit d9b3841

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const len = 500; // seems to happen most frequently between about 500-2000
2+
const es = new Array(len);
3+
const fs = new Array(len);
4+
const as = [
5+
['foo', [1]],
6+
['foo', [1, 2]]
7+
];
8+
for (const [a, [b, c, d]] of as) {
9+
for (const e of es) {
10+
for (const f of fs) {}
11+
}
12+
}

Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9286,6 +9286,8 @@ void ByteCodeParser::parseBlock(unsigned limit)
92869286
if (!generatedCase) {
92879287
Node* result = jsConstant(JSValue());
92889288
addToGraph(ForceOSRExit);
9289+
addToGraph(Phantom, get(bytecode.m_symbolIterator));
9290+
addToGraph(Phantom, get(bytecode.m_iterable));
92899291
set(bytecode.m_iterator, result);
92909292
set(bytecode.m_next, result);
92919293

@@ -9533,6 +9535,9 @@ void ByteCodeParser::parseBlock(unsigned limit)
95339535
if (!generatedCase) {
95349536
Node* result = jsConstant(JSValue());
95359537
addToGraph(ForceOSRExit);
9538+
addToGraph(Phantom, get(bytecode.m_next));
9539+
addToGraph(Phantom, get(bytecode.m_iterator));
9540+
addToGraph(Phantom, get(bytecode.m_iterable));
95369541
set(bytecode.m_value, result);
95379542
set(bytecode.m_done, result);
95389543

0 commit comments

Comments
 (0)