Skip to content

Commit 72ea3c0

Browse files
ambvhoodmane
andauthored
gh-128627: Skip wasm-gc on iOS Safari where it's broken (#130418)
As of iOS 18.3.1, enabling wasm-gc breaks the interpreter. This disables the wasm-gc trampoline on iOS. Co-authored-by: Hood Chatham <[email protected]>
1 parent 81a9b53 commit 72ea3c0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Python/emscripten_trampoline.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ EM_JS(CountArgsFunc, _PyEM_GetCountArgsPtr, (), {
7777
// i32.const -1
7878
// )
7979
// )
80-
addOnPreRun(() => {
80+
81+
function getPyEMCountArgsPtr() {
82+
let isIOS = globalThis.navigator && /iPad|iPhone|iPod/.test(navigator.platform);
83+
if (isIOS) {
84+
return 0;
85+
}
86+
8187
// Try to initialize countArgsFunc
8288
const code = new Uint8Array([
8389
0x00, 0x61, 0x73, 0x6d, // \0asm magic number
@@ -149,15 +155,19 @@ addOnPreRun(() => {
149155
0x41, 0x7f, // i32.const -1
150156
0x0b // end function
151157
]);
152-
let ptr = 0;
153158
try {
154159
const mod = new WebAssembly.Module(code);
155160
const inst = new WebAssembly.Instance(mod, { e: { t: wasmTable } });
156-
ptr = addFunction(inst.exports.f);
161+
return addFunction(inst.exports.f);
157162
} catch (e) {
158163
// If something goes wrong, we'll null out _PyEM_CountFuncParams and fall
159164
// back to the JS trampoline.
165+
return 0;
160166
}
167+
}
168+
169+
addOnPreRun(() => {
170+
const ptr = getPyEMCountArgsPtr();
161171
Module._PyEM_CountArgsPtr = ptr;
162172
const offset = HEAP32[__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET / 4];
163173
HEAP32[(__PyRuntime + offset) / 4] = ptr;

0 commit comments

Comments
 (0)