From 3d7c3b81dabe4ee965186a0631131123f09b9bfb Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sun, 4 Sep 2022 09:46:57 -0700 Subject: [PATCH 1/4] Fix generateDyncall when there is more than one bigint argument --- src/library_makeDynCall.js | 2 +- test/test_other.py | 11 ++++++++--- test/test_runtime_dyncall_wrapper.c | 9 +++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/library_makeDynCall.js b/src/library_makeDynCall.js index ad6750ebb2bd8..b8413507aeb9d 100644 --- a/src/library_makeDynCall.js +++ b/src/library_makeDynCall.js @@ -19,7 +19,7 @@ mergeInto(LibraryManager.library, { "i", // The first argument is the function pointer to call // in the rest of the argument list, one 64 bit integer is legalized into // two 32 bit integers. - sig.slice(1).replace("j", "ii"), + sig.slice(1).split("").map(x => x === "j" ? "ii" : x).join("") ].join(""); var typeSectionBody = [ diff --git a/test/test_other.py b/test/test_other.py index d75ef4c3806e2..88c776c8ceae5 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12454,9 +12454,14 @@ def test_warn_once(self): self.do_runf('main.c', 'warning: foo\ndone\n') def test_dyncallwrapper(self): - self.set_setting('MAIN_MODULE', 1) - expected = "2 7\ni: 2 j: 8589934599 f: 3.120000 d: 77.120000" - self.do_runf(test_file('test_runtime_dyncall_wrapper.c'), expected) + self.set_setting("MAIN_MODULE", 1) + expected = """\ +2 7 +i: 2 j: 8589934599 f: 3.120000 d: 77.120000 +j1: 8589934599, j2: 30064771074, j3: 12884901891 +""" + self.do_runf(test_file("test_runtime_dyncall_wrapper.c"), expected) + def test_compile_with_cache_lock(self): # Verify that, after warming the cache, running emcc does not require the cache lock. diff --git a/test/test_runtime_dyncall_wrapper.c b/test/test_runtime_dyncall_wrapper.c index d54a19dd8821a..a6cfbe8869f41 100644 --- a/test/test_runtime_dyncall_wrapper.c +++ b/test/test_runtime_dyncall_wrapper.c @@ -10,6 +10,10 @@ void f2(int i, uint64_t j, float f, double d){ printf("i: %d j: %lld f: %f d: %lf\n", i, j, f, d); } +void f3(uint64_t j1, uint64_t j2, uint64_t j3){ + printf("j1: %lld, j2: %lld, j3: %lld\n", j1, j2, j3); +} + int main(){ EM_ASM({ @@ -21,4 +25,9 @@ int main(){ var w = createDyncallWrapper("vijfd"); w($0, 2, 7, 2, 3.12, 77.12); }, f2); + + EM_ASM({ + var w = createDyncallWrapper("vjjj"); + w($0, 7, 2, 2, 7, 3, 3); + }, f3); } From e53f007d774403ce7479560e98dc3d28a9dd7398 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 6 Sep 2022 18:04:00 -0700 Subject: [PATCH 2/4] Update src/library_makeDynCall.js Co-authored-by: Alon Zakai --- src/library_makeDynCall.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library_makeDynCall.js b/src/library_makeDynCall.js index b8413507aeb9d..da5b5e060a661 100644 --- a/src/library_makeDynCall.js +++ b/src/library_makeDynCall.js @@ -19,7 +19,7 @@ mergeInto(LibraryManager.library, { "i", // The first argument is the function pointer to call // in the rest of the argument list, one 64 bit integer is legalized into // two 32 bit integers. - sig.slice(1).split("").map(x => x === "j" ? "ii" : x).join("") + sig.slice(1).replace(/j/g, "ii"); ].join(""); var typeSectionBody = [ From 03b086aa66d4c313117f4418c0a40e94bd967fd8 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 20 Sep 2022 09:16:27 -0700 Subject: [PATCH 3/4] Update src/library_makeDynCall.js --- src/library_makeDynCall.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library_makeDynCall.js b/src/library_makeDynCall.js index da5b5e060a661..9e193013d0884 100644 --- a/src/library_makeDynCall.js +++ b/src/library_makeDynCall.js @@ -19,7 +19,7 @@ mergeInto(LibraryManager.library, { "i", // The first argument is the function pointer to call // in the rest of the argument list, one 64 bit integer is legalized into // two 32 bit integers. - sig.slice(1).replace(/j/g, "ii"); + sig.slice(1).replace(/j/g, "ii") ].join(""); var typeSectionBody = [ From 364eff64c9fc6087cb2c3fa23268e905c8120c5d Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 17 Oct 2022 10:16:42 -0700 Subject: [PATCH 4/4] Fix flake8 error --- test/test_other.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_other.py b/test/test_other.py index 0a6eae4c49d86..edb571a98ab03 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12527,7 +12527,6 @@ def test_dyncallwrapper(self): """ self.do_runf(test_file("test_runtime_dyncall_wrapper.c"), expected) - def test_compile_with_cache_lock(self): # Verify that, after warming the cache, running emcc does not require the cache lock. # Previously we would acquire the lock during sanity checking (even when the check