Skip to content

Commit

Permalink
[spec/interpreter] Rename elem/data.drop; update README; reorder (Web…
Browse files Browse the repository at this point in the history
…Assembly#75)

* Rename elem/data.drop
* Reorder bulk instructions
* Rename interpreter AST ref constructors to match reftype repo
* Update interpreter README
  • Loading branch information
rossberg authored Mar 30, 2019
1 parent c2cd260 commit 726d7ec
Show file tree
Hide file tree
Showing 16 changed files with 371 additions and 362 deletions.
48 changes: 24 additions & 24 deletions document/core/binary/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,27 @@ Variable Instructions
\end{array}
Table Instructions
~~~~~~~~~~~~~~~~~~

Each variant of :ref:`table instruction <syntax-instr-table>` is encoded with a different byte code.

.. _binary-table.copy:
.. _binary-table.init:
.. _binary-elem.drop:

.. math::
\begin{array}{llclll}
\production{instruction} & \Binstr &::=& \dots \\ &&|&
\hex{FC}~\hex{0C}~~\hex{00}~x{:}\Belemidx &\Rightarrow& \TABLEINIT~x \\ &&|&
\hex{FC}~\hex{0D}~~x{:}\Belemidx &\Rightarrow& \ELEMDROP~x \\ &&|&
\hex{FC}~\hex{0E}~~\hex{00}~~\hex{00} &\Rightarrow& \TABLECOPY \\
\end{array}
.. note::
In future versions of WebAssembly, the additional zero bytes occurring in the encoding of the |TABLECOPY| instruction may be used to index additional tables.


.. index:: memory instruction, memory index
pair: binary format; instruction
.. _binary-instr-memory:
Expand All @@ -126,10 +147,10 @@ Each variant of :ref:`memory instruction <syntax-instr-memory>` is encoded with
.. _binary-storen:
.. _binary-memory.size:
.. _binary-memory.grow:
.. _binary-memory.init:
.. _binary-memory.drop:
.. _binary-memory.copy:
.. _binary-memory.fill:
.. _binary-memory.copy:
.. _binary-memory.init:
.. _binary-data.drop:

.. math::
\begin{array}{llclll}
Expand Down Expand Up @@ -171,27 +192,6 @@ Each variant of :ref:`memory instruction <syntax-instr-memory>` is encoded with
In future versions of WebAssembly, the additional zero bytes occurring in the encoding of the |MEMORYSIZE|, |MEMORYGROW|, |MEMORYCOPY|, and |MEMORYFILL| instructions may be used to index additional memories.


Table Instructions
~~~~~~~~~~~~~~~~~~

Each variant of :ref:`table instruction <syntax-instr-table>` is encoded with a different byte code.

.. _binary-table.init:
.. _binary-table.drop:
.. _binary-table.copy:

.. math::
\begin{array}{llclll}
\production{instruction} & \Binstr &::=& \dots \\ &&|&
\hex{FC}~\hex{0C}~~\hex{00}~x{:}\Belemidx &\Rightarrow& \TABLEINIT~x \\ &&|&
\hex{FC}~\hex{0D}~~x{:}\Belemidx &\Rightarrow& \TABLEDROP~x \\ &&|&
\hex{FC}~\hex{0E}~~\hex{00}~~\hex{00} &\Rightarrow& \TABLECOPY \\
\end{array}
.. note::
In future versions of WebAssembly, the additional zero bytes occurring in the encoding of the |TABLECOPY| instruction may be used to index additional tables.


.. index:: numeric instruction
pair: binary format; instruction
.. _binary-instr-numeric:
Expand Down
68 changes: 34 additions & 34 deletions document/core/syntax/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,34 @@ These instructions get or set the values of variables, respectively.
The |LOCALTEE| instruction is like |LOCALSET| but also returns its argument.


.. index:: ! table instruction, table, table index
pair: abstract syntax; instruction
.. _syntax-instr-table:

Table Instructions
~~~~~~~~~~~~~~~~~~

Instructions in this group are concerned with tables :ref:`table <syntax-table>`.

.. math::
\begin{array}{llcl}
\production{instruction} & \instr &::=&
\dots \\&&|&
\TABLECOPY \\&&|&
\TABLEINIT~\elemidx \\&&|&
\ELEMDROP~\elemidx \\
\end{array}
The |TABLECOPY| instruction copies elements from a source table region to a possibly overlapping destination region.
The |TABLEINIT| instruction copies elements from a :ref:`passive element segment <syntax-elem>` into a table.
The |ELEMDROP| instruction prevents further use of a passive element segment. This instruction is intended to be used as an optimization hint. After an element segment is dropped its elements can no longer be retrieved, so the memory used by this segment may be freed.

.. note::
In the current version of WebAssembly,
all table instructions implicitly operate on :ref:`table <syntax-table>` :ref:`index <syntax-tableidx>` :math:`0`.
This restriction may be lifted in future versions.


.. index:: ! memory instruction, memory, memory index, page size, little endian, trap
pair: abstract syntax; instruction
.. _syntax-loadn:
Expand Down Expand Up @@ -243,10 +271,10 @@ Instructions in this group are concerned with linear :ref:`memory <syntax-mem>`.
\K{i64.}\STORE\K{32}~\memarg \\&&|&
\MEMORYSIZE \\&&|&
\MEMORYGROW \\&&|&
\MEMORYINIT~\dataidx \\&&|&
\MEMORYDROP~\dataidx \\&&|&
\MEMORYFILL \\&&|&
\MEMORYCOPY \\&&|&
\MEMORYFILL \\
\MEMORYINIT~\dataidx \\&&|&
\DATADROP~\dataidx \\
\end{array}
Memory is accessed with |LOAD| and |STORE| instructions for the different :ref:`value types <syntax-valtype>`.
Expand All @@ -265,45 +293,17 @@ The |MEMORYSIZE| instruction returns the current size of a memory.
The |MEMORYGROW| instruction grows memory by a given delta and returns the previous size, or :math:`-1` if enough memory cannot be allocated.
Both instructions operate in units of :ref:`page size <page-size>`.

The |MEMORYINIT| instruction copies data from a :ref:`passive data segment <syntax-data>` into a memory.
The |MEMORYDROP| instruction prevents further use of a passive data segment. This instruction is intended to be used as an optimization hint. After a data segment is dropped its data can no longer be retrieved, so the memory used by this segment may be freed.
The |MEMORYCOPY| instruction copies data from a source memory region to a possibly overlapping destination region.
The |MEMORYFILL| instruction sets all values in a region to a given byte.
The |MEMORYCOPY| instruction copies data from a source memory region to a possibly overlapping destination region.
The |MEMORYINIT| instruction copies data from a :ref:`passive data segment <syntax-data>` into a memory.
The |DATADROP| instruction prevents further use of a passive data segment. This instruction is intended to be used as an optimization hint. After a data segment is dropped its data can no longer be retrieved, so the memory used by this segment may be freed.

.. note::
In the current version of WebAssembly,
all memory instructions implicitly operate on :ref:`memory <syntax-mem>` :ref:`index <syntax-memidx>` :math:`0`.
This restriction may be lifted in future versions.


.. index:: ! table instruction, table, table index
pair: abstract syntax; instruction
.. _syntax-instr-table:

Table Instructions
~~~~~~~~~~~~~~~~~~

Instructions in this group are concerned with tables :ref:`table <syntax-table>`.

.. math::
\begin{array}{llcl}
\production{instruction} & \instr &::=&
\dots \\&&|&
\TABLEINIT~\elemidx \\&&|&
\TABLEDROP~\elemidx \\&&|&
\TABLECOPY \\
\end{array}
The |TABLEINIT| instruction copies elements from a :ref:`passive element segment <syntax-elem>` into a table.
The |TABLEDROP| instruction prevents further use of a passive element segment. This instruction is intended to be used as an optimization hint. After an element segment is dropped its elements can no longer be retrieved, so the memory used by this segment may be freed.
The |TABLECOPY| instruction copies elements from a source table region to a possibly overlapping destination region.

.. note::
In the current version of WebAssembly,
all table instructions implicitly operate on :ref:`table <syntax-table>` :ref:`index <syntax-tableidx>` :math:`0`.
This restriction may be lifted in future versions.


.. index:: ! control instruction, ! structured control, ! label, ! block, ! branch, ! unwinding, result type, label index, function index, type index, vector, trap, function, table, function type
pair: abstract syntax; instruction
.. _syntax-nop:
Expand Down
44 changes: 22 additions & 22 deletions document/core/text/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ Variable Instructions
\end{array}
Table Instructions
~~~~~~~~~~~~~~~~~~

.. _text-table.copy:
.. _text-table.init:
.. _text-elem.drop:

.. math::
\begin{array}{llcllll}
\production{instruction} & \Tplaininstr_I &::=& \dots \\ &&|&
\text{table.copy} &\Rightarrow& \TABLECOPY \\ &&|&
\text{table.init}~~x{:}\Telemidx_I &\Rightarrow& \TABLEINIT~x \\ &&|&
\text{elem.drop}~~x{:}\Telemidx_I &\Rightarrow& \ELEMDROP~x \\
\end{array}
.. index:: memory instruction, memory index
pair: text format; instruction
.. _text-instr-memory:
Expand All @@ -175,10 +191,10 @@ Memory Instructions
.. _text-storen:
.. _text-memory.size:
.. _text-memory.grow:
.. _text-memory.init:
.. _text-memory.drop:
.. _text-memory.copy:
.. _text-memory.fill:
.. _text-memory.copy:
.. _text-memory.init:
.. _text-data.drop:

The offset and alignment immediates to memory instructions are optional.
The offset defaults to :math:`\T{0}`, the alignment to the storage size of the respective memory access, which is its *natural alignment*.
Expand Down Expand Up @@ -220,26 +236,10 @@ Lexically, an |Toffset| or |Talign| phrase is considered a single :ref:`keyword
\text{i64.store32}~~m{:}\Tmemarg_4 &\Rightarrow& \I64.\STORE\K{32}~m \\ &&|&
\text{memory.size} &\Rightarrow& \MEMORYSIZE \\ &&|&
\text{memory.grow} &\Rightarrow& \MEMORYGROW \\ &&|&
\text{memory.init}~~x{:}\Tdataidx_I &\Rightarrow& \MEMORYINIT~x \\ &&|&
\text{memory.drop}~~x{:}\Tdataidx_I &\Rightarrow& \MEMORYDROP~x \\ &&|&
\text{memory.fill} &\Rightarrow& \MEMORYFILL \\ &&|&
\text{memory.copy} &\Rightarrow& \MEMORYCOPY \\ &&|&
\text{memory.fill} &\Rightarrow& \MEMORYFILL \\
\end{array}
Table Instructions
~~~~~~~~~~~~~~~~~~

.. _text-table.init:
.. _text-table.drop:
.. _text-table.copy:

.. math::
\begin{array}{llcllll}
\production{instruction} & \Tplaininstr_I &::=& \dots \\ &&|&
\text{table.init}~~x{:}\Telemidx_I &\Rightarrow& \TABLEINIT~x \\ &&|&
\text{table.drop}~~x{:}\Telemidx_I &\Rightarrow& \TABLEDROP~x \\ &&|&
\text{table.copy} &\Rightarrow& \TABLECOPY \\
\text{memory.init}~~x{:}\Tdataidx_I &\Rightarrow& \MEMORYINIT~x \\ &&|&
\text{data.drop}~~x{:}\Tdataidx_I &\Rightarrow& \DATADROP~x \\
\end{array}
Expand Down
14 changes: 7 additions & 7 deletions document/core/util/macros.def
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,18 @@
.. |GLOBALGET| mathdef:: \xref{syntax/instructions}{syntax-instr-variable}{\K{global.get}}
.. |GLOBALSET| mathdef:: \xref{syntax/instructions}{syntax-instr-variable}{\K{global.set}}

.. |TABLECOPY| mathdef:: \xref{syntax/instructions}{syntax-instr-table}{\K{table.copy}}
.. |TABLEINIT| mathdef:: \xref{syntax/instructions}{syntax-instr-table}{\K{table.init}}
.. |ELEMDROP| mathdef:: \xref{syntax/instructions}{syntax-instr-table}{\K{elem.drop}}

.. |LOAD| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{load}}
.. |STORE| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{store}}
.. |MEMORYSIZE| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{memory.size}}
.. |MEMORYGROW| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{memory.grow}}
.. |MEMORYINIT| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{memory.init}}
.. |MEMORYDROP| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{memory.drop}}
.. |MEMORYCOPY| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{memory.copy}}
.. |MEMORYFILL| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{memory.fill}}

.. |TABLEINIT| mathdef:: \xref{syntax/instructions}{syntax-instr-table}{\K{table.init}}
.. |TABLEDROP| mathdef:: \xref{syntax/instructions}{syntax-instr-table}{\K{table.drop}}
.. |TABLECOPY| mathdef:: \xref{syntax/instructions}{syntax-instr-table}{\K{table.copy}}
.. |MEMORYCOPY| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{memory.copy}}
.. |MEMORYINIT| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{memory.init}}
.. |DATADROP| mathdef:: \xref{syntax/instructions}{syntax-instr-memory}{\K{data.drop}}

.. |CONST| mathdef:: \xref{syntax/instructions}{syntax-instr-numeric}{\K{const}}
.. |EQZ| mathdef:: \xref{syntax/instructions}{syntax-instr-numeric}{\K{eqz}}
Expand Down
Loading

0 comments on commit 726d7ec

Please sign in to comment.