evmone
evmone copied to clipboard
Optimize store to memory
During EVM memory expansion the new region of memory is filled with zeros. This is inefficient in case of storing to memory because the region will be overwritten with new data.
This affects:
-
MSTORE -
MSTORE8 - one part of
MCOPY -
CALLDATACOPY -
CODECOPY -
EXTCODECOPY -
RETURNDATACOPY - call instructions with output data parameters (but be careful because in case the callee returns smaller buffer the remaining region must be filled with zeros).
We can start with writing a prototype ideal MSTORE without using helper. Then we can try to extract and reuse some helpers.
Some experiments https://godbolt.org/z/veKMKs63x.