Skip to content

Commit

Permalink
Update JSPI code to handle change in type reflection spec
Browse files Browse the repository at this point in the history
Resolves pyodide#4378
  • Loading branch information
hoodmane committed Jan 16, 2024
1 parent 4f2c037 commit b1ff271
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ index 0000000000..d2d24a6e0a
+ if (n !== undefined) {
+ return n;
+ }
+ n = WebAssembly.Function.type(wasmTable.get(func)).parameters.length;
+ n = wasmFunctionType(wasmTable.get(func)).parameters.length;
+ _PyEM_CountFuncParams.cache.set(func, n);
+ return n;
+}
Expand Down
10 changes: 10 additions & 0 deletions src/core/pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,13 @@ Module.iterObject = function* (object) {
}
}
};

function wasmFunctionType(wasm_func) {
if (!WebAssembly.Function) {
throw new Error("No type reflection");
}
if (WebAssembly.Function.type) {
return WebAssembly.Function.type(wasm_func);
}
return wasm_func.type();
}
2 changes: 1 addition & 1 deletion src/core/stack_switching/suspenders.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function createPromising(wasm_func) {
if (promisingFunctionMap.has(wasm_func)) {
return promisingFunctionMap.get(wasm_func);
}
const type = WebAssembly.Function.type(wasm_func);
const type = wasmFunctionType(wasm_func);
const module = getPromisingModule(type);
const instance = new WebAssembly.Instance(module, {
e: { i: wasm_func, s: suspenderGlobal },
Expand Down

0 comments on commit b1ff271

Please sign in to comment.