Commit 8343e75b authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

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

Port a2b34806

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/1273866Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#56541}
parent dfa56840
...@@ -3582,7 +3582,15 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3582,7 +3582,15 @@ void CodeGenerator::AssembleConstructFrame() {
if (call_descriptor->IsWasmFunctionCall()) { if (call_descriptor->IsWasmFunctionCall()) {
__ Push(kWasmInstanceRegister); __ Push(kWasmInstanceRegister);
} else if (call_descriptor->IsWasmImportWrapper()) { } 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);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment