Skip to content
Open
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
5 changes: 4 additions & 1 deletion document/core/syntax/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ The ${:DATA.DROP} instruction prevents further use of a passive data segment. Th
.. _syntax-ref.is_null:
.. _syntax-ref.as_non_null:
.. _syntax-ref.eq:
.. _syntax-ref.get_desc:
.. _syntax-ref.test:
.. _syntax-ref.cast:
.. _syntax-instr-ref:
Expand All @@ -247,7 +248,9 @@ The ${:REF.NULL} and ${:REF.FUNC} instructions produce a :ref:`null <syntax-null
The instruction ${:REF.IS_NULL} checks for null,
while ${:REF.AS_NON_NULL} converts a :ref:`nullable <syntax-reftype>` to a non-null one, and :ref:`traps <trap>` if it encounters null.

The ${:REF.EQ} compares two references.
The instruction ${:REF.EQ} compares two references.

The instruction ${:REF.GET_DESC} gets the :ref:`descriptor <syntax-desctype>` of an allocated value.

The instructions ${:REF.TEST} and ${:REF.CAST} test the :ref:`dynamic type <type-inst>` of a reference operand.
The former merely returns the result of the test,
Expand Down
1 change: 1 addition & 0 deletions document/core/util/macros.def
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@
.. |REFISNULL| mathdef:: \xref{syntax/instructions}{syntax-instr-ref}{\K{ref{.}is\_null}}
.. |REFASNONNULL| mathdef:: \xref{syntax/instructions}{syntax-instr-ref}{\K{ref{.}as\_non\_null}}
.. |REFEQ| mathdef:: \xref{syntax/instructions}{syntax-instr-ref}{\K{ref{.}eq}}
.. |REFGETDESC| mathdef:: \xref{syntax/instructions}{syntax-instr-ref}{\K{ref.get\_desc}}
.. |REFTEST| mathdef:: \xref{syntax/instructions}{syntax-instr-ref}{\K{ref{.}test}}
.. |REFCAST| mathdef:: \xref{syntax/instructions}{syntax-instr-ref}{\K{ref{.}cast}}

Expand Down
10 changes: 10 additions & 0 deletions document/core/valid/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,16 @@ $${rule-prose: Instr_ok/ref.eq}
$${rule: Instr_ok/ref.eq}


.. _valid-ref.get_desc:

:math:`\REFGETDESC~x`
.....................

$${rule-prose: Instr_ok/ref.get_desc}

$${rule: Instr_ok/ref.get_desc Instr_ok/ref.get_desc-exact}


.. _valid-ref.test:

:math:`\REFTEST~\X{rt}`
Expand Down
1 change: 1 addition & 0 deletions specification/wasm-latest/1.3-syntax.instructions.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ syntax instr/ref hint(desc "reference instruction") = ...
| REF.IS_NULL
| REF.AS_NON_NULL
| REF.EQ
| REF.GET_DESC typeidx
| REF.TEST reftype
| REF.CAST reftype
| ...
Expand Down
8 changes: 8 additions & 0 deletions specification/wasm-latest/2.3-validation.instructions.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ rule Instr_ok/ref.as_non_null:
rule Instr_ok/ref.eq:
C |- REF.EQ : (REF NULL EQ) (REF NULL EQ) -> I32

rule Instr_ok/ref.get_desc:
C |- REF.GET_DESC x : (REF NULL (_IDX x)) -> (REF (_IDX y))
-- ExpandDesc: C.TYPES[x] ~~ describestype? (DESCRIPTOR (_IDX y)) ct

rule Instr_ok/ref.get_desc-exact:
C |- REF.GET_DESC x : (REF NULL (EXACT (_IDX x))) -> (REF (EXACT (_IDX y)))
-- ExpandDesc: C.TYPES[x] ~~ describestype? (DESCRIPTOR (_IDX y)) ct

rule Instr_ok/ref.test:
C |- REF.TEST rt : rt' -> I32
-- Reftype_ok: C |- rt : OK
Expand Down
Loading