You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
Per the vote on #69, this PR removes subtyping from the proposal. List of changes:
* Syntax:
- remove `nullref` type
- rename `anyref` type to `externref`
- extend `ref.null` and `ref.is_null` instructions with new immediate of the form `func` or `extern` (this will later have to generalise to a `constype` per the [typed references proposal](https://github.com/WebAssembly/function-references))
* Typing rules:
- `ref.null`, `ref.is_null`: determine reference type based on new immediate
- `select`, `call_indirect`, `table.copy`, `table.init`: drop subtyping
- `br_table`: revert to rule requiring same label types
- `elem` segment: drop subtyping
- `global` import: drop subtyping (link time)
* Remove subtyping rules and bottom type.
* Revert typing algorithm (interpreter and spec appendix).
* JS API:
- remove `"nullref"`
- rename `"anyref"` to `"externref"`
* Scripts:
- rename `ref` result to `ref.extern`
- rename `ref.host` value to `ref.extern`
- drop subtyping from invocation type check
* JS translation:
- extend harness with separate eq functions for each ref type
* Adjust tests:
- apply syntax changes
- remove tests for subtyping
- change tests exercising subtyping in other ways
The algorithm uses two separate stacks: the *value stack* and the *control stack*.
42
37
The former tracks the :ref:`types <syntax-valtype>` of operand values on the :ref:`stack <stack>`,
43
38
the latter surrounding :ref:`structured control instructions <syntax-instr-control>` and their associated :ref:`blocks <syntax-instr-control>`.
44
39
45
40
.. code-block:: pseudo
46
41
47
-
type val_stack = stack(val_type)
42
+
type val_stack = stack(val_type | Unknown)
48
43
49
44
type ctrl_stack = stack(ctrl_frame)
50
45
type ctrl_frame = {
@@ -54,7 +49,8 @@ the latter surrounding :ref:`structured control instructions <syntax-instr-contr
54
49
unreachable : bool
55
50
}
56
51
57
-
For each value, the value stack records its :ref:`value type <syntax-valtype>`.
52
+
For each value, the value stack records its :ref:`value type <syntax-valtype>`, or :code:`Unknown` when the type is not known.
53
+
58
54
59
55
For each entered block, the control stack records a *control frame* with the type of the associated :ref:`label <syntax-label>` (used to type-check branches), the result type of the block (used to check its result), the height of the operand stack at the start of the block (used to check that operands do not underflow the current block), and a flag recording whether the remainder of the block is unreachable (used to handle :ref:`stack-polymorphic <polymorphism>` typing after branches).
60
56
@@ -73,17 +69,19 @@ However, these variables are not manipulated directly by the main checking funct
73
69
74
70
.. code-block:: pseudo
75
71
76
-
func push_val(type : val_type) =
72
+
func push_val(type : val_type | Unknown) =
77
73
vals.push(type)
78
74
79
-
func pop_val() : val_type =
80
-
if (vals.size() = ctrls[0].height && ctrls[0].unreachable) return Bot
75
+
func pop_val() : val_type | Unknown =
76
+
if (vals.size() = ctrls[0].height && ctrls[0].unreachable) return Unknown
0 commit comments