diff --git a/document/core/appendix/changes.rst b/document/core/appendix/changes.rst index e0bb708f0..2817d5a5d 100644 --- a/document/core/appendix/changes.rst +++ b/document/core/appendix/changes.rst @@ -182,7 +182,7 @@ Added managed reference types [#proposal-gc]_. * New generic :ref:`reference instructions `: |REFEQ|, |REFTEST|, |REFCAST|, |BRONCAST|, |BRONCASTFAIL| -* New :ref:`reference instructions ` for :ref:`unboxed scalars `: |I31NEW|, :math:`\I31GET\K{\_}\sx` +* New :ref:`reference instructions ` for :ref:`unboxed scalars `: |REFI31|, :math:`\I31GET\K{\_}\sx` * New :ref:`reference instructions ` for :ref:`structure types `: |STRUCTNEW|, |STRUCTNEWDEFAULT|, :math:`\STRUCTGET\K{\_}\sx^?`, |STRUCTSET| @@ -190,7 +190,7 @@ Added managed reference types [#proposal-gc]_. * New :ref:`reference instructions ` for converting :ref:`host types `: |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE| -* Extended set of :ref:`constant instructions ` with |I31NEW|, |STRUCTNEW|, |STRUCTNEWDEFAULT|, |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|, and |GLOBALGET| for any previously declared immutable :ref:`global ` +* Extended set of :ref:`constant instructions ` with |REFI31|, |STRUCTNEW|, |STRUCTNEWDEFAULT|, |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|, and |GLOBALGET| for any previously declared immutable :ref:`global ` .. [#proposal-signext] diff --git a/document/core/appendix/index-instructions.py b/document/core/appendix/index-instructions.py index 80c8e8b03..edcddb6fa 100755 --- a/document/core/appendix/index-instructions.py +++ b/document/core/appendix/index-instructions.py @@ -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'), diff --git a/document/core/binary/instructions.rst b/document/core/binary/instructions.rst index 2aebc124d..53e32a3cd 100644 --- a/document/core/binary/instructions.rst +++ b/document/core/binary/instructions.rst @@ -126,7 +126,7 @@ Generic :ref:`reference instructions ` 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: @@ -168,7 +168,7 @@ Generic :ref:`reference instructions ` 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} diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index 5768ca375..4dee649e6 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -375,22 +375,22 @@ Reference Instructions -.. _exec-i31.new: +.. _exec-ref.i31: -:math:`\I31NEW` +:math:`\REFI31` ............... -1. Assert: due to :ref:`validation `, a :ref:`value ` of :ref:`type ` |I32| is on the top of the stack. +1. Assert: due to :ref:`validation `, a :ref:`value ` of :ref:`type ` |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} @@ -409,7 +409,7 @@ Reference Instructions 4. Assert: due to :ref:`validation `, a :math:`\reff` is a :ref:`scalar reference `. -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)`. @@ -417,8 +417,8 @@ Reference Instructions .. 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} diff --git a/document/core/exec/runtime.rst b/document/core/exec/runtime.rst index bf3b4ef69..3a613aa5d 100644 --- a/document/core/exec/runtime.rst +++ b/document/core/exec/runtime.rst @@ -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: @@ -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 \\&&|& @@ -634,7 +634,7 @@ In order to express the reduction of :ref:`traps `, :ref:`calls `, :ref:`calls ` reference values, +The |REFI31NUM| instruction represents :ref:`unboxed scalar ` reference values, |REFSTRUCTADDR| and |REFARRAYADDR| represent :ref:`structure ` and :ref:`array ` reference values, respectively, and |REFFUNCADDR| instruction represents :ref:`function reference ` values. Similarly, |REFHOSTADDR| represents :ref:`host references ` diff --git a/document/core/exec/values.rst b/document/core/exec/values.rst index d7a7de952..7ec439cdd 100644 --- a/document/core/exec/values.rst +++ b/document/core/exec/values.rst @@ -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 ` :math:`\REFI31~i` -....................................................... +:ref:`Scalar References ` :math:`\REFI31NUM~i` +.......................................................... * The value is valid with :ref:`reference type ` :math:`(\REF~\I31)`. .. math:: \frac{ }{ - S \vdashval \REFI31~i : \REF~\I31 + S \vdashval \REFI31NUM~i : \REF~\I31 } diff --git a/document/core/syntax/instructions.rst b/document/core/syntax/instructions.rst index 67b985885..1d6a61b71 100644 --- a/document/core/syntax/instructions.rst +++ b/document/core/syntax/instructions.rst @@ -482,7 +482,7 @@ while the latter performs a downcast and :ref:`traps ` 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: @@ -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 \\ @@ -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 `. +The instructions |REFI31| and :math:`\I31GET\K{\_}\sx` convert between type |I31| and an unboxed :ref:`scalar `. The instructions |EXTERNINTERNALIZE| and |EXTERNEXTERNALIZE| allow lossless conversion between references represented as type :math:`(\REF~\NULL~\EXTERN)`| and as :math:`(\REF~\NULL~\ANY)`. diff --git a/document/core/text/instructions.rst b/document/core/text/instructions.rst index 1b076c383..ad1c3e3e1 100644 --- a/document/core/text/instructions.rst +++ b/document/core/text/instructions.rst @@ -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: @@ -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 \\ &&|& diff --git a/document/core/util/macros.def b/document/core/util/macros.def index 85ce64e0d..8087a2c96 100644 --- a/document/core/util/macros.def +++ b/document/core/util/macros.def @@ -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}} @@ -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}} diff --git a/document/core/valid/instructions.rst b/document/core/valid/instructions.rst index 0509bd591..c7fdafedf 100644 --- a/document/core/valid/instructions.rst +++ b/document/core/valid/instructions.rst @@ -729,9 +729,9 @@ 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)]`. @@ -739,7 +739,7 @@ Scalar Reference Instructions .. math:: \frac{ }{ - C \vdashinstr \I31NEW : [\I32] \to [(\REF~\I31)] + C \vdashinstr \REFI31 : [\I32] \to [(\REF~\I31)] } .. _valid-i31.get_sx: diff --git a/interpreter/binary/decode.ml b/interpreter/binary/decode.ml index baaae3e72..f3ebce676 100644 --- a/interpreter/binary/decode.ml +++ b/interpreter/binary/decode.ml @@ -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 diff --git a/interpreter/binary/encode.ml b/interpreter/binary/encode.ml index c1d8b47c7..0319f5c06 100644 --- a/interpreter/binary/encode.ml +++ b/interpreter/binary/encode.ml @@ -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 diff --git a/interpreter/exec/eval.ml b/interpreter/exec/eval.ml index 2ca39e395..b4a0062de 100644 --- a/interpreter/exec/eval.ml +++ b/interpreter/exec/eval.ml @@ -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' -> diff --git a/interpreter/syntax/ast.ml b/interpreter/syntax/ast.ml index 437e3a10c..d7535374c 100644 --- a/interpreter/syntax/ast.ml +++ b/interpreter/syntax/ast.ml @@ -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 *) diff --git a/interpreter/syntax/free.ml b/interpreter/syntax/free.ml index a43b72f31..85858d432 100644 --- a/interpreter/syntax/free.ml +++ b/interpreter/syntax/free.ml @@ -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) diff --git a/interpreter/syntax/operators.ml b/interpreter/syntax/operators.ml index 168265898..cc3d09b69 100644 --- a/interpreter/syntax/operators.ml +++ b/interpreter/syntax/operators.ml @@ -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) diff --git a/interpreter/text/arrange.ml b/interpreter/text/arrange.ml index 0124b27f5..71590ef8a 100644 --- a/interpreter/text/arrange.ml +++ b/interpreter/text/arrange.ml @@ -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) -> diff --git a/interpreter/text/lexer.mll b/interpreter/text/lexer.mll index 3435dd3d0..44c22423c 100644 --- a/interpreter/text/lexer.mll +++ b/interpreter/text/lexer.mll @@ -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 @@ -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 diff --git a/interpreter/text/parser.mly b/interpreter/text/parser.mly index 4c16da85e..8e74493f8 100644 --- a/interpreter/text/parser.mly +++ b/interpreter/text/parser.mly @@ -275,7 +275,7 @@ let inline_func_type_explicit (c : context) x ft at = %token 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 I31_GET %token Ast.instr'> STRUCT_NEW ARRAY_NEW ARRAY_GET %token STRUCT_SET @@ -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)) } diff --git a/interpreter/valid/valid.ml b/interpreter/valid/valid.ml index 53d0cb976..5a28beb63 100644 --- a/interpreter/valid/valid.ml +++ b/interpreter/valid/valid.ml @@ -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 -> @@ -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 diff --git a/proposals/gc/MVP.md b/proposals/gc/MVP.md index 6382005df..69d72a6f0 100644 --- a/proposals/gc/MVP.md +++ b/proposals/gc/MVP.md @@ -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_` extracts the value, zero- or sign-extending @@ -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 @@ -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` | diff --git a/proposals/gc/Overview.md b/proposals/gc/Overview.md index f215b0c94..7655c206e 100644 --- a/proposals/gc/Overview.md +++ b/proposals/gc/Overview.md @@ -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)) ... @@ -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] ``` diff --git a/test/core/gc/br_on_cast.wast b/test/core/gc/br_on_cast.wast index a7b35949a..5b0605545 100644 --- a/test/core/gc/br_on_cast.wast +++ b/test/core/gc/br_on_cast.wast @@ -12,7 +12,7 @@ (func (export "init") (param $x externref) (table.set (i32.const 0) (ref.null any)) - (table.set (i32.const 1) (i31.new (i32.const 7))) + (table.set (i32.const 1) (ref.i31 (i32.const 7))) (table.set (i32.const 2) (struct.new $st (i32.const 6))) (table.set (i32.const 3) (array.new $at (i32.const 5) (i32.const 3))) (table.set (i32.const 4) (extern.internalize (local.get $x))) diff --git a/test/core/gc/br_on_cast_fail.wast b/test/core/gc/br_on_cast_fail.wast index 601de88af..ac5086407 100644 --- a/test/core/gc/br_on_cast_fail.wast +++ b/test/core/gc/br_on_cast_fail.wast @@ -12,7 +12,7 @@ (func (export "init") (param $x externref) (table.set (i32.const 0) (ref.null any)) - (table.set (i32.const 1) (i31.new (i32.const 7))) + (table.set (i32.const 1) (ref.i31 (i32.const 7))) (table.set (i32.const 2) (struct.new $st (i32.const 6))) (table.set (i32.const 3) (array.new $at (i32.const 5) (i32.const 3))) (table.set (i32.const 4) (extern.internalize (local.get $x))) diff --git a/test/core/gc/extern.wast b/test/core/gc/extern.wast index f9b01f11e..0f2fa8ec6 100644 --- a/test/core/gc/extern.wast +++ b/test/core/gc/extern.wast @@ -10,7 +10,7 @@ (func (export "init") (param $x externref) (table.set (i32.const 0) (ref.null any)) - (table.set (i32.const 1) (i31.new (i32.const 7))) + (table.set (i32.const 1) (ref.i31 (i32.const 7))) (table.set (i32.const 2) (struct.new_default $st)) (table.set (i32.const 3) (array.new_default $at (i32.const 0))) (table.set (i32.const 4) (extern.internalize (local.get $x))) diff --git a/test/core/gc/i31.wast b/test/core/gc/i31.wast index 284b5d244..3b6c32fba 100644 --- a/test/core/gc/i31.wast +++ b/test/core/gc/i31.wast @@ -1,13 +1,13 @@ (module (func (export "new") (param $i i32) (result (ref i31)) - (i31.new (local.get $i)) + (ref.i31 (local.get $i)) ) (func (export "get_u") (param $i i32) (result i32) - (i31.get_u (i31.new (local.get $i))) + (i31.get_u (ref.i31 (local.get $i))) ) (func (export "get_s") (param $i i32) (result i32) - (i31.get_s (i31.new (local.get $i))) + (i31.get_s (ref.i31 (local.get $i))) ) (func (export "get_u-null") (result i32) @@ -17,8 +17,8 @@ (i31.get_u (ref.null i31)) ) - (global $i (ref i31) (i31.new (i32.const 2))) - (global $m (mut (ref i31)) (i31.new (i32.const 3))) + (global $i (ref i31) (ref.i31 (i32.const 2))) + (global $m (mut (ref i31)) (ref.i31 (i32.const 3))) (func (export "get_globals") (result i32 i32) (i31.get_u (global.get $i)) (i31.get_u (global.get $m)) diff --git a/test/core/gc/ref_cast.wast b/test/core/gc/ref_cast.wast index 0a1a0edea..43a9587d8 100644 --- a/test/core/gc/ref_cast.wast +++ b/test/core/gc/ref_cast.wast @@ -12,7 +12,7 @@ (func (export "init") (param $x externref) (table.set (i32.const 0) (ref.null any)) - (table.set (i32.const 1) (i31.new (i32.const 7))) + (table.set (i32.const 1) (ref.i31 (i32.const 7))) (table.set (i32.const 2) (struct.new_default $st)) (table.set (i32.const 3) (array.new_default $at (i32.const 0))) (table.set (i32.const 4) (extern.internalize (local.get $x))) diff --git a/test/core/gc/ref_eq.wast b/test/core/gc/ref_eq.wast index c30d7a5c1..001efd69f 100644 --- a/test/core/gc/ref_eq.wast +++ b/test/core/gc/ref_eq.wast @@ -12,9 +12,9 @@ (func (export "init") (table.set (i32.const 0) (ref.null eq)) (table.set (i32.const 1) (ref.null i31)) - (table.set (i32.const 2) (i31.new (i32.const 7))) - (table.set (i32.const 3) (i31.new (i32.const 7))) - (table.set (i32.const 4) (i31.new (i32.const 8))) + (table.set (i32.const 2) (ref.i31 (i32.const 7))) + (table.set (i32.const 3) (ref.i31 (i32.const 7))) + (table.set (i32.const 4) (ref.i31 (i32.const 8))) (table.set (i32.const 5) (struct.new_default $st)) (table.set (i32.const 6) (struct.new_default $st)) (table.set (i32.const 7) (array.new_default $at (i32.const 0))) diff --git a/test/core/gc/ref_test.wast b/test/core/gc/ref_test.wast index 31cf62897..9a34c8468 100644 --- a/test/core/gc/ref_test.wast +++ b/test/core/gc/ref_test.wast @@ -16,7 +16,7 @@ (table.set $ta (i32.const 0) (ref.null any)) (table.set $ta (i32.const 1) (ref.null struct)) (table.set $ta (i32.const 2) (ref.null none)) - (table.set $ta (i32.const 3) (i31.new (i32.const 7))) + (table.set $ta (i32.const 3) (ref.i31 (i32.const 7))) (table.set $ta (i32.const 4) (struct.new_default $st)) (table.set $ta (i32.const 5) (array.new_default $at (i32.const 0))) (table.set $ta (i32.const 6) (extern.internalize (local.get $x))) @@ -29,7 +29,7 @@ (table.set $te (i32.const 0) (ref.null noextern)) (table.set $te (i32.const 1) (ref.null extern)) (table.set $te (i32.const 2) (local.get $x)) - (table.set $te (i32.const 3) (extern.externalize (i31.new (i32.const 8)))) + (table.set $te (i32.const 3) (extern.externalize (ref.i31 (i32.const 8)))) (table.set $te (i32.const 4) (extern.externalize (struct.new_default $st))) (table.set $te (i32.const 5) (extern.externalize (ref.null any))) )