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/intro/introduction.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ WebAssembly (abbreviated Wasm [#wasm]_) is a *safe, portable, low-level code for
5
5
designed for efficient execution and compact representation.
6
6
Its main goal is to enable high performance applications on the Web, but it does not make any Web-specific assumptions or provide Web-specific features, so it can be employed in other environments as well.
7
7
8
-
WebAssembly is an open standard developed by a `W3C Community Group <https://www.w3.org/community/webassembly/>`_ that includes representatives of all major browser vendors.
8
+
WebAssembly is an open standard developed by a `W3C Community Group <https://www.w3.org/community/webassembly/>`_.
9
9
10
10
This document describes version |release| of the :ref:`core <scope>` WebAssembly standard.
11
11
It is intended that it will be superseded by new incremental releases with additional features in the future.
Copy file name to clipboardExpand all lines: document/core/valid/conventions.rst
+7-11Lines changed: 7 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -40,14 +40,14 @@ which collects relevant information about the surrounding :ref:`module <syntax-m
40
40
* *Globals*: the list of globals declared in the current module, represented by their global type.
41
41
* *Locals*: the list of locals declared in the current function (including parameters), represented by their value type.
42
42
* *Labels*: the stack of labels accessible from the current position, represented by their result type.
43
-
* *Return*: the return type of the current function, represented as a result type.
43
+
* *Return*: the return type of the current function, represented as an optional result type that is absent when no return is allowed, as in free-standing expressions.
44
44
45
45
In other words, a context contains a sequence of suitable :ref:`types <syntax-type>` for each :ref:`index space <syntax-index>`,
46
46
describing each defined entry in that space.
47
47
Locals, labels and return type are only used for validating :ref:`instructions <syntax-instr>` in :ref:`function bodies <syntax-func>`, and are left empty elsewhere.
48
48
The label stack is the only part of the context that changes as validation of an instruction sequence proceeds.
49
49
50
-
It is convenient to define contexts as :ref:`records <notation-record>` :math:`C` with abstract syntax:
50
+
More concretely, contexts are defined as :ref:`records <notation-record>` :math:`C` with abstract syntax:
51
51
52
52
.. math::
53
53
\begin{array}{llll}
@@ -64,22 +64,18 @@ It is convenient to define contexts as :ref:`records <notation-record>` :math:`C
64
64
\end{array}
65
65
\end{array}
66
66
67
-
.. note::
68
-
The fields of a context are not defined as :ref:`vectors <syntax-vec>`,
69
-
since their lengths are not bounded by the maximum vector size.
67
+
.. _notation-extend:
70
68
71
-
In addition to field access :math:`C.\K{field}` the following notation is adopted for manipulating contexts:
69
+
In addition to field access written :math:`C.\K{field}` the following notation is adopted for manipulating contexts:
72
70
73
71
* When spelling out a context, empty fields are omitted.
74
72
75
73
* :math:`C,\K{field}\,A^\ast` denotes the same context as :math:`C` but with the elements :math:`A^\ast` prepended to its :math:`\K{field}` component sequence.
76
74
77
75
.. note::
78
-
This notation is defined to *prepend* not *append*.
79
-
It is only used in situations where the original :math:`C.\K{field}` is either empty
80
-
or :math:`\K{field}` is :math:`\K{labels}`.
81
-
In the latter case adding to the front is desired
82
-
because the :ref:`label index <syntax-labelidx>` space is indexed relatively, that is, in reverse order of addition.
76
+
We use :ref:`indexing notation <notation-index>` like :math:`C.\CLABELS[i]` to look up indices in their respective :ref:`index space <syntax-index>` in the context.
77
+
Context extension notation :math:`C,\K{field}\,A` is primarily used to locally extend *relative* index spaces, such as :ref:`label indices <syntax-labelidx>`.
78
+
Accordingly, the notation is defined to append at the *front* of the respective sequence, introducing a new relative index :math:`0` and shifting the existing ones.
Copy file name to clipboardExpand all lines: document/core/valid/instructions.rst
+22-6Lines changed: 22 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -314,7 +314,7 @@ Memory Instructions
314
314
315
315
* The memory :math:`C.\CMEMS[0]` must be defined in the context.
316
316
317
-
* The alignment :math:`2^{\memarg.\ALIGN}` must not be larger than the :ref:`width <syntax-valtype>` of :math:`t` divided by :math:`8`.
317
+
* The alignment :math:`2^{\memarg.\ALIGN}` must not be larger than the :ref:`bit width <syntax-valtype>` of :math:`t` divided by :math:`8`.
318
318
319
319
* Then the instruction is valid with type :math:`[\I32] \to [t]`.
320
320
@@ -354,7 +354,7 @@ Memory Instructions
354
354
355
355
* The memory :math:`C.\CMEMS[0]` must be defined in the context.
356
356
357
-
* The alignment :math:`2^{\memarg.\ALIGN}` must not be larger than the :ref:`width <syntax-valtype>` of :math:`t` divided by :math:`8`.
357
+
* The alignment :math:`2^{\memarg.\ALIGN}` must not be larger than the :ref:`bit width <syntax-valtype>` of :math:`t` divided by :math:`8`.
358
358
359
359
* Then the instruction is valid with type :math:`[\I32~t] \to []`.
360
360
@@ -483,6 +483,8 @@ Control Instructions
483
483
}
484
484
485
485
.. note::
486
+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
487
+
486
488
The fact that the nested instruction sequence :math:`\instr^\ast` must have type :math:`[] \to [t^?]` implies that it cannot access operands that have been pushed on the stack before the block was entered.
487
489
This may be generalized in future versions of WebAssembly.
488
490
@@ -507,6 +509,8 @@ Control Instructions
507
509
}
508
510
509
511
.. note::
512
+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
513
+
510
514
The fact that the nested instruction sequence :math:`\instr^\ast` must have type :math:`[] \to [t^?]` implies that it cannot access operands that have been pushed on the stack before the loop was entered.
511
515
This may be generalized in future versions of WebAssembly.
512
516
@@ -536,6 +540,8 @@ Control Instructions
536
540
}
537
541
538
542
.. note::
543
+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
544
+
539
545
The fact that the nested instruction sequence :math:`\instr^\ast` must have type :math:`[] \to [t^?]` implies that it cannot access operands that have been pushed on the stack before the conditional was entered.
540
546
This may be generalized in future versions of WebAssembly.
541
547
@@ -559,6 +565,8 @@ Control Instructions
559
565
}
560
566
561
567
.. note::
568
+
The :ref:`label index <syntax-labelidx>` space in the :ref:`context <context>` :math:`C` contains the most recent label first, so that :math:`C.\CLABELS[l]` performs a relative lookup as expected.
569
+
562
570
The |BR| instruction is :ref:`stack-polymorphic <polymorphism>`.
563
571
564
572
@@ -580,6 +588,9 @@ Control Instructions
580
588
C \vdashinstr\BRIF~l : [t^?~\I32] \to [t^?]
581
589
}
582
590
591
+
.. note::
592
+
The :ref:`label index <syntax-labelidx>` space in the :ref:`context <context>` :math:`C` contains the most recent label first, so that :math:`C.\CLABELS[l]` performs a relative lookup as expected.
593
+
583
594
584
595
.. _valid-br_table:
585
596
@@ -608,6 +619,8 @@ Control Instructions
608
619
}
609
620
610
621
.. note::
622
+
The :ref:`label index <syntax-labelidx>` space in the :ref:`context <context>` :math:`C` contains the most recent label first, so that :math:`C.\CLABELS[l_i]` performs a relative lookup as expected.
623
+
611
624
The |BRTABLE| instruction is :ref:`stack-polymorphic <polymorphism>`.
612
625
613
626
@@ -616,7 +629,7 @@ Control Instructions
616
629
:math:`\RETURN`
617
630
...............
618
631
619
-
* The return type :math:`C.\CRETURN` must not be empty in the context.
632
+
* The return type :math:`C.\CRETURN` must not be absent in the context.
620
633
621
634
* Let :math:`[t^?]` be the :ref:`result type <syntax-resulttype>` of :math:`C.\CRETURN`.
622
635
@@ -632,8 +645,8 @@ Control Instructions
632
645
.. note::
633
646
The |RETURN| instruction is :ref:`stack-polymorphic <polymorphism>`.
634
647
635
-
:math:`C.\CRETURN` is empty (:math:`\epsilon`) when validating an :ref:`expression <valid-expr>` that is not a function body.
636
-
This differs from it being set to the empty result type (:math:`[]`),
648
+
:math:`C.\CRETURN` is absent (set to :math:`\epsilon`) when validating an :ref:`expression <valid-expr>` that is not a function body.
649
+
This differs from it being set to the empty result type (:math:`[\epsilon]`),
637
650
which is the case for functions not returning anything.
638
651
639
652
@@ -773,7 +786,7 @@ Constant Expressions
773
786
\frac{
774
787
(C \vdashinstrconst\instr\const)^\ast
775
788
}{
776
-
C \vdashexprconst\instr~\END\const
789
+
C \vdashexprconst\instr^\ast~\END\const
777
790
}
778
791
779
792
.. math::
@@ -789,4 +802,7 @@ Constant Expressions
789
802
}
790
803
791
804
.. note::
805
+
Currently, constant expressions occurring as initializers of :ref:`globals <syntax-global>` are further constrained in that contained |GETGLOBAL| instructions are only allowed to refer to *imported* globals.
806
+
This is enforced in the :ref:`validation rule for modules <valid-module>` by constraining the context :math:`C` accordingly.
807
+
792
808
The definition of constant expression may be extended in future versions of WebAssembly.
0 commit comments