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/exec/instructions.rst
+239Lines changed: 239 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -830,6 +830,245 @@ Memory Instructions
830
830
\end{array}
831
831
832
832
833
+
.. index:: table instruction, table index, store, frame, address, table address, table instance, function element, element address, element instance, value type
834
+
pair: execution; instruction
835
+
single: abstract syntax; instruction
836
+
.. _exec-instr-table:
837
+
838
+
Table Instructions
839
+
~~~~~~~~~~~~~~~~~~
840
+
841
+
.. _exec-table.init:
842
+
843
+
:math:`\TABLEINIT~x`
844
+
....................
845
+
846
+
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.
847
+
848
+
2. Assert: due to :ref:`validation <valid-table.init>`, :math:`F.\AMODULE.\MITABLES[0]` exists.
849
+
850
+
3. Let :math:`\X{ta}` be the :ref:`table address <syntax-tableaddr>` :math:`F.\AMODULE.\MITABLES[0]`.
851
+
852
+
4. Assert: due to :ref:`validation <valid-table.init>`, :math:`S.\STABLES[\X{ta}]` exists.
853
+
854
+
5. Let :math:`\X{table}` be the :ref:`table instance <syntax-tableinst>` :math:`S.\STABLES[\X{ta}]`.
855
+
856
+
6. Assert: due to :ref:`validation <valid-elem.init>`, :math:`F.\AMODULE.\MIELEMS[x]` exists.
857
+
858
+
7. Let :math:`\X{ea}` be the :ref:`element address <syntax-elemaddr>` :math:`F.\AMODULE.\MIELEMS[x]`.
859
+
860
+
8. Assert: due to :ref:`validation <valid-elem.init>`, :math:`S.\SELEM[\X{ea}]` exists.
861
+
862
+
9. Let :math:`\X{elem}^?` be the optional :ref:`element instance <syntax-eleminst>` :math:`S.\SELEM[\X{ea}]`.
863
+
864
+
10. If :math:`\X{elem}^? = \epsilon`, then:
865
+
866
+
a. Trap.
867
+
868
+
11. Assert: due to :ref:`validation <valid-table.init>`, a value of :ref:`value type <syntax-valtype>` |I32| is on the top of the stack.
869
+
870
+
12. Pop the value :math:`\I32.\CONST~n` from the stack.
871
+
872
+
13. Assert: due to :ref:`validation <valid-table.init>`, a value of :ref:`value type <syntax-valtype>` |I32| is on the top of the stack.
873
+
874
+
14. Pop the value :math:`\I32.\CONST~s` from the stack.
875
+
876
+
15. Assert: due to :ref:`validation <valid-table.init>`, a value of :ref:`value type <syntax-valtype>` |I32| is on the top of the stack.
877
+
878
+
16. Pop the value :math:`\I32.\CONST~d` from the stack.
879
+
880
+
17. If :math:`n` is :math:`0`, then:
881
+
882
+
a. If :math:`d` is larger than the length of :math:`\X{table}.\TIELEM`, then:
883
+
884
+
i. Trap.
885
+
886
+
b. If :math:`s` is larger than the length of :math:`\X{elem}.\EIINIT`, then:
887
+
888
+
i. Trap.
889
+
890
+
18. Else:
891
+
892
+
a. Push the value :math:`\I32.\CONST~d` to the stack.
893
+
894
+
b. Let :math:`\funcelem` be the :ref:`function element <syntax-funcelem>` :math:`\X{elem}.\EIINIT[s]`.
895
+
896
+
d. Execute the instruction :math:`\TABLESET~\funcelem`.
897
+
898
+
e. Push the value :math:`\I32.\CONST~(d+1)` to the stack.
899
+
900
+
f. Push the value :math:`\I32.\CONST~(s+1)` to the stack.
901
+
902
+
g. Push the value :math:`\I32.\CONST~(n-1)` to the stack.
Copy file name to clipboardExpand all lines: document/core/exec/runtime.rst
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -480,6 +480,8 @@ Conventions
480
480
.. _syntax-invoke:
481
481
.. _syntax-init_elem:
482
482
.. _syntax-init_data:
483
+
.. _syntax-table_get:
484
+
.. _syntax-table_set:
483
485
.. _syntax-instr-admin:
484
486
485
487
Administrative Instructions
@@ -498,6 +500,8 @@ In order to express the reduction of :ref:`traps <trap>`, :ref:`calls <syntax-ca
498
500
\INVOKE~\funcaddr \\ &&|&
499
501
\INITELEM~\tableaddr~\u32~\funcidx^\ast \\ &&|&
500
502
\INITDATA~\memaddr~\u32~\byte^\ast \\ &&|&
503
+
\TABLEGET \\ &&|&
504
+
\TABLESET \\ &&|&
501
505
\LABEL_n\{\instr^\ast\}~\instr^\ast~\END \\ &&|&
502
506
\FRAME_n\{\frame\}~\instr^\ast~\END \\
503
507
\end{array}
@@ -513,6 +517,11 @@ The |INITELEM| and |INITDATA| instructions perform initialization of :ref:`eleme
513
517
.. note::
514
518
The reason for splitting instantiation into individual reduction steps is to provide a semantics that is compatible with future extensions like threads.
515
519
520
+
The |TABLEGET| and |TABLESET| instructions are used to simplify the specification of the |TABLEINIT| and |TABLECOPY| instructions.
521
+
522
+
.. note::
523
+
In the future, |TABLEGET| and |TABLESET| may be provided as regular instructions.
524
+
516
525
The |LABEL| and |FRAME| instructions model :ref:`labels <syntax-label>` and :ref:`frames <syntax-frame>` :ref:`"on the stack" <exec-notation>`.
517
526
Moreover, the administrative syntax maintains the nesting structure of the original :ref:`structured control instruction <syntax-instr-control>` or :ref:`function body <syntax-func>` and their :ref:`instruction sequences <syntax-instr-seq>` with an |END| marker.
518
527
That way, the end of the inner instruction sequence is known when part of an outer sequence.
0 commit comments