diff options
author | Ćukasz Langa <lukasz@langa.pl> | 2025-02-24 00:26:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-24 07:26:04 +0800 |
commit | 72ea3c030a81262af64ebcae2e83ce2ff529bcef (patch) | |
tree | 49233d4e9e83bb213099ce429fc93e1fb983dc4c /Python | |
parent | 81a9b53fee79c4581bc1e2acae1c98ee0b692c7d (diff) | |
download | cpython-72ea3c030a81262af64ebcae2e83ce2ff529bcef.tar.gz cpython-72ea3c030a81262af64ebcae2e83ce2ff529bcef.zip |
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 <roberthoodchatham@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/emscripten_trampoline.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Python/emscripten_trampoline.c b/Python/emscripten_trampoline.c index 0293c7ea0f3..a7bb685bf3d 100644 --- a/Python/emscripten_trampoline.c +++ b/Python/emscripten_trampoline.c @@ -77,7 +77,13 @@ EM_JS(CountArgsFunc, _PyEM_GetCountArgsPtr, (), { // i32.const -1 // ) // ) -addOnPreRun(() => { + +function getPyEMCountArgsPtr() { + let isIOS = globalThis.navigator && /iPad|iPhone|iPod/.test(navigator.platform); + if (isIOS) { + return 0; + } + // Try to initialize countArgsFunc const code = new Uint8Array([ 0x00, 0x61, 0x73, 0x6d, // \0asm magic number @@ -149,15 +155,19 @@ addOnPreRun(() => { 0x41, 0x7f, // i32.const -1 0x0b // end function ]); - let ptr = 0; try { const mod = new WebAssembly.Module(code); const inst = new WebAssembly.Instance(mod, { e: { t: wasmTable } }); - ptr = addFunction(inst.exports.f); + return addFunction(inst.exports.f); } catch (e) { // If something goes wrong, we'll null out _PyEM_CountFuncParams and fall // back to the JS trampoline. + return 0; } +} + +addOnPreRun(() => { + const ptr = getPyEMCountArgsPtr(); Module._PyEM_CountArgsPtr = ptr; const offset = HEAP32[__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET / 4]; HEAP32[(__PyRuntime + offset) / 4] = ptr; |