[wasm] Fix wasm to js wrapper on ia32 for i64 return
When generating the code for an illegal (non-js-compliant) wrapper for a js function, we were generating a zero constant of the return type. This failed on ia32 if the return type is i64. The correct thing to do is to return two i32 zero constants. R=titzer@chromium.org BUG=v8:6104, v8:6096 Change-Id: Idc0dd8d3eef901c22d5278d97f1879b000a18588 Reviewed-on: https://chromium-review.googlesource.com/455857 Reviewed-by: Ben Titzer <titzer@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#43835}
This commit is contained in:
parent
9d0f248201
commit
69da6fcd2a
@ -2823,9 +2823,14 @@ void WasmGraphBuilder::BuildWasmToJSWrapper(Handle<JSReceiver> target,
|
||||
BuildCallToRuntimeWithContext(Runtime::kWasmThrowTypeError, jsgraph(),
|
||||
context, nullptr, 0, effect_, *control_);
|
||||
// TODO(wasm): Support multi-return.
|
||||
wasm::ValueType return_type =
|
||||
sig->return_count() == 0 ? wasm::kWasmI32 : sig->GetReturn();
|
||||
Return(ZeroConstant(return_type));
|
||||
if (sig->return_count() == 0) {
|
||||
Return(Int32Constant(0));
|
||||
} else if (Int64Lowering::IsI64AsTwoParameters(jsgraph()->machine(),
|
||||
sig->GetReturn())) {
|
||||
Return(Int32Constant(0), Int32Constant(0));
|
||||
} else {
|
||||
Return(ZeroConstant(sig->GetReturn()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -128,6 +128,19 @@ assertThrows(function() {
|
||||
assertThrows(() => instance.exports.main(), TypeError);
|
||||
})();
|
||||
|
||||
(function ImportI64Return() {
|
||||
// This tests that we generate correct code by using the correct return
|
||||
// register(s). See bug 6104.
|
||||
var builder = new WasmModuleBuilder();
|
||||
builder.addImport('', 'f', makeSig([], [kWasmI64]));
|
||||
builder.addFunction('main', kSig_v_v)
|
||||
.addBody([kExprCallFunction, 0, kExprDrop])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate({'': {f: () => 1}});
|
||||
|
||||
assertThrows(() => instance.exports.main(), TypeError);
|
||||
})();
|
||||
|
||||
(function ImportSymbolToNumberThrows() {
|
||||
var builder = new WasmModuleBuilder();
|
||||
var index = builder.addImport("", "func", kSig_i_v);
|
||||
|
Loading…
Reference in New Issue
Block a user