Skip to content

function pointers in wasm64 #136

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

Closed
sunfishcode opened this issue Feb 1, 2020 · 1 comment
Closed

function pointers in wasm64 #136

sunfishcode opened this issue Feb 1, 2020 · 1 comment

Comments

@sunfishcode
Copy link
Member

With wasm64 discussions happening, one question for the wasm64 C ABI is how to represent function pointers.

Some options:

  • Function pointers are i64, and require a function table with i64 indices. However, it's unclear if anyone would ever need that many functions though, and this puts a burden on engines to support 64-bit table indices which might not otherwise be needed in many places.
  • Function pointers are i64, but the function table still uses i32 indices, and we convert i64 to i32 before indirect calls.
  • Function pointers are i64, and the static linker picks whether to use 32-bit or 64-bit tables, and rewrites the code as needed to make this work. However, it seems like this would be awkward for dynamic linking.
  • Function pointers are i32 (while data pointers remain i64). This is ok by the C standard and compatible with POSIX's dlsym, but could break other assumptions. It would save some memory when function pointers are stored in structs or arrays. This would probably require more work in LLVM and Clang to support.
@sunfishcode
Copy link
Member Author

Wasm has since added tables with 64-bit indices.

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

No branches or pull requests

1 participant