You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: document/core/valid/instructions.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1641,7 +1641,7 @@ Constant Expressions
1641
1641
}
1642
1642
1643
1643
.. note::
1644
-
Currently, constant expressions occurring as initializers of :ref:`globals <syntax-global>` are further constrained in that contained |GLOBALGET| instructions are only allowed to refer to *imported* globals.
1644
+
Currently, constant expressions occurring in :ref:`globals <syntax-global>`, :ref:`element <syntax-elem>`, or :ref:`data <syntax-data>` segments are further constrained in that contained |GLOBALGET| instructions are only allowed to refer to *imported* globals.
1645
1645
This is enforced in the :ref:`validation rule for modules <valid-module>` by constraining the context :math:`C` accordingly.
1646
1646
1647
1647
The definition of constant expression may be extended in future versions of WebAssembly.
Copy file name to clipboardExpand all lines: document/core/valid/modules.rst
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -546,40 +546,40 @@ Instead, the context :math:`C` for validation of the module's content is constru
546
546
547
547
* all other fields are empty.
548
548
549
-
* Under the context :math:`C`:
549
+
* For each :math:`\functype_i` in :math:`\module.\MTYPES`,
550
+
the :ref:`function type <syntax-functype>` :math:`\functype_i` must be :ref:`valid <valid-functype>`.
550
551
551
-
* For each :math:`\functype_i` in :math:`\module.\MTYPES`,
552
-
the :ref:`function type <syntax-functype>` :math:`\functype_i` must be :ref:`valid <valid-functype>`.
552
+
* Under the context :math:`C`:
553
553
554
554
* For each :math:`\func_i` in :math:`\module.\MFUNCS`,
555
555
the definition :math:`\func_i` must be :ref:`valid <valid-func>` with a :ref:`function type <syntax-functype>` :math:`\X{ft}_i`.
556
556
557
+
* If :math:`\module.\MSTART` is non-empty,
558
+
then :math:`\module.\MSTART` must be :ref:`valid <valid-start>`.
559
+
560
+
* For each :math:`\import_i` in :math:`\module.\MIMPORTS`,
561
+
the segment :math:`\import_i` must be :ref:`valid <valid-import>` with an :ref:`external type <syntax-externtype>` :math:`\X{it}_i`.
562
+
563
+
* For each :math:`\export_i` in :math:`\module.\MEXPORTS`,
564
+
the segment :math:`\export_i` must be :ref:`valid <valid-export>` with :ref:`external type <syntax-externtype>` :math:`\X{et}_i`.
565
+
566
+
* Under the context :math:`C'`:
567
+
557
568
* For each :math:`\table_i` in :math:`\module.\MTABLES`,
558
569
the definition :math:`\table_i` must be :ref:`valid <valid-table>` with a :ref:`table type <syntax-tabletype>` :math:`\X{tt}_i`.
559
570
560
571
* For each :math:`\mem_i` in :math:`\module.\MMEMS`,
561
572
the definition :math:`\mem_i` must be :ref:`valid <valid-mem>` with a :ref:`memory type <syntax-memtype>` :math:`\X{mt}_i`.
562
573
563
-
* For each :math:`\global_i` in :math:`\module.\MGLOBALS`:
564
-
565
-
* Under the context :math:`C'`,
566
-
the definition :math:`\global_i` must be :ref:`valid <valid-global>` with a :ref:`global type <syntax-globaltype>` :math:`\X{gt}_i`.
574
+
* For each :math:`\global_i` in :math:`\module.\MGLOBALS`,
575
+
the definition :math:`\global_i` must be :ref:`valid <valid-global>` with a :ref:`global type <syntax-globaltype>` :math:`\X{gt}_i`.
567
576
568
577
* For each :math:`\elem_i` in :math:`\module.\MELEMS`,
569
578
the segment :math:`\elem_i` must be :ref:`valid <valid-elem>` with :ref:`reference type <syntax-reftype>` :math:`\X{rt}_i`.
570
579
571
580
* For each :math:`\data_i` in :math:`\module.\MDATAS`,
572
581
the segment :math:`\data_i` must be :ref:`valid <valid-data>`.
573
582
574
-
* If :math:`\module.\MSTART` is non-empty,
575
-
then :math:`\module.\MSTART` must be :ref:`valid <valid-start>`.
576
-
577
-
* For each :math:`\import_i` in :math:`\module.\MIMPORTS`,
578
-
the segment :math:`\import_i` must be :ref:`valid <valid-import>` with an :ref:`external type <syntax-externtype>` :math:`\X{it}_i`.
579
-
580
-
* For each :math:`\export_i` in :math:`\module.\MEXPORTS`,
581
-
the segment :math:`\export_i` must be :ref:`valid <valid-export>` with :ref:`external type <syntax-externtype>` :math:`\X{et}_i`.
582
-
583
583
* The length of :math:`C.\CMEMS` must not be larger than :math:`1`.
584
584
585
585
* All export names :math:`\export_i.\ENAME` must be different.
@@ -607,15 +607,15 @@ Instead, the context :math:`C` for validation of the module's content is constru
607
607
\quad
608
608
(C \vdashfunc\func : \X{ft})^\ast
609
609
\quad
610
-
(C \vdashtable\table : \X{tt})^\ast
610
+
(C'\vdashtable\table : \X{tt})^\ast
611
611
\quad
612
-
(C \vdashmem\mem : \X{mt})^\ast
612
+
(C'\vdashmem\mem : \X{mt})^\ast
613
613
\quad
614
614
(C' \vdashglobal\global : \X{gt})^\ast
615
615
\\
616
-
(C \vdashelem\elem : \X{rt})^\ast
616
+
(C'\vdashelem\elem : \X{rt})^\ast
617
617
\quad
618
-
(C \vdashdata\data\ok)^n
618
+
(C'\vdashdata\data\ok)^n
619
619
\quad
620
620
(C \vdashstart\start\ok)^?
621
621
\quad
@@ -667,8 +667,8 @@ Instead, the context :math:`C` for validation of the module's content is constru
667
667
However, this recursion is just a specification device.
668
668
All types needed to construct :math:`C` can easily be determined from a simple pre-pass over the module that does not perform any actual validation.
669
669
670
-
Globals, however, are not recursive.
671
-
The effect of defining the limited context :math:`C'` for validating the module's globals is that their initialization expressions can only access functions and imported globals and nothing else.
670
+
Globals, however, are not recursive and not accessible within :ref:`constant expressions <valid-const>` when they are defined locally.
671
+
The effect of defining the limited context :math:`C'` for validating certain definitions is that they can only access functions and imported globals and nothing else.
672
672
673
673
.. note::
674
674
The restriction on the number of memories may be lifted in future versions of WebAssembly.
0 commit comments