Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 5d2313b

Browse files
authored
Merge pull request #422 from WebAssembly/ref.i31
Rename i31.new mnemonic to ref.i31
2 parents 5a85356 + 0f4dba9 commit 5d2313b

29 files changed

+63
-64
lines changed

document/core/appendix/changes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ Added managed reference types [#proposal-gc]_.
182182

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

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

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

189189
* 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|
190190

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

193-
* 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>`
193+
* 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>`
194194

195195

196196
.. [#proposal-signext]

document/core/appendix/index-instructions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
348348
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'),
349349
Instruction(r'\EXTERNINTERNALIZE', r'\hex{FB}~\hex{1A}', r'[\EXTERNREF] \to [\ANYREF]', r'valid-extern.internalize', r'exec-extern.internalize'),
350350
Instruction(r'\EXTERNEXTERNALIZE', r'\hex{FB}~\hex{1B}', r'[\ANYREF] \to [\EXTERNREF]', r'valid-extern.externalize', r'exec-extern.externalize'),
351-
Instruction(r'\I31NEW', r'\hex{FB}~\hex{1C}', r'[\I32] \to [\I31REF]', r'valid-i31.new', r'exec-i31.new'),
351+
Instruction(r'\REFI31', r'\hex{FB}~\hex{1C}', r'[\I32] \to [\I31REF]', r'valid-ref.i31', r'exec-ref.i31'),
352352
Instruction(r'\I31GETS', r'\hex{FB}~\hex{1D}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'),
353353
Instruction(r'\I31GETU', r'\hex{FB}~\hex{1E}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'),
354354
Instruction(None, r'\hex{FB}~\hex{1E} \dots'),

document/core/binary/instructions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Generic :ref:`reference instructions <syntax-instr-ref>` are represented by sing
126126
.. _binary-array.copy:
127127
.. _binary-array.init_data:
128128
.. _binary-array.init_elem:
129-
.. _binary-i31.new:
129+
.. _binary-ref.i31:
130130
.. _binary-i31.get_s:
131131
.. _binary-i31.get_u:
132132
.. _binary-ref.test:
@@ -168,7 +168,7 @@ Generic :ref:`reference instructions <syntax-instr-ref>` are represented by sing
168168
\hex{FB}~~23{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFCAST~(\REF~\NULL~\X{ht}) \\ &&|&
169169
\hex{FB}~~26{:}\Bu32 &\Rightarrow& \EXTERNINTERNALIZE \\ &&|&
170170
\hex{FB}~~27{:}\Bu32 &\Rightarrow& \EXTERNEXTERNALIZE \\ &&|&
171-
\hex{FB}~~28{:}\Bu32 &\Rightarrow& \I31NEW \\ &&|&
171+
\hex{FB}~~28{:}\Bu32 &\Rightarrow& \REFI31 \\ &&|&
172172
\hex{FB}~~29{:}\Bu32 &\Rightarrow& \I31GETS \\ &&|&
173173
\hex{FB}~~30{:}\Bu32 &\Rightarrow& \I31GETU \\
174174
\end{array}

document/core/exec/instructions.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,22 +375,22 @@ Reference Instructions
375375
376376
377377
378-
.. _exec-i31.new:
378+
.. _exec-ref.i31:
379379

380-
:math:`\I31NEW`
380+
:math:`\REFI31`
381381
...............
382382

383-
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.
383+
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.
384384

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

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

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

391391
.. math::
392392
\begin{array}{lcl@{\qquad}l}
393-
(\I32.\CONST~i)~\I31NEW &\stepto& (\REFI31~\wrap_{32,31}(i))
393+
(\I32.\CONST~i)~\REFI31 &\stepto& (\REFI31NUM~\wrap_{32,31}(i))
394394
\end{array}
395395
396396
@@ -409,16 +409,16 @@ Reference Instructions
409409

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

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

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

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

418418
.. math::
419419
\begin{array}{lcl@{\qquad}l}
420-
(\REFI31~i)~\I31NEW &\stepto& (\I32.\CONST~\extend^{\sx}_{31,32}(i)) \\
421-
(\REFNULL~t)~\I31NEW &\stepto& \TRAP
420+
(\REFI31NUM~i)~\I31GET\K{\_}\sx &\stepto& (\I32.\CONST~\extend^{\sx}_{31,32}(i)) \\
421+
(\REFNULL~t)~\I31GET\K{\_}\sx &\stepto& \TRAP
422422
\end{array}
423423
424424

document/core/exec/runtime.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Runtime Structure
1212
.. _syntax-num:
1313
.. _syntax-vecc:
1414
.. _syntax-ref:
15-
.. _syntax-ref.i31:
15+
.. _syntax-ref.i31num:
1616
.. _syntax-ref.struct:
1717
.. _syntax-ref.array:
1818
.. _syntax-ref.host:
@@ -48,7 +48,7 @@ Any of the aformentioned references can furthermore be wrapped up as an *externa
4848
\V128.\CONST~\i128 \\
4949
\production{reference} & \reff &::=&
5050
\REFNULL~t \\&&|&
51-
\REFI31~\u31 \\&&|&
51+
\REFI31NUM~\u31 \\&&|&
5252
\REFSTRUCTADDR~\structaddr \\&&|&
5353
\REFARRAYADDR~\arrayaddr \\&&|&
5454
\REFFUNCADDR~\funcaddr \\&&|&
@@ -634,7 +634,7 @@ In order to express the reduction of :ref:`traps <trap>`, :ref:`calls <syntax-ca
634634
\production{administrative instruction} & \instr &::=&
635635
\dots \\ &&|&
636636
\TRAP \\ &&|&
637-
\REFI31~\u31 \\&&|&
637+
\REFI31NUM~\u31 \\&&|&
638638
\REFSTRUCTADDR~\structaddr \\&&|&
639639
\REFARRAYADDR~\arrayaddr \\&&|&
640640
\REFFUNCADDR~\funcaddr \\&&|&
@@ -649,7 +649,7 @@ In order to express the reduction of :ref:`traps <trap>`, :ref:`calls <syntax-ca
649649
The |TRAP| instruction represents the occurrence of a trap.
650650
Traps are bubbled up through nested instruction sequences, ultimately reducing the entire program to a single |TRAP| instruction, signalling abrupt termination.
651651

652-
The |REFI31| instruction represents :ref:`unboxed scalar <syntax-ref.i31>` reference values,
652+
The |REFI31NUM| instruction represents :ref:`unboxed scalar <syntax-ref.i31>` reference values,
653653
|REFSTRUCTADDR| and |REFARRAYADDR| represent :ref:`structure <syntax-ref.struct>` and :ref:`array <syntax-ref.array>` reference values, respectively,
654654
and |REFFUNCADDR| instruction represents :ref:`function reference <syntax-ref.func>` values.
655655
Similarly, |REFHOSTADDR| represents :ref:`host references <syntax-ref.host>`

document/core/exec/values.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@ The following auxiliary typing rules specify this typing relation relative to a
6666
That ensures that it is compatible with any nullable type in that hierarchy.
6767

6868

69-
.. _valid-ref.i31:
69+
.. _valid-ref.i31num:
7070

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

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

7676
.. math::
7777
\frac{
7878
}{
79-
S \vdashval \REFI31~i : \REF~\I31
79+
S \vdashval \REFI31NUM~i : \REF~\I31
8080
}
8181
8282

document/core/syntax/instructions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ while the latter performs a downcast and :ref:`traps <trap>` if the operand's ty
482482
.. _syntax-array.copy:
483483
.. _syntax-array.init_data:
484484
.. _syntax-array.init_elem:
485-
.. _syntax-i31.new:
485+
.. _syntax-ref.i31:
486486
.. _syntax-i31.get_s:
487487
.. _syntax-i31.get_u:
488488
.. _syntax-extern.internalize:
@@ -519,7 +519,7 @@ Instructions in this group are concerned with creating and accessing :ref:`refer
519519
\ARRAYCOPY~\typeidx~\typeidx \\&&|&
520520
\ARRAYINITDATA~\typeidx~\dataidx \\&&|&
521521
\ARRAYINITELEM~\typeidx~\elemidx \\&&|&
522-
\I31NEW \\&&|&
522+
\REFI31 \\&&|&
523523
\I31GET\K{\_}\sx \\&&|&
524524
\EXTERNINTERNALIZE \\&&|&
525525
\EXTERNEXTERNALIZE \\
@@ -537,7 +537,7 @@ again allowing for different sign extension modes in the case of a :ref:`packed
537537
|ARRAYLEN| produces the length of an array.
538538
|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.
539539

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

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

document/core/text/instructions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Reference Instructions
199199
.. _text-array.copy:
200200
.. _text-array.init_data:
201201
.. _text-array.init_elem:
202-
.. _text-i31.new:
202+
.. _text-ref.i31:
203203
.. _text-i31.get_s:
204204
.. _text-i31.get_u:
205205
.. _text-ref.test:
@@ -237,7 +237,7 @@ Reference Instructions
237237
\text{array.copy}~~x{:}\Ttypeidx_I~~y{:}\Ttypeidx_I &\Rightarrow& \ARRAYCOPY~x~y \\ &&|&
238238
\text{array.init\_data}~~x{:}\Ttypeidx_I~~y{:}\Tdataidx_I &\Rightarrow& \ARRAYINITDATA~x~y \\ &&|&
239239
\text{array.init\_elem}~~x{:}\Ttypeidx_I~~y{:}\Telemidx_I &\Rightarrow& \ARRAYINITELEM~x~y \\ &&|&
240-
\text{i31.new} &\Rightarrow& \I31NEW \\ &&|&
240+
\text{ref.i31} &\Rightarrow& \REFI31 \\ &&|&
241241
\text{i31.get\_u} &\Rightarrow& \I31GETU \\ &&|&
242242
\text{i31.get\_s} &\Rightarrow& \I31GETS \\ &&|&
243243
\text{extern.internalize} &\Rightarrow& \EXTERNINTERNALIZE \\ &&|&

document/core/util/macros.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@
504504
.. |ARRAYINITDATA| mathdef:: \xref{syntax/instructions}{syntax-instr-aray}{\K{array.init\_data}}
505505
.. |ARRAYINITELEM| mathdef:: \xref{syntax/instructions}{syntax-instr-aray}{\K{array.init\_elem}}
506506

507-
.. |I31NEW| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.new}}
507+
.. |REFI31| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{ref.i31}}
508508
.. |I31GET| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.get}}
509509
.. |I31GETS| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.get\_s}}
510510
.. |I31GETU| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.get\_u}}
@@ -1302,7 +1302,7 @@
13021302

13031303
.. Administrative Instructions, terminals
13041304

1305-
.. |REFI31| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}i31}}
1305+
.. |REFI31NUM| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}i31}}
13061306
.. |REFFUNCADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}func}}
13071307
.. |REFSTRUCTADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}struct}}
13081308
.. |REFARRAYADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}array}}

document/core/valid/instructions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,17 +729,17 @@ Aggregate Reference Instructions
729729
Scalar Reference Instructions
730730
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
731731

732-
.. _valid-i31.new:
732+
.. _valid-ref.i31:
733733

734-
:math:`\I31NEW`
734+
:math:`\REFI31`
735735
...............
736736

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

739739
.. math::
740740
\frac{
741741
}{
742-
C \vdashinstr \I31NEW : [\I32] \to [(\REF~\I31)]
742+
C \vdashinstr \REFI31 : [\I32] \to [(\REF~\I31)]
743743
}
744744
745745
.. _valid-i31.get_sx:

0 commit comments

Comments
 (0)