There was an error while loading. Please reload this page.
1 parent 0da9a0c commit 0c2b94eCopy full SHA for 0c2b94e
1 file changed
Python/emscripten_trampoline.c
@@ -77,11 +77,13 @@ EM_JS(CountArgsFunc, _PyEM_GetCountArgsPtr, (), {
77
// i32.const -1
78
// )
79
80
-addOnPreRun(() => {
+
81
+function getPyEMCountArgsPtr() {
82
let isIOS = /iPad|iPhone|iPod/.test(navigator.platform);
83
if (isIOS) {
- return;
84
+ return 0;
85
}
86
87
// Try to initialize countArgsFunc
88
const code = new Uint8Array([
89
0x00, 0x61, 0x73, 0x6d, // \0asm magic number
@@ -153,15 +155,19 @@ addOnPreRun(() => {
153
155
0x41, 0x7f, // i32.const -1
154
156
0x0b // end function
157
]);
- let ptr = 0;
158
try {
159
const mod = new WebAssembly.Module(code);
160
const inst = new WebAssembly.Instance(mod, { e: { t: wasmTable } });
- ptr = addFunction(inst.exports.f);
161
+ return addFunction(inst.exports.f);
162
} catch (e) {
163
// If something goes wrong, we'll null out _PyEM_CountFuncParams and fall
164
// back to the JS trampoline.
165
166
167
+}
168
169
+addOnPreRun(() => {
170
+ const ptr = getPyEMCountArgsPtr();
171
Module._PyEM_CountArgsPtr = ptr;
172
const offset = HEAP32[__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET / 4];
173
HEAP32[(__PyRuntime + offset) / 4] = ptr;
0 commit comments