forked from pyodide/pyodide
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use hoodmane/hiwire library instead of our own implementation (pyodid…
…e#4128) This change switches to my external implementation of hiwire. This is the minimal change set to do this, it uses some hacks to avoid changing any files outside of `hiwire.{c,h,js}`. In followups, I will gradually switch to using the new APIs rather than compatibility shims.
- Loading branch information
Showing
8 changed files
with
347 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
emsdk/patches/0001-Support-externref-in-EM_JS-functions-with-dynamic-li.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
From 04dd736fe3ea0d469b84800585eaa4ca6648b9f9 Mon Sep 17 00:00:00 2001 | ||
From: Hood Chatham <[email protected]> | ||
Date: Thu, 31 Aug 2023 13:53:39 +0200 | ||
Subject: [PATCH] Support externref in EM_JS functions with dynamic linking | ||
|
||
--- | ||
emscripten.py | 1 + | ||
src/library_addfunction.js | 1 + | ||
test/core/test_externref2.c | 22 ++++++++++++++++++++++ | ||
test/core/test_externref2.out | 2 ++ | ||
test/test_core.py | 14 ++++++++++++++ | ||
5 files changed, 40 insertions(+) | ||
create mode 100644 test/core/test_externref2.c | ||
create mode 100644 test/core/test_externref2.out | ||
|
||
diff --git a/emscripten.py b/emscripten.py | ||
index f011a58b8..74ea6f525 100644 | ||
--- a/emscripten.py | ||
+++ b/emscripten.py | ||
@@ -601,6 +601,7 @@ def type_to_sig(type): | ||
webassembly.Type.I64: 'j', | ||
webassembly.Type.F32: 'f', | ||
webassembly.Type.F64: 'd', | ||
+ webassembly.Type.EXTERNREF: 'e', | ||
webassembly.Type.VOID: 'v' | ||
}[type] | ||
|
||
diff --git a/src/library_addfunction.js b/src/library_addfunction.js | ||
index 39e00b772..1537dca66 100644 | ||
--- a/src/library_addfunction.js | ||
+++ b/src/library_addfunction.js | ||
@@ -29,6 +29,7 @@ addToLibrary({ | ||
'j': 'i64', | ||
'f': 'f32', | ||
'd': 'f64', | ||
+ 'e': 'externref', | ||
#if MEMORY64 | ||
'p': 'i64', | ||
#else | ||
diff --git a/test/core/test_externref2.c b/test/core/test_externref2.c | ||
new file mode 100644 | ||
index 000000000..47451c260 | ||
--- /dev/null | ||
+++ b/test/core/test_externref2.c | ||
@@ -0,0 +1,22 @@ | ||
+#include "emscripten.h" | ||
+ | ||
+ | ||
+EM_JS(__externref_t, get_ref, (), { | ||
+ return {a: 7, b: 9}; | ||
+}); | ||
+ | ||
+EM_JS(void, modify_ref, (__externref_t arg), { | ||
+ arg.a += 3; | ||
+ arg.b -= 3; | ||
+}); | ||
+ | ||
+EM_JS(void, log_ref, (__externref_t arg), { | ||
+ console.log(arg); | ||
+}); | ||
+ | ||
+int main() { | ||
+ __externref_t a = get_ref(); | ||
+ log_ref(a); | ||
+ modify_ref(a); | ||
+ log_ref(a); | ||
+} | ||
diff --git a/test/core/test_externref2.out b/test/core/test_externref2.out | ||
new file mode 100644 | ||
index 000000000..eaceb4e73 | ||
--- /dev/null | ||
+++ b/test/core/test_externref2.out | ||
@@ -0,0 +1,2 @@ | ||
+{ a: 7, b: 9 } | ||
+{ a: 10, b: 6 } | ||
diff --git a/test/test_core.py b/test/test_core.py | ||
index 2f776068d..8b1933bf9 100644 | ||
--- a/test/test_core.py | ||
+++ b/test/test_core.py | ||
@@ -9699,6 +9699,20 @@ NODEFS is no longer included by default; build with -lnodefs.js | ||
self.emcc_args += ['-mreference-types'] | ||
self.do_core_test('test_externref.c', libraries=['asm.o']) | ||
|
||
+ @parameterized({ | ||
+ '': [False], | ||
+ 'dynlink': [True] | ||
+ }) | ||
+ @requires_node | ||
+ @no_wasm2js('wasm2js does not support reference types') | ||
+ def test_externref2(self, dynlink): | ||
+ self.emcc_args += ['-mreference-types'] | ||
+ self.node_args.append("--experimental-wasm-reftypes") | ||
+ if dynlink: | ||
+ self.set_setting('MAIN_MODULE', 2) | ||
+ self.do_core_test('test_externref2.c') | ||
+ | ||
+ | ||
def test_syscall_intercept(self): | ||
self.do_core_test('test_syscall_intercept.c') | ||
|
||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.