Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix emulated function pointer cast exporting #6939

Merged
merged 3 commits into from
Aug 3, 2018
Merged

Fix emulated function pointer cast exporting #6939

merged 3 commits into from
Aug 3, 2018

Conversation

kripken
Copy link
Member

@kripken kripken commented Aug 2, 2018

Emulated function pointers is the mode where we do calls from JS using the wasm Table, which is how we currently do dynamic linking in both asm.js and wasm (in asm.js, this mode creates something like a wasm Table on the outside of the asm.js, and calls that). Emulated function pointer casts is where we assume a function pointer type may be cast in a weird way, so we make sure indirect calls work even with the wrong argument number or type, sort of like native platforms do. The "trick" we use for that is to use i64s for all values, and cast as necessary. For this mode, we export every single function's function table index, as we need those from JS - we can't call them as wasm exports, as they return i64. So we call dynCall of the right signature, and then inside wasm we cast the i64 to what we want, and return that to JS.

The bug here is that we mixed those two modes up - we exported all the function pointers for the former mode, when we just need it in the latter. So this just changes up a few ifdefs to the proper mode. Note the effect on the metadce test - a dynamic library now has far fewer exports and is smaller.

kripken added 3 commits August 1, 2018 10:30
…ts (since we use an i64 return value, and cannot call through an export to JS) - emulated function pointers without casts does not need all the fp$ exports
@kripken kripken merged commit f15e66a into incoming Aug 3, 2018
@kripken kripken deleted the casts branch August 3, 2018 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants