Skip to content

Commit

Permalink
Fix exception allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Nov 22, 2024
1 parent 90cbd50 commit d1bf45a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
16 changes: 9 additions & 7 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4226,25 +4226,27 @@ Control Instructions

2. Assert: due to :ref:`validation <valid-throw>`, :math:`F.\AMODULE.\MITAGS[x]` exists.

3. Let :math:`ta` be the :ref:`tag address <syntax-tagaddr>` :math:`F.\AMODULE.\MITAGS[x]`.
3. Let :math:`\X{ta}` be the :ref:`tag address <syntax-tagaddr>` :math:`F.\AMODULE.\MITAGS[x]`.

4. Assert: due to :ref:`validation <valid-throw>`, :math:`S.\STAGS[ta]` exists.
4. Assert: due to :ref:`validation <valid-throw>`, :math:`S.\STAGS[\X{ta}]` exists.

5. Let :math:`\X{ti}` be the :ref:`tag instance <syntax-taginst>` :math:`S.\STAGS[ta]`.
5. Let :math:`\X{ti}` be the :ref:`tag instance <syntax-taginst>` :math:`S.\STAGS[\X{ta}]`.

6. Let :math:`[t^n] \toF [{t'}^\ast]` be the :ref:`tag type <syntax-tagtype>` :math:`\X{ti}.\TAGITYPE`.

7. Assert: due to :ref:`validation <valid-throw>`, there are at least :math:`n` values on the top of the stack.

8. Pop the :math:`n` values :math:`\val^n` from the stack.

9. Let :math:`\X{ea}` be the :ref:`exception address <syntax-exnaddr>` resulting from :ref:`allocating <alloc-exception>` an exception instance with tag address :math:`ta` and initializer values :math:`\val^n`.
9. Let :math:`\X{exn}` be the :ref:`exception instance <syntax-exninst>` :math:`\{\EITAG~\X{ta}, \EIFIELDS~\val^n\}`.

10. Let :math:`\X{exn}` be :math:`S.\SEXNS[ea]`
10. Let :math:`\X{ea}` be the length of :math:`S.\SEXNS`.

11. Push the value :math:`\REFEXNADDR~\X{ea}` to the stack.
11. Append :math:`\X{exn}` to :math:`S.\SEXNS`.

12. Execute the instruction |THROWREF|.
12. Push the value :math:`\REFEXNADDR~\X{ea}` to the stack.

13. Execute the instruction |THROWREF|.

.. math::
~\\[-1ex]
Expand Down
26 changes: 0 additions & 26 deletions document/core/exec/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,32 +170,6 @@ are *allocated* in a :ref:`store <syntax-store>` :math:`S`, as defined by the fo
\end{array}
.. index:: exception, exception instance, exception address, tag address
.. _alloc-exception:

:ref:`Exceptions <syntax-exninst>`
..................................

1. Let :math:`ta` be the :ref:`tag address <syntax-tagaddr>` associated with the exception to allocate and :math:`\EIFIELDS~\val^\ast` be the values to initialize the exception with.

2. Let :math:`a` be the first free :ref:`exception address <syntax-exnaddr>` in :math:`S`.

3. Let :math:`\exninst` be the :ref:`exception instance <syntax-exninst>` :math:`\{ \EITAG~ta, \EIFIELDS~\val^\ast \}`.

4. Append :math:`\exninst` to the |SEXNS| of :math:`S`.

5. Return :math:`a`.

.. math::
\begin{array}{rlll}
\allocexn(S, \tagaddr, \val^\ast) &=& S', \exnaddr \\[1ex]
\mbox{where:} \hfill \\
\exnaddr &=& |S.\SEXNS| \\
\exninst &=& \{ \EITAG~\tagaddr, \EIFIELDS~\val^\ast \} \\
S' &=& S \compose \{\SEXNS~\exninst\} \\
\end{array}
.. index:: global, global instance, global address, global type, value type, mutability, value
.. _alloc-global:

Expand Down
2 changes: 0 additions & 2 deletions document/core/util/macros.def
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,6 @@
.. |allocdata| mathdef:: \xref{exec/modules}{alloc-data}{\F{allocdata}}
.. |allocmodule| mathdef:: \xref{exec/modules}{alloc-module}{\F{allocmodule}}

.. |allocexn| mathdef:: \xref{exec/modules}{alloc-exception}{\F{allocexn}}

.. |growtable| mathdef:: \xref{exec/modules}{grow-table}{\F{growtable}}
.. |growmem| mathdef:: \xref{exec/modules}{grow-mem}{\F{growmem}}

Expand Down

0 comments on commit d1bf45a

Please sign in to comment.