Skip to content

Commit 0c564ef

Browse files
authored
Fix generateDyncall when there is more than one 64 bit argument (#17798)
replace("j", "ii") only replaces the first "j", but we need to replace them all.
1 parent c6017aa commit 0c564ef

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/library_makeDynCall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mergeInto(LibraryManager.library, {
1919
"i", // The first argument is the function pointer to call
2020
// in the rest of the argument list, one 64 bit integer is legalized into
2121
// two 32 bit integers.
22-
sig.slice(1).replace("j", "ii"),
22+
sig.slice(1).replace(/j/g, "ii")
2323
].join("");
2424

2525
var typeSectionBody = [

test/test_other.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12546,9 +12546,13 @@ def test_warn_once(self):
1254612546
self.do_runf('main.c', 'warning: foo\ndone\n')
1254712547

1254812548
def test_dyncallwrapper(self):
12549-
self.set_setting('MAIN_MODULE', 1)
12550-
expected = "2 7\ni: 2 j: 8589934599 f: 3.120000 d: 77.120000"
12551-
self.do_runf(test_file('test_runtime_dyncall_wrapper.c'), expected)
12549+
self.set_setting("MAIN_MODULE", 1)
12550+
expected = """\
12551+
2 7
12552+
i: 2 j: 8589934599 f: 3.120000 d: 77.120000
12553+
j1: 8589934599, j2: 30064771074, j3: 12884901891
12554+
"""
12555+
self.do_runf(test_file("test_runtime_dyncall_wrapper.c"), expected)
1255212556

1255312557
def test_compile_with_cache_lock(self):
1255412558
# Verify that, after warming the cache, running emcc does not require the cache lock.

test/test_runtime_dyncall_wrapper.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ void f2(int i, uint64_t j, float f, double d){
1010
printf("i: %d j: %lld f: %f d: %lf\n", i, j, f, d);
1111
}
1212

13+
void f3(uint64_t j1, uint64_t j2, uint64_t j3){
14+
printf("j1: %lld, j2: %lld, j3: %lld\n", j1, j2, j3);
15+
}
16+
1317

1418
int main(){
1519
EM_ASM({
@@ -21,4 +25,9 @@ int main(){
2125
var w = createDyncallWrapper("vijfd");
2226
w($0, 2, 7, 2, 3.12, 77.12);
2327
}, f2);
28+
29+
EM_ASM({
30+
var w = createDyncallWrapper("vjjj");
31+
w($0, 7, 2, 2, 7, 3, 3);
32+
}, f3);
2433
}

0 commit comments

Comments
 (0)