Skip to content

Commit 0a5de06

Browse files
committed
Ungate start functions, and restrict args/returns.
Adjust the 🪙 to include start functions in the MVP, and add a restriction that start functions cannot currently have arguments or return values, for now. And add some words describing the order that start functions are called in.
1 parent 58d94a7 commit 0a5de06

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

design/mvp/Binary.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Notes:
283283
[`CanonicalABI.md`](CanonicalABI.md#canonical-definitions).
284284

285285

286-
## 🪙 Start Definitions
286+
## Start Definitions
287287

288288
(See [Start Definitions](Explainer.md#start-definitions) in the explainer.)
289289
```ebnf
@@ -292,10 +292,11 @@ start ::= f:<funcidx> arg*:vec(<valueidx>) r:<u32> => (start f (value arg)* (res
292292
Notes:
293293
* Validation requires `f` have `functype` with `param` arity and types matching `arg*`
294294
and `result` arity `r`.
295-
* Validation appends the `result` types of `f` to the value index space (making
295+
* Currently, `arg*` and `result*` are requird to be empty.
296+
* 🪙 Validation appends the `result` types of `f` to the value index space (making
296297
them available for reference by subsequent definitions).
297298

298-
In addition to the type-compatibility checks mentioned above, the validation
299+
🪙 In addition to the type-compatibility checks mentioned above, the validation
299300
rules for value definitions additionally require that each value is consumed
300301
exactly once. Thus, during validation, each value has an associated "consumed"
301302
boolean flag. When a value is first added to the value index space (via

design/mvp/Explainer.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ JavaScript runtimes. For a more user-focussed explanation, take a look at the
2222
* [Canonical definitions](#canonical-definitions)
2323
* [Canonical ABI](#canonical-built-ins)
2424
* [Canonical built-ins](#canonical-built-ins)
25-
* [Start definitions](#-start-definitions)
25+
* [Start Definitions](#-start-definitions)
2626
* [Import and export definitions](#import-and-export-definitions)
2727
* [Component invariants](#component-invariants)
2828
* [JavaScript embedding](#JavaScript-embedding)
@@ -1305,15 +1305,28 @@ See the [CanonicalABI.md](CanonicalABI.md#canonical-definitions) for detailed
13051305
definitions of each of these built-ins and their interactions.
13061306

13071307

1308-
### 🪙 Start Definitions
1308+
### Start Definitions
13091309

13101310
Like modules, components can have start functions that are called during
1311-
instantiation. Unlike modules, components can call start functions at multiple
1312-
points during instantiation with each such call having parameters and results.
1311+
instantiation. Unlike modules, component dependencies are always acyclic,
1312+
so their dependencies are always initialized first, so they can call
1313+
imports without any special considerations.
1314+
13131315
Thus, `start` definitions in components look like function calls:
13141316
```ebnf
13151317
start ::= (start <funcidx> (value <valueidx>)* (result (value <id>?))*)
13161318
```
1319+
1320+
If multiple start definitins are present in a component, they are called in
1321+
the order they appear in the encoding.
1322+
1323+
Currently, the `(value <valueidx>)*` and `(result (value <id>?))` lists are
1324+
required to be empty, and `<funcidx>` must refer to a function with no
1325+
arguments or return values. In the 🪙 future, these will allow the calls
1326+
to be passed arguments and return results.
1327+
1328+
#### 🪙 Start Definition arguments and results
1329+
13171330
The `(value <valueidx>)*` list specifies the arguments passed to `funcidx` by
13181331
indexing into the *value index space*. Value definitions (in the value index
13191332
space) are like immutable `global` definitions in Core WebAssembly except that

0 commit comments

Comments
 (0)