aboutsummaryrefslogtreecommitdiffstats
path: root/docs/miscellaneous.rst
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-25 03:15:07 +0800
committerGitHub <noreply@github.com>2016-08-25 03:15:07 +0800
commit9fc1bcb2becf48192e5c52d6af1fac2b88656f2d (patch)
tree85087d05bfb5955cee0804b5d2c093c9b6ea127d /docs/miscellaneous.rst
parentd5e4b7492ebf28182d71e2bbc9aece24e4e16182 (diff)
parentef117c29021c31bc7f9c3e0b9797b72538591199 (diff)
downloaddexon-solidity-9fc1bcb2becf48192e5c52d6af1fac2b88656f2d.tar.gz
dexon-solidity-9fc1bcb2becf48192e5c52d6af1fac2b88656f2d.tar.zst
dexon-solidity-9fc1bcb2becf48192e5c52d6af1fac2b88656f2d.zip
Merge pull request #945 from Denton-L/fix-documentation
Minor corrections to documentation
Diffstat (limited to 'docs/miscellaneous.rst')
-rw-r--r--docs/miscellaneous.rst2
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index 804d69ef..882a6002 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -66,7 +66,7 @@ Calling ``select(false, x)`` will compute ``x * x`` and ``select(true, x)`` will
.. index:: optimizer, common subexpression elimination, constant propagation
*************************
-Internals - the Optimizer
+Internals - The Optimizer
*************************
The Solidity optimizer operates on assembly, so it can be and also is used by other languages. It splits the sequence of instructions into basic blocks at JUMPs and JUMPDESTs. Inside these blocks, the instructions are analysed and every modification to the stack, to memory or storage is recorded as an expression which consists of an instruction and a list of arguments which are essentially pointers to other expressions. The main idea is now to find expressions that are always equal (on every input) and combine them into an expression class. The optimizer first tries to find each new expression in a list of already known expressions. If this does not work, the expression is simplified according to rules like ``constant + constant = sum_of_constants`` or ``X * 1 = X``. Since this is done recursively, we can also apply the latter rule if the second factor is a more complex expression where we know that it will always evaluate to one. Modifications to storage and memory locations have to erase knowledge about storage and memory locations which are not known to be different: If we first write to location x and then to location y and both are input variables, the second could overwrite the first, so we actually do not know what is stored at x after we wrote to y. On the other hand, if a simplification of the expression x - y evaluates to a non-zero constant, we know that we can keep our knowledge about what is stored at x.