Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ref.null semantics #478

Merged
merged 6 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 13 additions & 4 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,22 @@ Reference Instructions

.. _exec-ref.null:

:math:`\REFNULL~\X{ht}`
:math:`\REFNULL~x`
.......................

1. Push the value :math:`\REFNULL~\X{ht}` to the stack.
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.

.. note::
No formal reduction rule is required for this instruction, since the |REFNULL| instruction is already a :ref:`value <syntax-val>`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a variation of this note still applies, since we only reduce some ref.null's.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-11-14 at 8 13 01 PM I added a note like this. If you think there are better words, feel free to change it.

2. Assert: due to :ref:`validation <valid-ref.null>`, the :ref:`defined type <syntax-deftype>` :math:`F.\AMODULE.\MITYPES[x]` exists.

3. Let :math:`\deftype` be the :ref:`defined type <syntax-deftype>` :math:`F.\AMODULE.\MITYPES[x]`.

4. Push the value :math:`\REFNULL~\deftype` to the stack.

.. math::
\begin{array}{lcl@{\qquad}l}
F; (\REFNULL~x) &\stepto& F; (\REFNULL~\deftype)
& (\iff \deftype = F.\AMODULE.\MITYPES[x]) \\
\end{array}


.. _exec-ref.func:
Expand Down
2 changes: 1 addition & 1 deletion document/core/exec/runtime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Any of the aformentioned references can furthermore be wrapped up as an *externa
\production{vector} & \vecc &::=&
\V128.\CONST~\i128 \\
\production{reference} & \reff &::=&
\REFNULL~t \\&&|&
\REFNULL~t & (\iff t \neq \typeidx) \\&&|&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct in spirit, but technically, since meta variables are existentially quantified, a negation like this doesn't do the right thing – you can always take a different type index to make it true. I think you need to say some like "t = absheaptype ∨ t = deftype". Or perhaps spell it out as \REFNULL~\absheaptype~|~\REFNULL~\deftype.

Copy link
Contributor Author

@ShinWonho ShinWonho Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-11-13 at 6 34 43 PM

Thank you for the comment! I fixed this.

\REFI31NUM~\u31 \\&&|&
\REFSTRUCTADDR~\structaddr \\&&|&
\REFARRAYADDR~\arrayaddr \\&&|&
Expand Down
Loading