From 7c0c7e307792d49927362788adec638a5fc8d3cf Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Fri, 14 Aug 2026 10:26:26 -0500 Subject: [PATCH 1/2] Add param name subsection --- document/core/appendix/custom.rst | 26 ++++++++++++++++++--- document/core/util/macros.def | 1 + proposals/extended-name-section/Overview.md | 7 ++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/document/core/appendix/custom.rst b/document/core/appendix/custom.rst index 6980d3e61..8e42bfe1d 100644 --- a/document/core/appendix/custom.rst +++ b/document/core/appendix/custom.rst @@ -5,7 +5,7 @@ Custom Sections and Annotations This appendix defines dedicated :ref:`custom sections ` for WebAssembly's :ref:`binary format ` and :ref:`annotations ` for the text format. Such sections or annotations do not contribute to, or otherwise affect, the WebAssembly semantics, and may be ignored by an implementation. -However, they provide useful meta data that implementations can make use of to improve user experience or take compilation hints. +However, they provide useful metadata that implementations can make use of to improve user experience or take compilation hints. @@ -31,7 +31,7 @@ Subsections ........... The :ref:`data ` of a name section consists of a sequence of *subsections*. -Each subsection consists of a +Each subsection consists of: * a one-byte subsection *id*, * the |U32| *size* of the contents, in bytes, @@ -54,7 +54,8 @@ Each subsection consists of a \Belemnamesubsec^? \\ &&& \Bdatanamesubsec^? \\ &&& \Bfieldnamesubsec^? \\ &&& - \Btagnamesubsec^? \\ + \Btagnamesubsec^? \\ &&& + \Bparamnamesubsec^? \\ \production{name subsection} & \Bnamesubsection_N(\B{B}) &::=& N{:}\Bbyte~~\X{size}{:}\Bu32~~\B{B} & (\iff \X{size} = ||\B{B}||) \\ @@ -77,6 +78,7 @@ Id Subsection 9 :ref:`data segment names ` 10 :ref:`field names ` 11 :ref:`tag names ` +12 :ref:`parameter names ` == =========================================== Each subsection may occur at most once, and in order of increasing id. @@ -306,6 +308,24 @@ It consists of a :ref:`name map ` assigning tag names to :ref:`t \end{array} +.. index:: parameter, parameter index +.. _binary-paramnamesec: + +Parameter Names +............... + +The *parameter name subsection* has the id 12. +It consists of an :ref:`indirect name map ` assigning parameter names to parameter :ref:`indices ` grouped by the :ref:`type indices ` of their respective :ref:`function types `. + +Note that this section only names parameters within :ref:`function types `, not :ref:`type uses `. Per-function parameter names are assigned in the :ref:`local name subsection `. + +.. math:: + \begin{array}{llclll} + \production{parameter name subsection} & \Bparamnamesubsec &::=& + \Bnamesubsection_{12}(\Bindirectnamemap) \\ + \end{array} + + .. index:: ! name annotation, name, Unicode UTF-8 .. _text-nameannot: diff --git a/document/core/util/macros.def b/document/core/util/macros.def index 730999870..4950fc4a4 100644 --- a/document/core/util/macros.def +++ b/document/core/util/macros.def @@ -1824,6 +1824,7 @@ .. |Bdatanamesubsec| mathdef:: \xref{appendix/custom}{binary-datanamesec}{\B{datanamesubsec}} .. |Bfieldnamesubsec| mathdef:: \xref{appendix/custom}{binary-fieldnamesec}{\B{fieldnamesubsec}} .. |Btagnamesubsec| mathdef:: \xref{appendix/custom}{binary-tagnamesec}{\B{tagnamesubsec}} +.. |Bparamnamesubsec| mathdef:: \xref{appendix/custom}{binary-paramnamesec}{\B{paramnamesubsec}} .. Annotations diff --git a/proposals/extended-name-section/Overview.md b/proposals/extended-name-section/Overview.md index c8b6c6971..9c5ecb0b0 100644 --- a/proposals/extended-name-section/Overview.md +++ b/proposals/extended-name-section/Overview.md @@ -18,6 +18,7 @@ The following new subsections are defined for the custom name section: | [global names](#global-names) | `7` | | [element segment names](#element-segment-names) | `8` | | [data segment names](#data-segment-names) | `9` | +| [parameter names](#parameter-names) | `12` | ### Label Names @@ -44,3 +45,9 @@ The *element segment name subsection* has the id 8. It consists of a [name map]( ### Data Segment Names The *data segment name subsection* has the id 9. It consists of a [name map](https://webassembly.github.io/spec/core/appendix/custom.html#binary-namemap) assigning data segment names to [data segment indices](https://webassembly.github.io/spec/core/binary/modules.html#binary-dataidx). + +### Parameter Names + +The *parameter name subsection* has the id 12. It consists of an [indirect name map](https://webassembly.github.io/spec/core/appendix/custom.html#binary-indirectnamemap) assigning parameter names to parameter indices grouped by [type indices](https://webassembly.github.io/spec/core/syntax/modules.html#syntax-typeidx). + +Note that this section assigns names to parameters in *function types*, not type uses (i.e. parameters written inline in function definitions or imports). Such parameters are already covered by the local name subsection. From cb2aec127dd044a69bfd8e1aad40aeec062b1e70 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Fri, 14 Aug 2026 17:36:20 -0500 Subject: [PATCH 2/2] Add tag parameter name subsection --- document/core/appendix/custom.rst | 26 +++++++++++++++++++-- document/core/util/macros.def | 1 + proposals/extended-name-section/Overview.md | 9 ++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/document/core/appendix/custom.rst b/document/core/appendix/custom.rst index 8e42bfe1d..9766a7b85 100644 --- a/document/core/appendix/custom.rst +++ b/document/core/appendix/custom.rst @@ -55,7 +55,8 @@ Each subsection consists of: \Bdatanamesubsec^? \\ &&& \Bfieldnamesubsec^? \\ &&& \Btagnamesubsec^? \\ &&& - \Bparamnamesubsec^? \\ + \Bparamnamesubsec^? \\ &&& + \Btagparamnamesubsec^? \\ \production{name subsection} & \Bnamesubsection_N(\B{B}) &::=& N{:}\Bbyte~~\X{size}{:}\Bu32~~\B{B} & (\iff \X{size} = ||\B{B}||) \\ @@ -79,6 +80,7 @@ Id Subsection 10 :ref:`field names ` 11 :ref:`tag names ` 12 :ref:`parameter names ` +13 :ref:`tag parameter names ` == =========================================== Each subsection may occur at most once, and in order of increasing id. @@ -157,6 +159,9 @@ Local Names The *local name subsection* has the id 2. It consists of an :ref:`indirect name map ` assigning local names to :ref:`local indices ` grouped by :ref:`function indices `. +.. note:: + This includes the function's parameters, and can therefore be used for both defined and imported functions. + .. math:: \begin{array}{llclll} \production{local name subsection} & \Blocalnamesubsec &::=& @@ -317,7 +322,8 @@ Parameter Names The *parameter name subsection* has the id 12. It consists of an :ref:`indirect name map ` assigning parameter names to parameter :ref:`indices ` grouped by the :ref:`type indices ` of their respective :ref:`function types `. -Note that this section only names parameters within :ref:`function types `, not :ref:`type uses `. Per-function parameter names are assigned in the :ref:`local name subsection `. +.. note:: + This section only applies to :ref:`function types `, not :ref:`type uses `. Per-function parameter names are assigned in the :ref:`local name subsection `, and per-tag parameter names are assigned in the :ref:`tag parameter name subsection `. .. math:: \begin{array}{llclll} @@ -326,6 +332,22 @@ Note that this section only names parameters within :ref:`function types ` assigning parameter names to tag parameter :ref:`indices ` grouped by their respective :ref:`tag indices `. + +.. math:: + \begin{array}{llclll} + \production{tag parameter name subsection} & \Btagparamnamesubsec &::=& + \Bnamesubsection_{13}(\Bindirectnamemap) \\ + \end{array} + + .. index:: ! name annotation, name, Unicode UTF-8 .. _text-nameannot: diff --git a/document/core/util/macros.def b/document/core/util/macros.def index 4950fc4a4..717cb83b8 100644 --- a/document/core/util/macros.def +++ b/document/core/util/macros.def @@ -1825,6 +1825,7 @@ .. |Bfieldnamesubsec| mathdef:: \xref{appendix/custom}{binary-fieldnamesec}{\B{fieldnamesubsec}} .. |Btagnamesubsec| mathdef:: \xref{appendix/custom}{binary-tagnamesec}{\B{tagnamesubsec}} .. |Bparamnamesubsec| mathdef:: \xref{appendix/custom}{binary-paramnamesec}{\B{paramnamesubsec}} +.. |Btagparamnamesubsec| mathdef:: \xref{appendix/custom}{binary-tagparamnamesec}{\B{tagparamnamesubsec}} .. Annotations diff --git a/proposals/extended-name-section/Overview.md b/proposals/extended-name-section/Overview.md index 9c5ecb0b0..e9a038654 100644 --- a/proposals/extended-name-section/Overview.md +++ b/proposals/extended-name-section/Overview.md @@ -19,6 +19,7 @@ The following new subsections are defined for the custom name section: | [element segment names](#element-segment-names) | `8` | | [data segment names](#data-segment-names) | `9` | | [parameter names](#parameter-names) | `12` | +| [tag parameter names](#tag-parameter-names) | `13` | ### Label Names @@ -48,6 +49,12 @@ The *data segment name subsection* has the id 9. It consists of a [name map](htt ### Parameter Names -The *parameter name subsection* has the id 12. It consists of an [indirect name map](https://webassembly.github.io/spec/core/appendix/custom.html#binary-indirectnamemap) assigning parameter names to parameter indices grouped by [type indices](https://webassembly.github.io/spec/core/syntax/modules.html#syntax-typeidx). +The *parameter name subsection* has the id 12. It consists of an [indirect name map](https://webassembly.github.io/spec/core/appendix/custom.html#binary-indirectnamemap) assigning parameter names to parameter indices grouped by [type indices](https://webassembly.github.io/spec/core/syntax/modules.html#syntax-typeidx) for function types. Note that this section assigns names to parameters in *function types*, not type uses (i.e. parameters written inline in function definitions or imports). Such parameters are already covered by the local name subsection. + +### Tag Parameter Names + +The *tag parameter name subsection* has the id 13. It consists of an [indirect name map](https://webassembly.github.io/spec/core/appendix/custom.html#binary-indirectnamemap) assigning parameter names to parameter indices grouped by [tag indices](https://webassembly.github.io/spec/core/syntax/modules.html#syntax-tagidx). + +This subsection exists because the names assigned to tag parameters belong to a type use, not a type definition, but because the type use is not associated with a function, the local name subsection cannot be used.