Merge pull request #9162 from ethereum/memoryEscalator

Memory Escalator
This commit is contained in:
Daniel Kirchner
2020-09-21 20:03:38 +02:00
committed by GitHub
56 changed files with 2389 additions and 66 deletions
+20
View File
@@ -952,6 +952,26 @@ option.
See :ref:`Using the Commandline Compiler <commandline-compiler>` for details about the Solidity linker.
memoryguard
^^^^^^^^^^^
This function is available in the EVM dialect with objects. The caller of
``let ptr := memoryguard(size)`` (where ``size`` has to be a literal number)
promises that they only use memory in either the range ``[0, size)`` or the
unbounded range starting at ``ptr``.
Since the presence of a ``memoryguard`` call indicates that all memory access
adheres to this restriction, it allows the optimizer to perform additional
optimization steps, for example the stack limit evader, which attempts to move
stack variables that would otherwise be unreachable to memory.
The Yul optimizer promises to only use the memory range ``[size, ptr)`` for its purposes.
If the optimizer does not need to reserve any memory, it holds that ``ptr == size``.
``memoryguard`` can be called multiple times, but needs to have the same literal as argument
within one Yul subobject. If at least one ``memoryguard`` call is found in a subobject,
the additional optimiser steps will be run on it.
.. _yul-object: