Skip to content

Commit

Permalink
Merge pull request #422 from WebAssembly/ref.i31
Browse files Browse the repository at this point in the history
Rename i31.new mnemonic to ref.i31
  • Loading branch information
rossberg authored Sep 12, 2023
2 parents 5a85356 + 0f4dba9 commit 5d2313b
Show file tree
Hide file tree
Showing 29 changed files with 63 additions and 64 deletions.
4 changes: 2 additions & 2 deletions document/core/appendix/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ Added managed reference types [#proposal-gc]_.

* New generic :ref:`reference instructions <syntax-instr-ref>`: |REFEQ|, |REFTEST|, |REFCAST|, |BRONCAST|, |BRONCASTFAIL|

* New :ref:`reference instructions <syntax-instr-ref>` for :ref:`unboxed scalars <syntax-i31>`: |I31NEW|, :math:`\I31GET\K{\_}\sx`
* New :ref:`reference instructions <syntax-instr-ref>` for :ref:`unboxed scalars <syntax-i31>`: |REFI31|, :math:`\I31GET\K{\_}\sx`

* New :ref:`reference instructions <syntax-instr-ref>` for :ref:`structure types <syntax-structtype>`: |STRUCTNEW|, |STRUCTNEWDEFAULT|, :math:`\STRUCTGET\K{\_}\sx^?`, |STRUCTSET|

* New :ref:`reference instructions <syntax-instr-ref>` for :ref:`array types <syntax-structtype>`: |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |ARRAYNEWDATA|, |ARRAYNEWELEM|, :math:`\ARRAYGET\K{\_}\sx^?`, |ARRAYSET|, |ARRAYLEN|, |ARRAYFILL|, |ARRAYCOPY|, |ARRAYINITDATA|, |ARRAYINITELEM|

* New :ref:`reference instructions <syntax-instr-ref>` for converting :ref:`host types <syntax-externtype>`: |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|

* Extended set of :ref:`constant instructions <valid-const>` with |I31NEW|, |STRUCTNEW|, |STRUCTNEWDEFAULT|, |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|, and |GLOBALGET| for any previously declared immutable :ref:`global <syntax-global>`
* Extended set of :ref:`constant instructions <valid-const>` with |REFI31|, |STRUCTNEW|, |STRUCTNEWDEFAULT|, |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|, and |GLOBALGET| for any previously declared immutable :ref:`global <syntax-global>`


.. [#proposal-signext]
Expand Down
2 changes: 1 addition & 1 deletion document/core/appendix/index-instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
Instruction(r'\BRONCASTFAIL~t_1~t_2', r'\hex{FB}~\hex{19}', r'[t_1] \to [t_2]', r'valid-br_on_cast_fail', r'exec-br_on_cast_fail'),
Instruction(r'\EXTERNINTERNALIZE', r'\hex{FB}~\hex{1A}', r'[\EXTERNREF] \to [\ANYREF]', r'valid-extern.internalize', r'exec-extern.internalize'),
Instruction(r'\EXTERNEXTERNALIZE', r'\hex{FB}~\hex{1B}', r'[\ANYREF] \to [\EXTERNREF]', r'valid-extern.externalize', r'exec-extern.externalize'),
Instruction(r'\I31NEW', r'\hex{FB}~\hex{1C}', r'[\I32] \to [\I31REF]', r'valid-i31.new', r'exec-i31.new'),
Instruction(r'\REFI31', r'\hex{FB}~\hex{1C}', r'[\I32] \to [\I31REF]', r'valid-ref.i31', r'exec-ref.i31'),
Instruction(r'\I31GETS', r'\hex{FB}~\hex{1D}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'),
Instruction(r'\I31GETU', r'\hex{FB}~\hex{1E}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'),
Instruction(None, r'\hex{FB}~\hex{1E} \dots'),
Expand Down
4 changes: 2 additions & 2 deletions document/core/binary/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Generic :ref:`reference instructions <syntax-instr-ref>` are represented by sing
.. _binary-array.copy:
.. _binary-array.init_data:
.. _binary-array.init_elem:
.. _binary-i31.new:
.. _binary-ref.i31:
.. _binary-i31.get_s:
.. _binary-i31.get_u:
.. _binary-ref.test:
Expand Down Expand Up @@ -168,7 +168,7 @@ Generic :ref:`reference instructions <syntax-instr-ref>` are represented by sing
\hex{FB}~~23{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFCAST~(\REF~\NULL~\X{ht}) \\ &&|&
\hex{FB}~~26{:}\Bu32 &\Rightarrow& \EXTERNINTERNALIZE \\ &&|&
\hex{FB}~~27{:}\Bu32 &\Rightarrow& \EXTERNEXTERNALIZE \\ &&|&
\hex{FB}~~28{:}\Bu32 &\Rightarrow& \I31NEW \\ &&|&
\hex{FB}~~28{:}\Bu32 &\Rightarrow& \REFI31 \\ &&|&
\hex{FB}~~29{:}\Bu32 &\Rightarrow& \I31GETS \\ &&|&
\hex{FB}~~30{:}\Bu32 &\Rightarrow& \I31GETU \\
\end{array}
Expand Down
16 changes: 8 additions & 8 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -375,22 +375,22 @@ Reference Instructions
.. _exec-i31.new:
.. _exec-ref.i31:

:math:`\I31NEW`
:math:`\REFI31`
...............

1. Assert: due to :ref:`validation <valid-i31.new>`, a :ref:`value <syntax-val>` of :ref:`type <syntax-valtype>` |I32| is on the top of the stack.
1. Assert: due to :ref:`validation <valid-ref.i31>`, a :ref:`value <syntax-val>` of :ref:`type <syntax-valtype>` |I32| is on the top of the stack.

2. Pop the value :math:`\I32.\CONST~i` from the stack.

3. Let :math:`j` be the result of computing :math:`\wrap_{32,31}(i)`.

4. Push the reference value :math:`(\REFI31~j)` to the stack.
4. Push the reference value :math:`(\REFI31NUM~j)` to the stack.

.. math::
\begin{array}{lcl@{\qquad}l}
(\I32.\CONST~i)~\I31NEW &\stepto& (\REFI31~\wrap_{32,31}(i))
(\I32.\CONST~i)~\REFI31 &\stepto& (\REFI31NUM~\wrap_{32,31}(i))
\end{array}
Expand All @@ -409,16 +409,16 @@ Reference Instructions

4. Assert: due to :ref:`validation <valid-i31.get_sx>`, a :math:`\reff` is a :ref:`scalar reference <syntax-ref.i31>`.

5. Let :math:`\REFI31~i` be the reference value :math:`\reff`.
5. Let :math:`\REFI31NUM~i` be the reference value :math:`\reff`.

6. Let :math:`j` be the result of computing :math:`\extend^{\sx}_{31,32}(i)`.

7. Push the value :math:`\I32.\CONST~j` to the stack.

.. math::
\begin{array}{lcl@{\qquad}l}
(\REFI31~i)~\I31NEW &\stepto& (\I32.\CONST~\extend^{\sx}_{31,32}(i)) \\
(\REFNULL~t)~\I31NEW &\stepto& \TRAP
(\REFI31NUM~i)~\I31GET\K{\_}\sx &\stepto& (\I32.\CONST~\extend^{\sx}_{31,32}(i)) \\
(\REFNULL~t)~\I31GET\K{\_}\sx &\stepto& \TRAP
\end{array}
Expand Down
8 changes: 4 additions & 4 deletions document/core/exec/runtime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Runtime Structure
.. _syntax-num:
.. _syntax-vecc:
.. _syntax-ref:
.. _syntax-ref.i31:
.. _syntax-ref.i31num:
.. _syntax-ref.struct:
.. _syntax-ref.array:
.. _syntax-ref.host:
Expand Down Expand Up @@ -48,7 +48,7 @@ Any of the aformentioned references can furthermore be wrapped up as an *externa
\V128.\CONST~\i128 \\
\production{reference} & \reff &::=&
\REFNULL~t \\&&|&
\REFI31~\u31 \\&&|&
\REFI31NUM~\u31 \\&&|&
\REFSTRUCTADDR~\structaddr \\&&|&
\REFARRAYADDR~\arrayaddr \\&&|&
\REFFUNCADDR~\funcaddr \\&&|&
Expand Down Expand Up @@ -634,7 +634,7 @@ In order to express the reduction of :ref:`traps <trap>`, :ref:`calls <syntax-ca
\production{administrative instruction} & \instr &::=&
\dots \\ &&|&
\TRAP \\ &&|&
\REFI31~\u31 \\&&|&
\REFI31NUM~\u31 \\&&|&
\REFSTRUCTADDR~\structaddr \\&&|&
\REFARRAYADDR~\arrayaddr \\&&|&
\REFFUNCADDR~\funcaddr \\&&|&
Expand All @@ -649,7 +649,7 @@ In order to express the reduction of :ref:`traps <trap>`, :ref:`calls <syntax-ca
The |TRAP| instruction represents the occurrence of a trap.
Traps are bubbled up through nested instruction sequences, ultimately reducing the entire program to a single |TRAP| instruction, signalling abrupt termination.

The |REFI31| instruction represents :ref:`unboxed scalar <syntax-ref.i31>` reference values,
The |REFI31NUM| instruction represents :ref:`unboxed scalar <syntax-ref.i31>` reference values,
|REFSTRUCTADDR| and |REFARRAYADDR| represent :ref:`structure <syntax-ref.struct>` and :ref:`array <syntax-ref.array>` reference values, respectively,
and |REFFUNCADDR| instruction represents :ref:`function reference <syntax-ref.func>` values.
Similarly, |REFHOSTADDR| represents :ref:`host references <syntax-ref.host>`
Expand Down
8 changes: 4 additions & 4 deletions document/core/exec/values.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ The following auxiliary typing rules specify this typing relation relative to a
That ensures that it is compatible with any nullable type in that hierarchy.


.. _valid-ref.i31:
.. _valid-ref.i31num:

:ref:`Scalar References <syntax-ref>` :math:`\REFI31~i`
.......................................................
:ref:`Scalar References <syntax-ref>` :math:`\REFI31NUM~i`
..........................................................

* The value is valid with :ref:`reference type <syntax-reftype>` :math:`(\REF~\I31)`.

.. math::
\frac{
}{
S \vdashval \REFI31~i : \REF~\I31
S \vdashval \REFI31NUM~i : \REF~\I31
}
Expand Down
6 changes: 3 additions & 3 deletions document/core/syntax/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ while the latter performs a downcast and :ref:`traps <trap>` if the operand's ty
.. _syntax-array.copy:
.. _syntax-array.init_data:
.. _syntax-array.init_elem:
.. _syntax-i31.new:
.. _syntax-ref.i31:
.. _syntax-i31.get_s:
.. _syntax-i31.get_u:
.. _syntax-extern.internalize:
Expand Down Expand Up @@ -519,7 +519,7 @@ Instructions in this group are concerned with creating and accessing :ref:`refer
\ARRAYCOPY~\typeidx~\typeidx \\&&|&
\ARRAYINITDATA~\typeidx~\dataidx \\&&|&
\ARRAYINITELEM~\typeidx~\elemidx \\&&|&
\I31NEW \\&&|&
\REFI31 \\&&|&
\I31GET\K{\_}\sx \\&&|&
\EXTERNINTERNALIZE \\&&|&
\EXTERNEXTERNALIZE \\
Expand All @@ -537,7 +537,7 @@ again allowing for different sign extension modes in the case of a :ref:`packed
|ARRAYLEN| produces the length of an array.
|ARRAYFILL| fills a specified slice of an array with a given value and |ARRAYCOPY|, |ARRAYINITDATA|, and |ARRAYINITELEM| copy elements to a specified slice of an array from a given array, data segment, or element segment, respectively.

The instructions |I31NEW| and :math:`\I31GET\K{\_}\sx` convert between type |I31| and an unboxed :ref:`scalar <syntax-i31>`.
The instructions |REFI31| and :math:`\I31GET\K{\_}\sx` convert between type |I31| and an unboxed :ref:`scalar <syntax-i31>`.

The instructions |EXTERNINTERNALIZE| and |EXTERNEXTERNALIZE| allow lossless conversion between references represented as type :math:`(\REF~\NULL~\EXTERN)`| and as :math:`(\REF~\NULL~\ANY)`.

Expand Down
4 changes: 2 additions & 2 deletions document/core/text/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ Reference Instructions
.. _text-array.copy:
.. _text-array.init_data:
.. _text-array.init_elem:
.. _text-i31.new:
.. _text-ref.i31:
.. _text-i31.get_s:
.. _text-i31.get_u:
.. _text-ref.test:
Expand Down Expand Up @@ -237,7 +237,7 @@ Reference Instructions
\text{array.copy}~~x{:}\Ttypeidx_I~~y{:}\Ttypeidx_I &\Rightarrow& \ARRAYCOPY~x~y \\ &&|&
\text{array.init\_data}~~x{:}\Ttypeidx_I~~y{:}\Tdataidx_I &\Rightarrow& \ARRAYINITDATA~x~y \\ &&|&
\text{array.init\_elem}~~x{:}\Ttypeidx_I~~y{:}\Telemidx_I &\Rightarrow& \ARRAYINITELEM~x~y \\ &&|&
\text{i31.new} &\Rightarrow& \I31NEW \\ &&|&
\text{ref.i31} &\Rightarrow& \REFI31 \\ &&|&
\text{i31.get\_u} &\Rightarrow& \I31GETU \\ &&|&
\text{i31.get\_s} &\Rightarrow& \I31GETS \\ &&|&
\text{extern.internalize} &\Rightarrow& \EXTERNINTERNALIZE \\ &&|&
Expand Down
4 changes: 2 additions & 2 deletions document/core/util/macros.def
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
.. |ARRAYINITDATA| mathdef:: \xref{syntax/instructions}{syntax-instr-aray}{\K{array.init\_data}}
.. |ARRAYINITELEM| mathdef:: \xref{syntax/instructions}{syntax-instr-aray}{\K{array.init\_elem}}

.. |I31NEW| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.new}}
.. |REFI31| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{ref.i31}}
.. |I31GET| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.get}}
.. |I31GETS| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.get\_s}}
.. |I31GETU| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.get\_u}}
Expand Down Expand Up @@ -1302,7 +1302,7 @@

.. Administrative Instructions, terminals

.. |REFI31| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}i31}}
.. |REFI31NUM| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}i31}}
.. |REFFUNCADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}func}}
.. |REFSTRUCTADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}struct}}
.. |REFARRAYADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}array}}
Expand Down
6 changes: 3 additions & 3 deletions document/core/valid/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -729,17 +729,17 @@ Aggregate Reference Instructions
Scalar Reference Instructions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. _valid-i31.new:
.. _valid-ref.i31:

:math:`\I31NEW`
:math:`\REFI31`
...............

* The instruction is valid with type :math:`[\I32] \to [(\REF~\I31)]`.

.. math::
\frac{
}{
C \vdashinstr \I31NEW : [\I32] \to [(\REF~\I31)]
C \vdashinstr \REFI31 : [\I32] \to [(\REF~\I31)]
}
.. _valid-i31.get_sx:
Expand Down
2 changes: 1 addition & 1 deletion interpreter/binary/decode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ let rec instr s =
| 0x1al -> extern_internalize
| 0x1bl -> extern_externalize

| 0x1cl -> i31_new
| 0x1cl -> ref_i31
| 0x1dl -> i31_get_s
| 0x1el -> i31_get_u

Expand Down
2 changes: 1 addition & 1 deletion interpreter/binary/encode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ struct
| RefCast (NoNull, t) -> op 0xfb; op 0x16; heap_type t
| RefCast (Null, t) -> op 0xfb; op 0x17; heap_type t

| I31New -> op 0xfb; op 0x1c
| RefI31 -> op 0xfb; op 0x1c
| I31Get SX -> op 0xfb; op 0x1d
| I31Get ZX -> op 0xfb; op 0x1e

Expand Down
2 changes: 1 addition & 1 deletion interpreter/exec/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ let rec step (c : config) : config =
| RefEq, Ref r1 :: Ref r2 :: vs' ->
value_of_bool (eq_ref r1 r2) :: vs', []

| I31New, Num (I32 i) :: vs' ->
| RefI31, Num (I32 i) :: vs' ->
Ref (I31.I31Ref (I31.of_i32 i)) :: vs', []

| I31Get ext, Ref (NullRef _) :: vs' ->
Expand Down
2 changes: 1 addition & 1 deletion interpreter/syntax/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ and instr' =
| RefTest of ref_type (* type test *)
| RefCast of ref_type (* type cast *)
| RefEq (* reference equality *)
| I31New (* allocate scalar *)
| RefI31 (* scalar reference *)
| I31Get of extension (* read scalar *)
| StructNew of idx * initop (* allocate structure *)
| StructGet of idx * idx * extension option (* read structure field *)
Expand Down
2 changes: 1 addition & 1 deletion interpreter/syntax/free.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ let rec instr (e : instr) =
| RefEq -> empty
| RefNull t -> heap_type t
| RefFunc x -> funcs (idx x)
| I31New | I31Get _ -> empty
| RefI31 | I31Get _ -> empty
| StructNew (x, _) | ArrayNew (x, _) | ArrayNewFixed (x, _) -> types (idx x)
| ArrayNewElem (x, y) -> types (idx x) ++ elems (idx y)
| ArrayNewData (x, y) -> types (idx x) ++ datas (idx y)
Expand Down
2 changes: 1 addition & 1 deletion interpreter/syntax/operators.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ let ref_test t = RefTest t
let ref_cast t = RefCast t
let ref_eq = RefEq

let i31_new = I31New
let ref_i31 = RefI31
let i31_get_u = I31Get ZX
let i31_get_s = I31Get SX
let struct_new x = StructNew (x, Explicit)
Expand Down
2 changes: 1 addition & 1 deletion interpreter/text/arrange.ml
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ let rec instr e =
| RefTest t -> "ref.test", [Atom (ref_type t)]
| RefCast t -> "ref.cast", [Atom (ref_type t)]
| RefEq -> "ref.eq", []
| I31New -> "i31.new", []
| RefI31 -> "ref.i31", []
| I31Get ext -> "i31.get" ^ extension ext, []
| StructNew (x, op) -> "struct.new" ^ initop op ^ " " ^ var x, []
| StructGet (x, y, exto) ->
Expand Down
3 changes: 1 addition & 2 deletions interpreter/text/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ rule token = parse

| "ref.null" -> REF_NULL
| "ref.func" -> REF_FUNC
| "ref.i31" -> REF_I31
| "ref.struct" -> REF_STRUCT
| "ref.array" -> REF_ARRAY
| "ref.extern" -> REF_EXTERN
Expand All @@ -320,7 +319,7 @@ rule token = parse
| "ref.cast" -> REF_CAST
| "ref.eq" -> REF_EQ

| "i31.new" -> I31_NEW
| "ref.i31" -> REF_I31
| "i31.get_u" -> I31_GET i31_get_u
| "i31.get_s" -> I31_GET i31_get_s

Expand Down
4 changes: 2 additions & 2 deletions interpreter/text/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ let inline_func_type_explicit (c : context) x ft at =
%token<Ast.instr'> UNARY BINARY TEST COMPARE CONVERT
%token REF_NULL REF_FUNC REF_I31 REF_STRUCT REF_ARRAY REF_EXTERN REF_HOST
%token REF_EQ REF_IS_NULL REF_AS_NON_NULL REF_TEST REF_CAST
%token I31_NEW
%token REF_I31
%token<Ast.instr'> I31_GET
%token<Ast.idx -> Ast.instr'> STRUCT_NEW ARRAY_NEW ARRAY_GET
%token STRUCT_SET
Expand Down Expand Up @@ -565,7 +565,7 @@ plain_instr :
| REF_TEST ref_type { fun c -> ref_test ($2 c) }
| REF_CAST ref_type { fun c -> ref_cast ($2 c) }
| REF_EQ { fun c -> ref_eq }
| I31_NEW { fun c -> i31_new }
| REF_I31 { fun c -> ref_i31 }
| I31_GET { fun c -> $1 }
| STRUCT_NEW var { fun c -> $1 ($2 c type_) }
| STRUCT_GET var var { fun c -> let x = $2 c type_ in $1 x ($3 c (field x.it)) }
Expand Down
4 changes: 2 additions & 2 deletions interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : infer_in
| RefEq ->
[RefT (Null, EqHT); RefT (Null, EqHT)] --> [NumT I32T], []

| I31New ->
| RefI31 ->
[NumT I32T] --> [RefT (NoNull, I31HT)], []

| I31Get ext ->
Expand Down Expand Up @@ -944,7 +944,7 @@ let is_const (c : context) (e : instr) =
match e.it with
| Const _ | VecConst _
| RefNull _ | RefFunc _
| I31New | StructNew _ | ArrayNew _ | ArrayNewFixed _ -> true
| RefI31 | StructNew _ | ArrayNew _ | ArrayNewFixed _ -> true
| GlobalGet x -> let GlobalT (mut, _t) = global c x in mut = Cons
| _ -> false

Expand Down
8 changes: 4 additions & 4 deletions proposals/gc/MVP.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ In particular, `ref.null` is typed as before, despite the introduction of `none`

#### Unboxed Scalars

* `i31.new` creates an `i31ref` from a 32 bit value, truncating high bit
- `i31.new : [i32] -> [(ref i31)]`
* `ref.i31` creates an `i31ref` from a 32 bit value, truncating high bit
- `ref.i31 : [i32] -> [(ref i31)]`
- this is a *constant instruction*

* `i31.get_<sx>` extracts the value, zero- or sign-extending
Expand Down Expand Up @@ -703,7 +703,7 @@ Note: The [reference types](https://github.com/WebAssembly/reference-types) and

In order to allow RTTs to be initialised as globals, the following extensions are made to the definition of *constant expressions*:

* `i31.new` is a constant instruction
* `ref.i31` is a constant instruction
* `struct.new` and `struct.new_default` are constant instructions
* `array.new`, `array.new_default`, and `array.new_fixed` are constant instructions
- Note: `array.new_data` and `array.new_elem` are not for the time being, see above
Expand Down Expand Up @@ -834,7 +834,7 @@ The opcode for heap types is encoded as an `s33`.
| 0xfb19 | `br_on_cast_fail $l (ref null1? ht1) (ref null2? ht2)` | `flags : u8`, $l : labelidx`, `ht1 : heaptype`, `ht2 : heaptype` |
| 0xfb1a | `extern.internalize` |
| 0xfb1b | `extern.externalize` |
| 0xfb1c | `i31.new` |
| 0xfb1c | `ref.i31` |
| 0xfb1d | `i31.get_s` |
| 0xfb1e | `i31.get_u` |

Expand Down
4 changes: 2 additions & 2 deletions proposals/gc/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ However, compilation with a uniform representation can still be achieved in this
(func $new_C (result (ref $C)) ...)
(func $f
...
(call $make_pair (i31.new 1) (i31.new 0))
(call $make_pair (ref.i31 1) (ref.i31 0))
...
(call $make_pair (call $new_C) (call $new_C))
...
Expand Down Expand Up @@ -607,7 +607,7 @@ To implement any such language efficiently, Wasm needs to provide such a mechani

There are only three instructions for converting from and to this reference type:
```
i31.new : [i32] -> [i31ref]
ref.i31 : [i32] -> [i31ref]
i31.get_u : [i31ref] -> [i32]
i31.get_s : [i31ref] -> [i32]
```
Expand Down
Loading

0 comments on commit 5d2313b

Please sign in to comment.