Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions AstSemantics.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@ operations.

Parameters and local variables use local types.

### Expression Types

*Expression types* include all the local types, and also:

* `void`: no value

AST expression nodes use expression types.
Also note that there is no need for a `void` type; function signatures use
[sequences of types](Calls.md) to describe their return values, so a `void`
return type is represented as an empty sequence.

### Memory Types

Expand Down Expand Up @@ -293,12 +289,24 @@ may be added in the future.

## Calls

Each function has a *signature*, which consists of:

* Return types, which are a sequence of local types
* Argument types, which are a sequence of local types

Note that WebAssembly itself does not support variable-length argument lists
(aka varargs). C and C++ compilers are expected to implement this functionality
by storing arguments in a buffer in linear memory and passing a pointer to the
buffer.

In the MVP, the length of the return types sequence may only be 0 or 1. This
restriction may be lifted in the future.

Direct calls to a function specify the callee by index into a function table.

* `call_direct`: call function directly

Each function has a signature in terms of expression types, and calls must match
the function signature
Calls must match the function signature
exactly. [Imported functions](MVP.md#code-loading-and-imports) also have
signatures and are added to the same function table and are thus also callable
via `call_direct`.
Expand Down
7 changes: 3 additions & 4 deletions PostMVP.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ variables are not aliasable and thus allow more aggressive optimization.
Support fixed-width SIMD vectors, initially only for 128-bit wide vectors as
demonstrated in [PNaCl's SIMD][] and [SIMD.js][].

SIMD adds new primitive variable and expression types (e.g., `float32x4`) so it
has to be part of the core semantics. SIMD operations (e.g., `float32x4.add`)
could be either builtin operations (no different from `int32.add`) or exports of
a builtin SIMD module.
SIMD adds new local types (e.g., `float32x4`) so it has to be part of the core
semantics. SIMD operations (e.g., `float32x4.add`) could be either builtin
operations (no different from `int32.add`) or exports of a builtin SIMD module.

[PNaCl's SIMD]: https://developer.chrome.com/native-client/reference/pnacl-c-cpp-language-support#portable-simd-vectors
[SIMD.js]: https://github.com/tc39/ecmascript_simd
Expand Down