2024-05-25 12:06:50 +00:00
|
|
|
From d4d5d35072b6d28c5f98b77a0d578e01bd25ef7e Mon Sep 17 00:00:00 2001
|
2023-07-08 15:30:05 +00:00
|
|
|
From: Hood Chatham <roberthoodchatham@gmail.com>
|
|
|
|
Date: Thu, 22 Jun 2023 18:53:22 -0700
|
2024-12-20 05:16:17 +00:00
|
|
|
Subject: [PATCH 3/7] Changes for JSPI
|
2023-07-08 15:30:05 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
src/library.js | 2 +-
|
|
|
|
src/library_dylink.js | 3 ++-
|
2024-05-07 07:59:57 +00:00
|
|
|
src/parseTools.mjs | 2 +-
|
2023-07-08 15:30:05 +00:00
|
|
|
src/preamble.js | 7 +++++++
|
|
|
|
4 files changed, 11 insertions(+), 3 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/src/library.js b/src/library.js
|
2024-05-25 12:06:50 +00:00
|
|
|
index 44531ee1d..f02e85ea2 100644
|
2023-07-08 15:30:05 +00:00
|
|
|
--- a/src/library.js
|
|
|
|
+++ b/src/library.js
|
2024-05-25 12:06:50 +00:00
|
|
|
@@ -1269,7 +1269,7 @@ addToLibrary({
|
2023-07-08 15:30:05 +00:00
|
|
|
#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
|
2024-05-25 12:06:50 +00:00
|
|
|
index cea3ce05d..c3f3c2bbf 100644
|
2023-07-08 15:30:05 +00:00
|
|
|
--- a/src/library_dylink.js
|
|
|
|
+++ b/src/library_dylink.js
|
2023-09-13 23:38:29 +00:00
|
|
|
@@ -73,6 +73,7 @@ var LibraryDylink = {
|
|
|
|
#if !DISABLE_EXCEPTION_CATCHING || SUPPORT_LONGJMP == 'emscripten'
|
|
|
|
$createInvokeFunction__internal: true,
|
2024-05-07 07:59:57 +00:00
|
|
|
$createInvokeFunction__deps: ['$dynCall', 'setThrew', '$stackSave', '$stackRestore'],
|
2023-09-13 23:38:29 +00:00
|
|
|
+ $createInvokeFunction__postset: "if(!Module.createInvoke) { Module.createInvoke = Module.createInvokeFunction; }",
|
|
|
|
$createInvokeFunction: (sig) => {
|
|
|
|
return function() {
|
|
|
|
var sp = stackSave();
|
2024-05-25 12:06:50 +00:00
|
|
|
@@ -125,7 +126,7 @@ var LibraryDylink = {
|
2023-07-08 15:30:05 +00:00
|
|
|
// 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
|
2023-09-13 23:38:29 +00:00
|
|
|
#if !DISABLE_EXCEPTION_CATCHING
|
2024-05-07 07:59:57 +00:00
|
|
|
diff --git a/src/parseTools.mjs b/src/parseTools.mjs
|
2024-05-25 12:06:50 +00:00
|
|
|
index 7f20321c3..118a32078 100644
|
2024-05-07 07:59:57 +00:00
|
|
|
--- a/src/parseTools.mjs
|
|
|
|
+++ b/src/parseTools.mjs
|
|
|
|
@@ -581,7 +581,7 @@ function makeThrow(excPtr) {
|
2023-07-08 15:30:05 +00:00
|
|
|
}
|
|
|
|
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
|
2024-05-25 12:06:50 +00:00
|
|
|
index 18cf93959..57a7245ab 100644
|
2023-07-08 15:30:05 +00:00
|
|
|
--- a/src/preamble.js
|
|
|
|
+++ b/src/preamble.js
|
2024-05-07 07:59:57 +00:00
|
|
|
@@ -18,6 +18,10 @@
|
|
|
|
#include "runtime_pthread.js"
|
|
|
|
#endif
|
2023-07-08 15:30:05 +00:00
|
|
|
|
|
|
|
+if(!Module.wrapException) {
|
|
|
|
+ Module.wrapException = (e) => e;
|
|
|
|
+}
|
|
|
|
+
|
2024-01-23 12:18:42 +00:00
|
|
|
#if RELOCATABLE
|
|
|
|
{{{ makeModuleReceiveWithVar('dynamicLibraries', undefined, '[]', true) }}}
|
|
|
|
#endif
|
2024-05-25 12:06:50 +00:00
|
|
|
@@ -942,6 +946,9 @@ function getWasmImports() {
|
2023-07-08 15:30:05 +00:00
|
|
|
// Receives the wasm imports, returns the exports.
|
|
|
|
function createWasm() {
|
2024-05-07 07:59:57 +00:00
|
|
|
var info = getWasmImports();
|
2023-07-08 15:30:05 +00:00
|
|
|
+ if (Module.adjustWasmImports) {
|
2024-05-07 07:59:57 +00:00
|
|
|
+ Module.adjustWasmImports(info);
|
2023-07-08 15:30:05 +00:00
|
|
|
+ }
|
2024-05-07 07:59:57 +00:00
|
|
|
// 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
|
2023-07-08 15:30:05 +00:00
|
|
|
--
|
2024-05-07 07:59:57 +00:00
|
|
|
2.34.1
|
|
|
|
|