mirror of https://github.com/pyodide/pyodide.git
88 lines
2.8 KiB
Diff
88 lines
2.8 KiB
Diff
From d0ccdbba02c05ff1952059361bd9fb69ebf17f8d Mon Sep 17 00:00:00 2001
|
|
From: Hood Chatham <roberthoodchatham@gmail.com>
|
|
Date: Thu, 22 Jun 2023 18:53:22 -0700
|
|
Subject: [PATCH 3/5] Changes for JSPI
|
|
|
|
---
|
|
src/library.js | 2 +-
|
|
src/library_dylink.js | 3 ++-
|
|
src/parseTools.mjs | 2 +-
|
|
src/preamble.js | 7 +++++++
|
|
4 files changed, 11 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/library.js b/src/library.js
|
|
index 289255c12..e5d87d492 100644
|
|
--- a/src/library.js
|
|
+++ b/src/library.js
|
|
@@ -1268,7 +1268,7 @@ addToLibrary({
|
|
#if EXCEPTION_STACK_TRACES
|
|
throw new EmscriptenSjLj;
|
|
#else
|
|
- throw Infinity;
|
|
+ throw Module.wrapException(Infinity);
|
|
#endif
|
|
},
|
|
#elif !SUPPORT_LONGJMP
|
|
diff --git a/src/library_dylink.js b/src/library_dylink.js
|
|
index 216a1362e..e8c812fab 100644
|
|
--- a/src/library_dylink.js
|
|
+++ b/src/library_dylink.js
|
|
@@ -73,6 +73,7 @@ var LibraryDylink = {
|
|
#if !DISABLE_EXCEPTION_CATCHING || SUPPORT_LONGJMP == 'emscripten'
|
|
$createInvokeFunction__internal: true,
|
|
$createInvokeFunction__deps: ['$dynCall', 'setThrew', '$stackSave', '$stackRestore'],
|
|
+ $createInvokeFunction__postset: "if(!Module.createInvoke) { Module.createInvoke = Module.createInvokeFunction; }",
|
|
$createInvokeFunction: (sig) => {
|
|
return function() {
|
|
var sp = stackSave();
|
|
@@ -131,7 +132,7 @@ var LibraryDylink = {
|
|
// Asm.js-style exception handling: invoke wrapper generation
|
|
else if (symName.startsWith('invoke_')) {
|
|
// Create (and cache) new invoke_ functions on demand.
|
|
- sym = wasmImports[symName] = createInvokeFunction(symName.split('_')[1]);
|
|
+ sym = wasmImports[symName] = Module.createInvoke(symName.split('_')[1]);
|
|
}
|
|
#endif
|
|
#if !DISABLE_EXCEPTION_CATCHING
|
|
diff --git a/src/parseTools.mjs b/src/parseTools.mjs
|
|
index a22dd55a3..15dcf5941 100644
|
|
--- a/src/parseTools.mjs
|
|
+++ b/src/parseTools.mjs
|
|
@@ -581,7 +581,7 @@ function makeThrow(excPtr) {
|
|
}
|
|
return `assert(false, '${assertInfo}');`;
|
|
}
|
|
- return `throw ${excPtr};`;
|
|
+ return `throw Module.wrapException(${excPtr});`;
|
|
}
|
|
|
|
function storeException(varName, excPtr) {
|
|
diff --git a/src/preamble.js b/src/preamble.js
|
|
index 3f3b4db45..c0515125e 100644
|
|
--- a/src/preamble.js
|
|
+++ b/src/preamble.js
|
|
@@ -18,6 +18,10 @@
|
|
#include "runtime_pthread.js"
|
|
#endif
|
|
|
|
+if(!Module.wrapException) {
|
|
+ Module.wrapException = (e) => e;
|
|
+}
|
|
+
|
|
#if RELOCATABLE
|
|
{{{ makeModuleReceiveWithVar('dynamicLibraries', undefined, '[]', true) }}}
|
|
#endif
|
|
@@ -944,6 +948,9 @@ function getWasmImports() {
|
|
// Receives the wasm imports, returns the exports.
|
|
function createWasm() {
|
|
var info = getWasmImports();
|
|
+ if (Module.adjustWasmImports) {
|
|
+ Module.adjustWasmImports(info);
|
|
+ }
|
|
// Load the wasm module and create an instance of using native support in the JS engine.
|
|
// handle a generated wasm instance, receiving its exports and
|
|
// performing other necessary setup
|
|
--
|
|
2.34.1
|
|
|