Skip to content

Commit

Permalink
Describe a primitive reactor ABI. (#256)
Browse files Browse the repository at this point in the history
* Describe a primitive reactor ABI.

This adds a new reactor ABI, indicated by exporting the function
"_activate". For now, a reactor is just a module which doesn't have
a lifetime scoped by a "_start" or "main" function, though it may
evolve to include other semantics in the future.

* Mention that command and reactor kinds are mutually exclusive.

* Rename `_activate` to `_initialize`.
  • Loading branch information
sunfishcode authored Apr 20, 2020
1 parent ef3c605 commit d8b286c
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions design/application-abi.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,29 @@ include.
Current Unstable ABI
--------------------

The current WASI unstable ABI specifies only two exports from a WASI
application:
There are two kinds of modules:

- `_start` - the program entry point
- `memory` - linear memory used by the program
- A *command* exports a function named `_start`, with no arguments and no return
values. Environments shall call this function once, after instantiating the
module and all of its dependencies. After this function exits, the instance
is considered terminated and no further use of any of its exports should be
permitted.

The `_start` export must be WebAssembly function and will be used as the program
entry point. This is the default name used by `lld` when linking WebAssembly
modules. The embedder is expected to call this function once the module is
instantiated.
- A *reactor* exports a function named `_initialize`, with no arguments and no
return values. Environments shall call this function once, after instantiating
the module and all of its dependencies. After this function exits, the instance
remains live, and its exports may be accessed.

Many of the current WASI unstable APIs require sharing of linear memory between
the application and the embedder. In order to use any such APIs the WASI module
is expected to export its linear memory under the name `memory`.
These kinds are mutually exclusive; implementations should report an error if
asked to instantiate a module containing exports which declare it to be of
multiple kinds.

Regardless of the kind, all programs accessing WASI APIs also export a linear
memory with the name `memory`. Pointers in WASI API calls are relative to this
memory's index space.

In the future, as the underlying WebAssembly platform offers more features, we
we hope to eliminate the requirement to export all of linear memory.

Planned Stable ABI
------------------
Expand Down

0 comments on commit d8b286c

Please sign in to comment.