Skip to content

AssemblyScript's exports #1301

@sunfishcode

Description

@sunfishcode

I'm working on documenting the assumptions that runtimes make when running wasm modules, and I'm not very familiar with AssemblyScript and would like to learn more.

Here are the exports in a simple AssemblyScript wasm module being used in non-Web wasm runtimes:

  (export "__setArgumentsLength" (func 45))
  (export "memory" (memory 0))
  (export "__alloc" (func 4))
  (export "__retain" (func 5))
  (export "__release" (func 6))
  (export "__collect" (func 7))
  (export "__reset" (func 8))
  (export "__rtti_base" (global 4))
  (export "_start" (func 47))
  (export "wasiabort" (func 49))

The _start export is recognized as the entrypoint of the program, meaning a call to "_start" starts the program and ends it. "memory" is also currently recognized and used by APIs to allow pointers to memory to be passed around. The rest appear to be specific to AssemblyScript.

Does AssemblyScript assume that something outside of the module will call these other functions?

If so, I'd like to understand how this should work. If the environment recognizes these exports, importing them and calling them from within functions called by _start would imply a cyclic dependency, and while some environments have ways to do that, isn't something wasm supports in general.

If not, would there be any obstacles to removing these exports?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions