Skip to content

Commit 9a1cb4d

Browse files
authored
Elaborate on the definitions of commands and reactors. (#282)
* Elaborate on the definitions of commands and reactors. This pulls out the parts of #281 which document existing practice. * Simplify the text about __heap_base and __data_end. We no longer need to say "applications may export these", but it's still useful to say that environments shouldn't access them.
1 parent e910968 commit 9a1cb4d

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

design/application-abi.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,40 @@ Current Unstable ABI
1515
There are two kinds of modules:
1616

1717
- A *command* exports a function named `_start`, with no arguments and no return
18-
values. Environments shall call this function once, after instantiating the
19-
module and all of its dependencies. After this function exits, the instance
20-
is considered terminated and no further use of any of its exports should be
21-
permitted.
18+
values.
2219

23-
- A *reactor* exports a function named `_initialize`, with no arguments and no
24-
return values. Environments shall call this function once, after instantiating
25-
the module and all of its dependencies. After this function exits, the instance
26-
remains live, and its exports may be accessed.
20+
Command instances may assume that they will be called from the environment
21+
at most once. Command instances may assume that none of their exports are
22+
accessed outside the duraction of that call.
23+
24+
- All other modules are *reactors*. A reactor may export a function named
25+
`_initialize`, with no arguments and no return values.
26+
27+
If an `_initialize` export is present, reactor instances may assume that it
28+
will be called by the environment at most once, and that none of their
29+
other exports are accessed before that call.
30+
31+
After being instantiated, and after any `_initialize` function is called,
32+
a reactor instance remains live, and its exports may be accessed.
2733

2834
These kinds are mutually exclusive; implementations should report an error if
2935
asked to instantiate a module containing exports which declare it to be of
3036
multiple kinds.
3137

32-
Regardless of the kind, all programs accessing WASI APIs also export a linear
33-
memory with the name `memory`. Pointers in WASI API calls are relative to this
34-
memory's index space.
38+
Regardless of the kind, all modules accessing WASI APIs also export a linear
39+
memory with the name `memory`. Data pointers in WASI API calls are relative to
40+
this memory's index space.
41+
42+
Regardless of the kind, all modules accessing WASI APIs also export a table
43+
with the name `__indirect_function_table`. Function pointers in WASI API calls
44+
are relative to this table's index space.
45+
46+
Environments shall not access exports named `__heap_base` or `__data_end`.
47+
Toolchains are encouraged to avoid providing these exports.
3548

3649
In the future, as the underlying WebAssembly platform offers more features, we
37-
we hope to eliminate the requirement to export all of linear memory.
50+
we hope to eliminate the requirement to export all of linear memory or all of
51+
the indirect function table.
3852

3953
Planned Stable ABI
4054
------------------

0 commit comments

Comments
 (0)