Commit 2c46f0b5 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Support importing constructed {WebAssmebly.Function}.

This adds support for properly importing {WebAssembly.Function} objects
that were constructed in JavaScript and just wrap a JavaScript callable.

R=ahaas@chromium.org
TEST=mjsunit/wasm/type-reflection
BUG=v8:7742

Change-Id: I00e01db0d85b83d405eb28517d00fba62c253985
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1690949
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62641}
parent e935874b
......@@ -6015,8 +6015,9 @@ std::pair<WasmImportCallKind, Handle<JSReceiver>> ResolveWasmImportCall(
if (!js_function->MatchesSignature(expected_sig)) {
return std::make_pair(WasmImportCallKind::kLinkError, callable);
}
// TODO(7742): Implement proper handling of this case.
UNIMPLEMENTED();
Isolate* isolate = callable->GetIsolate();
// Resolve the short-cut to the underlying callable and continue.
callable = handle(js_function->GetCallable(), isolate);
}
if (WasmCapiFunction::IsWasmCapiFunction(*callable)) {
auto capi_function = Handle<WasmCapiFunction>::cast(callable);
......
......@@ -319,8 +319,7 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
/wasm function signature contains illegal type/);
})();
// TODO(7742): Enable once imported constructed functions are callable.
/*(function TestFunctionModuleImportMatchingSig() {
(function TestFunctionModuleImportMatchingSig() {
let builder = new WasmModuleBuilder();
let fun = new WebAssembly.Function({parameters:[], results:["i32"]}, _ => 7);
let fun_index = builder.addImport("m", "fun", kSig_i_v)
......@@ -331,7 +330,7 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.exportFunc();
let instance = builder.instantiate({ m: { fun: fun }});
assertEquals(7, instance.exports.main());
})();*/
})();
(function TestFunctionModuleImportMismatchingSig() {
let builder = new WasmModuleBuilder();
......
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