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

[spec] Add concrete ref types#49

Merged
rossberg merged 8 commits intomasterfrom
spec
Aug 6, 2021
Merged

[spec] Add concrete ref types#49
rossberg merged 8 commits intomasterfrom
spec

Conversation

@rossberg
Copy link
Member

Starting the spec text for this proposal by adding the new forms of ref types, text & binary format, and surrounding semantics.

(Includes a few minor spec typos that I discovered on the way and that I will upstream in another PR.)

@rossberg
Copy link
Member Author

@conrad-watt, friendly ping.

@conrad-watt
Copy link
Contributor

sorry for the delay, I'm on this now

Copy link
Contributor

@conrad-watt conrad-watt left a comment

Choose a reason for hiding this comment

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

I believe the typing of ref.func also needs to be updated to have a return type that is the type of a specific function, rather than just funcref, but I can't comment directly on that part of the file.

In future versions of WebAssembly, value types may include types denoted by :ref:`type indices <syntax-typeidx>`.
Thus, the binary format for types corresponds to the encodings of small negative :math:`\xref{binary/values}{binary-sint}{\sN}` values, so that they can coexist with (positive) type indices in the future.
In some places, possible types include both type constructors or types denoted by :ref:`type indices <syntax-typeidx>`.
Thus, the binary format for most type constructors corresponds to the encodings of small negative :math:`\xref{binary/values}{binary-sint}{\sN}` values, such that they can unambiguously occur in the same place as (positive) type indices.
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the "most" here be fixed with a rebase?

(ref WebAssembly/spec#1338)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I merged upstream.


.. note::
In the current version of WebAssembly, only tables of element type |FUNCREF| can be initialized with an element segment.
In the current version of WebAssembly, only tables whose elements are function references can be initialized with an element segment.
Copy link
Contributor

Choose a reason for hiding this comment

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

should this note contain a ref to <syntax-reftype>?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

.. math::
\frac{
\vdashmemtype \memtype \ok
C \vdashmemtype \memtype \ok
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the memtype is just a limit, the context C isn't used. Could add it trivially to the limit validity judgement to make the shape match, or remove it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Uniformly added C to all wf and subtyping judgements. Also updated rules index.

* Or :math:`\heaptype_1` is a :ref:`type index <syntax-typeidx>` that defines a function type and :math:`\heaptype_2` is :math:`FUNC`.

* Or :math:`\heaptype_1` is a :ref:`type index <syntax-typeidx>` that defines a function type :math:`\functype_1`, and :math:`\heaptype_2` is a :ref:`type index <syntax-typeidx>` that defines a function type :math:`\functype_2`, and :math:`\functype_1` :ref:`matches <match-functype>` :math:`\functype_2`.

Copy link
Contributor

Choose a reason for hiding this comment

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

The formatting here is broken for me, with judgments partially clipping into each other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tweaked formatting.

* Either both :math:`\reftype_1` and :math:`\reftype_2` are the same.
* :math:`\NULL_1` is absent or :math:`\NULL_2` is present.

.. math::
Copy link
Contributor

Choose a reason for hiding this comment

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

The formatting here is broken for me, with judgments partially clipping into each other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Dito.

~\\[-1ex]
\frac{
\begin{array}{@{}c@{}}
C \vdashresulttypematch [t_{11}^\ast] \matchesresulttype [t_{21}^ast]
Copy link
Contributor

Choose a reason for hiding this comment

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

various uses of ^ast instead of ^\ast should be fixed here

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Soundness
---------

.. todo:: need to ensure wf of nondet types and operate wrt semantic types
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you give me the cliff-notes version of what's missing here (especially "nondet types")?

Copy link
Member Author

Choose a reason for hiding this comment

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

Backmerged refinements of these notes from follow-up PR.

Copy link
Member Author

@rossberg rossberg left a comment

Choose a reason for hiding this comment

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

Comments addressed. Also moved the subtyping rules to a new section and updated the rule index.

Soundness
---------

.. todo:: need to ensure wf of nondet types and operate wrt semantic types
Copy link
Member Author

Choose a reason for hiding this comment

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

Backmerged refinements of these notes from follow-up PR.

In future versions of WebAssembly, value types may include types denoted by :ref:`type indices <syntax-typeidx>`.
Thus, the binary format for types corresponds to the encodings of small negative :math:`\xref{binary/values}{binary-sint}{\sN}` values, so that they can coexist with (positive) type indices in the future.
In some places, possible types include both type constructors or types denoted by :ref:`type indices <syntax-typeidx>`.
Thus, the binary format for most type constructors corresponds to the encodings of small negative :math:`\xref{binary/values}{binary-sint}{\sN}` values, such that they can unambiguously occur in the same place as (positive) type indices.
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I merged upstream.


.. note::
In the current version of WebAssembly, only tables of element type |FUNCREF| can be initialized with an element segment.
In the current version of WebAssembly, only tables whose elements are function references can be initialized with an element segment.
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

.. math::
\frac{
\vdashmemtype \memtype \ok
C \vdashmemtype \memtype \ok
Copy link
Member Author

Choose a reason for hiding this comment

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

Uniformly added C to all wf and subtyping judgements. Also updated rules index.

* Or :math:`\heaptype_1` is a :ref:`type index <syntax-typeidx>` that defines a function type and :math:`\heaptype_2` is :math:`FUNC`.

* Or :math:`\heaptype_1` is a :ref:`type index <syntax-typeidx>` that defines a function type :math:`\functype_1`, and :math:`\heaptype_2` is a :ref:`type index <syntax-typeidx>` that defines a function type :math:`\functype_2`, and :math:`\functype_1` :ref:`matches <match-functype>` :math:`\functype_2`.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tweaked formatting.

* Either both :math:`\reftype_1` and :math:`\reftype_2` are the same.
* :math:`\NULL_1` is absent or :math:`\NULL_2` is present.

.. math::
Copy link
Member Author

Choose a reason for hiding this comment

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

Dito.

~\\[-1ex]
\frac{
\begin{array}{@{}c@{}}
C \vdashresulttypematch [t_{11}^\ast] \matchesresulttype [t_{21}^ast]
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@conrad-watt conrad-watt left a comment

Choose a reason for hiding this comment

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

minor nit

=============================================== ===============================================================================
:ref:`External type <match-externtype>` :math:`\vdashexterntypematch \externtype_1 \matchesexterntype \externtype_2`
:ref:`Limits <match-limits>` :math:`\vdashlimitsmatch \limits_1 \matcheslimits \limits_2`
:ref:`Number type <match-numtype>` :math:`C \vdashnumtypematch \numtype_1 \matchesnumtype \numtype_2`
Copy link
Contributor

Choose a reason for hiding this comment

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

The various \matches* symbols don't appear to correctly link to the "Matching" section when clicked

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be fixed now.

Copy link
Contributor

@conrad-watt conrad-watt left a comment

Choose a reason for hiding this comment

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

LGTM

Just to check, when this is fully merged into the main spec, there will be a second round of reviews (hopefully with another fresh pair of eyes)? The changes are involved enough that I could definitely have missed something.

@rossberg
Copy link
Member Author

rossberg commented Aug 6, 2021

Yes, that's the idea. Though how thorough that final review will be is hard to predict.

@rossberg rossberg merged commit e8d2909 into master Aug 6, 2021
.. |matchestabletype| mathdef:: \xref{valid/matching}{match-tabletype}{\leq}
.. |matchesmemtype| mathdef:: \xref{valid/matching}{match-memtype}{\leq}
.. |matchesglobaltype| mathdef:: \xref{valid/matching}{match-globaltype}{\leq}
.. |matchesexterntype| mathdef:: \xref{exec/matching}{match-externtype}{\leq}
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, missed this - a few exec/matching should be valid/matching

Copy link
Member Author

Choose a reason for hiding this comment

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

Fix included in #52.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants