OSR entry into wasm misses some contexts
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Sep 2019 20:32:56 +0000 (20:32 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Sep 2019 20:32:56 +0000 (20:32 +0000)
commitaf6b216a8a846f5be267c41dba0b258813cc5e0e
tree290022f4bfd38220249ffbb3fa80f10378f59c3d
parent6aafb395f7461ff10e8cc62d2b5d705ab07511dd
OSR entry into wasm misses some contexts
https://bugs.webkit.org/show_bug.cgi?id=201569

Reviewed by Yusuke Suzuki.

JSTests:

Add a new harness and wast and the generated wasm file for
testing. The idea long term is to make it easy to test by creating
a C file and converting it to a wast then modify that to produce a
test.

* wasm.yaml:
* wasm/wast-tests/harness.js: Added.
(async.runWasmFile):
* wasm/wast-tests/osr-entry-inner-loop-branch-above-no-consts.wasm: Added.
* wasm/wast-tests/osr-entry-inner-loop-branch-above-no-consts.wast: Added.
* wasm/wast-tests/osr-entry-inner-loop-branch-above.wasm: Added.
* wasm/wast-tests/osr-entry-inner-loop-branch-above.wast: Added.
* wasm/wast-tests/osr-entry-inner-loop.wasm: Added.
* wasm/wast-tests/osr-entry-inner-loop.wast: Added.
* wasm/wast-tests/osr-entry-multiple-enclosed-contexts.wasm: Added.
* wasm/wast-tests/osr-entry-multiple-enclosed-contexts.wast: Added.

Source/JavaScriptCore:

This patch fixes an issue where we could fail to capture some of
our contexts when OSR entering into wasm code. Before we would
only capture the state of the block immediately surrounding the
entrance loop block header. We actually need to capture all
enclosed stacks.

Additionally, we don't need to use variables for all the captured
values. We can use a Phi and insert an upsilon just below the
captured value.

* interpreter/CallFrame.h:
* jsc.cpp:
(GlobalObject::finishCreation):
(functionCallerIsOMGCompiled):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::AirIRGenerator):
(JSC::Wasm::AirIRGenerator::emitEntryTierUpCheck):
(JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck):
(JSC::Wasm::AirIRGenerator::addLoop):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::createStack):
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::B3IRGenerator::addConstant):
(JSC::Wasm::B3IRGenerator::emitEntryTierUpCheck):
(JSC::Wasm::B3IRGenerator::emitLoopTierUpCheck):
(JSC::Wasm::B3IRGenerator::addLoop):
(JSC::Wasm::B3IRGenerator::addEndToUnreachable):
(JSC::Wasm::dumpExpressionStack):
(JSC::Wasm::B3IRGenerator::dump):
(JSC::Wasm::B3IRGenerator::Stack::Stack): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::append): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::takeLast): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::last): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::size const): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::isEmpty const): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::convertToExpressionList): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::at const): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::variableAt const): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::shrink): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::swap): Deleted.
(JSC::Wasm::B3IRGenerator::Stack::dump const): Deleted.
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::controlStack):

Tools:

Add new test harness mode for tests created from wast files.

* Scripts/run-jsc-stress-tests:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
JSTests/ChangeLog
JSTests/wasm.yaml
JSTests/wasm/wast-tests/harness.js [new file with mode: 0644]
JSTests/wasm/wast-tests/osr-entry-inner-loop-branch-above-no-consts.wasm [new file with mode: 0644]
JSTests/wasm/wast-tests/osr-entry-inner-loop-branch-above-no-consts.wast [new file with mode: 0644]
JSTests/wasm/wast-tests/osr-entry-inner-loop-branch-above.wasm [new file with mode: 0644]
JSTests/wasm/wast-tests/osr-entry-inner-loop-branch-above.wast [new file with mode: 0644]
JSTests/wasm/wast-tests/osr-entry-inner-loop.wasm [new file with mode: 0644]
JSTests/wasm/wast-tests/osr-entry-inner-loop.wast [new file with mode: 0644]
JSTests/wasm/wast-tests/osr-entry-multiple-enclosed-contexts.wasm [new file with mode: 0644]
JSTests/wasm/wast-tests/osr-entry-multiple-enclosed-contexts.wast [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/interpreter/CallFrame.h
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp
Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
Source/JavaScriptCore/wasm/WasmFunctionParser.h
Source/JavaScriptCore/wasm/WasmOpcodeOrigin.cpp
Tools/ChangeLog
Tools/Scripts/run-jsc-stress-tests