mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Change capitalisation
This commit is contained in:
parent
ac799aff0e
commit
02a72871d2
@ -61,7 +61,7 @@ It depends on the compiler (see below) how to actually resolve the paths.
|
|||||||
In general, the directory hierarchy does not need to strictly map onto your local
|
In general, the directory hierarchy does not need to strictly map onto your local
|
||||||
filesystem, it can also map to resources discovered via e.g. ipfs, http or git.
|
filesystem, it can also map to resources discovered via e.g. ipfs, http or git.
|
||||||
|
|
||||||
Use in actual Compilers
|
Use in Actual Compilers
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
When the compiler is invoked, it is not only possible to specify how to
|
When the compiler is invoked, it is not only possible to specify how to
|
||||||
|
@ -66,7 +66,7 @@ Calling ``select(false, x)`` will compute ``x * x`` and ``select(true, x)`` will
|
|||||||
.. index:: optimizer, common subexpression elimination, constant propagation
|
.. 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.
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user