[wasm] Allow any return count for JSPI export

R=clemensb@chromium.org

Bug: v8:12191, v8:13231
Change-Id: I0104f54ce5cdc022f22800d4aeec68aac481219d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3856573
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82769}
This commit is contained in:
Thibaud Michaud 2022-08-25 16:00:51 +02:00 committed by V8 LUCI CQ
parent 51acc286e0
commit a72a4db7cd
2 changed files with 16 additions and 4 deletions

View File

@ -1920,14 +1920,14 @@ bool IsSuspendingSignature(const i::wasm::FunctionSig* inner_sig,
return true;
}
// Given {inner_sig}: externref ti* -> to
// {outer_sig} must be: ti* -> externref
// Given {inner_sig}: externref [ti*] -> [to*]
// {outer_sig} must be: [ti*] -> [externref]
bool IsPromisingSignature(const i::wasm::FunctionSig* inner_sig,
const i::wasm::FunctionSig* outer_sig) {
if (inner_sig->parameter_count() != outer_sig->parameter_count() + 1) {
return false;
}
if (inner_sig->return_count() != 1 || outer_sig->return_count() != 1) {
if (outer_sig->return_count() != 1) {
return false;
}
if (inner_sig->GetParam(0) != i::wasm::kWasmExternRef) return false;

View File

@ -19,7 +19,6 @@ function ToPromising(wasm_export) {
let sig = WebAssembly.Function.type(wasm_export);
assertTrue(sig.parameters.length > 0);
assertEquals('externref', sig.parameters[0]);
assertEquals(1, sig.results.length);
let wrapper_sig = {
parameters: sig.parameters.slice(1),
results: ['externref']
@ -466,3 +465,16 @@ function TestNestedSuspenders(suspend) {
print(arguments.callee.name);
TestNestedSuspenders(false);
})();
(function Regress13231() {
print(arguments.callee.name);
// Check that a promising function with no return is allowed.
let builder = new WasmModuleBuilder();
let sig_v_r = makeSig([kWasmExternRef], []);
builder.addFunction("export", sig_v_r).addBody([]).exportFunc();
let instance = builder.instantiate();
let export_wrapper = ToPromising(instance.exports.export);
let export_sig = WebAssembly.Function.type(export_wrapper);
assertEquals([], export_sig.parameters);
assertEquals(['externref'], export_sig.results);
})();