Skip to content

Commit fe9d4d7

Browse files
committed
After emscripten-core#10741, we are still getting non-unique function pointer indexes in fastcomp because we are doing a matching the on the stubs instead of the wasm function wrapper.
In this change, we get the actual function wrapper and pass it into addFunction() so that addFunction can use this to compare with the function wrapper gotten from the wasm table.
1 parent e6919c8 commit fe9d4d7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

emscripten.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,14 +1559,19 @@ def check(extern):
15591559
fullname = "fp$" + extern
15601560
key = '%sModule["%s"]' % (side, fullname)
15611561
asm_setup += '''\
1562-
var %s = function() {
1563-
if (!%s) { %s
1564-
var fid = addFunction(%sModule["%s"] || %s, "%s");
1565-
%s = fid;
1562+
var %(fullname)s = function() {
1563+
if (!%(key)s) { %(assetMsg)s
1564+
// Use the original wasm function itself, for the table, from the main module.
1565+
var func = Module['asm']['%(barename)s'];
1566+
if (!func) {
1567+
func = %(side)sModule["%(barename)s"] || %(barename)s;
1568+
}
1569+
var fid = addFunction(func, "%(sig)s");
1570+
%(key)s = fid;
15661571
}
1567-
return %s;
1572+
return %(key)s;
15681573
}
1569-
''' % (fullname, key, check(barename), side, barename, barename, sig, key, key)
1574+
''' % {'fullname': fullname, 'key': key, 'assetMsg': check(barename), 'side': side, 'barename': barename, 'sig': sig}
15701575

15711576
asm_setup += create_invoke_wrappers(invoke_function_names)
15721577
asm_setup += setup_function_pointers(function_table_sigs)

0 commit comments

Comments
 (0)