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

List of functions emscripten imports/their purposes? #12265

Closed
vedantroy opened this issue Sep 18, 2020 · 4 comments
Closed

List of functions emscripten imports/their purposes? #12265

vedantroy opened this issue Sep 18, 2020 · 4 comments
Labels

Comments

@vedantroy
Copy link

vedantroy commented Sep 18, 2020

I'm trying to create an alternate implementation of the emscripten JS runtime. Is there a list of functions that emscripten imports from the parent runtime?

I see some of the imports are WASI-imports, which I can find external documentation for. I'm more curious about things like:

  • When is __indirect_function_table used?
  • When is setTempRet0 used?

Amongst other things. Is there any documentation on Emscripten's ABI?

@tlively
Copy link
Member

tlively commented Sep 18, 2020

In general Emscripten's interface with the wasm module is intentionally undocumented and unstable. We don't recommend assuming anything about it because it can change at any time (although in practice most of it doesn't change that frequently). So the short answer is that no, there is no documentation.

@kripken
Copy link
Member

kripken commented Sep 18, 2020

To add to that, things like __indirect_function_table and __heap_base are LLVM-isms (which might be documented there).

setTempRet0 is used to store 32 bits of data on the side, for implementing 64-bit return values (the high 32 bits are stored on the side). But as @tlively said, this and other special JS calls are internal APIs for emscripten, and can change. The best docs for them are the source code, in src/library*.js.

You may want to use standalone mode which minimizes the amount of things used from JS.

@sbc100
Copy link
Collaborator

sbc100 commented Sep 18, 2020

Yes, standalone mode is probably best way to go if trying to do this.

Others have attempted to do what you are doing although I'm not sure how much success they have had.

There was even an special metadata section called EMIT_EMSCRIPTEN_METADATA which was designed to give non-emscripen runtimes insight into the import/export ABI used by a given module: #7815. However I'm currently trying to remove it now that we have STANDALONE_WASM mode: #12231

@stale
Copy link

stale bot commented Sep 21, 2021

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Sep 21, 2021
@stale stale bot closed this as completed Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants