s390x: [wasm] Use a tuple as the instance for JS imports

Port a2b3480611

Original Commit Message:

    This CL refactors the implementation of WASM->JS import wrappers in order
    to make the wrapper code shareable. Instead of specializing to the import
    index, we use a tuple as the object ref in the both the import and indirect
    tables. The tuple allows the wrapper code to load both the calling
    instance and the target callable, rather than relying on code specialization.

    This requires some tricky codegen machinery, because WASM call descriptors
    expect an instance argument in a given register, yet the wrappers receive
    a tuple, the code generator must generate a prologue that loads the
    instance (and the callable), since it is not possible to express this at
    the graph level.

R=titzer@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: I34302b8ff737296fc98c032f1e9848b4bb9fae13
Reviewed-on: https://chromium-review.googlesource.com/c/1273866
Reviewed-by: Ben Titzer <titzer@chromium.org>
Reviewed-by: Joran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#56541}
This commit is contained in:
Junliang Yan 2018-10-10 13:08:37 -04:00 committed by Commit Bot
parent dfa56840fe
commit 8343e75b35

View File

@ -3582,7 +3582,15 @@ void CodeGenerator::AssembleConstructFrame() {
if (call_descriptor->IsWasmFunctionCall()) {
__ Push(kWasmInstanceRegister);
} else if (call_descriptor->IsWasmImportWrapper()) {
UNIMPLEMENTED(); // TODO(s390): wasm import wrapper prologue
// WASM import wrappers are passed a tuple in the place of the instance.
// Unpack the tuple into the instance and the target callable.
// This must be done here in the codegen because it cannot be expressed
// properly in the graph.
__ LoadP(kJSFunctionRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue2Offset));
__ LoadP(kWasmInstanceRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset));
__ Push(kWasmInstanceRegister);
}
}
}