Skip to content

Commit 7ab6d85

Browse files
thibaudmichaudV8 LUCI CQ
authored andcommitted
[wasm] Disallow WebAssembly.promising with asmjs
Throw a TypeError to match the behavior of creating a WebAssembly.promising from a JS function. [email protected] Bug: 355015467 Change-Id: Ic565d7cb13c90056e41c2721fd85dffa584b5f15 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5772793 Commit-Queue: Thibaud Michaud <[email protected]> Reviewed-by: Matthias Liedtke <[email protected]> Cr-Commit-Position: refs/heads/main@{#95536}
1 parent 6a6d87b commit 7ab6d85

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/wasm/wasm-js.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,10 @@ void WebAssemblyPromising(const v8::FunctionCallbackInfo<v8::Value>& info) {
22772277
i::DirectHandle<i::WasmExportedFunctionData> data(
22782278
wasm_exported_function->shared()->wasm_exported_function_data(),
22792279
i_isolate);
2280+
if (data->instance_data()->module_object()->is_asm_js()) {
2281+
thrower.TypeError("Argument 0 must be a WebAssembly exported function");
2282+
return;
2283+
}
22802284
i::Handle<i::JSFunction> result =
22812285
NewPromisingWasmExportedFunction(i_isolate, data, thrower);
22822286
info.GetReturnValue().Set(Utils::ToLocal(i::Cast<i::JSObject>(result)));

test/mjsunit/wasm/stack-switching.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
99

1010
(function TestInvalidWrappers() {
11+
print(arguments.callee.name);
1112
assertThrows(() => WebAssembly.promising({}), TypeError,
1213
/Argument 0 must be a function/);
1314
assertThrows(() => WebAssembly.promising(() => {}), TypeError,
@@ -16,6 +17,15 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
1617
/WebAssembly.Suspending must be invoked with 'new'/);
1718
assertThrows(() => new WebAssembly.Suspending({}), TypeError,
1819
/Argument 0 must be a function/);
20+
function asmModule() {
21+
"use asm";
22+
function x(v) {
23+
v = v | 0;
24+
}
25+
return x;
26+
}
27+
assertThrows(() => WebAssembly.promising(asmModule()), TypeError,
28+
/Argument 0 must be a WebAssembly exported function/);
1929
})();
2030

2131
(function TestStackSwitchNoSuspend() {

0 commit comments

Comments
 (0)