evmone icon indicating copy to clipboard operation
evmone copied to clipboard

Optimize store to memory

Open chfast opened this issue 2 years ago • 1 comments

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.

chfast avatar May 13 '23 10:05 chfast

Some experiments https://godbolt.org/z/veKMKs63x.

chfast avatar May 15 '23 08:05 chfast