evmone icon indicating copy to clipboard operation
evmone copied to clipboard

Optimize the "dispatch table"

Open chfast opened this issue 5 years ago • 0 comments

Currently, in the analysis phase we prepare a table where for each instruction in the code we store:

  • pointer to function implementing the instruction (8 bytes)
  • optional imminent value (4 bytes)
  • block index (4 bytes)

Issues:

  1. The imminent value slot is only used by some instructions.
  2. Moreover, 4 bytes is not enough for some instructions as imminent value, then it is an index in an additional memory where the bigger value is stored.
  3. Block index is only used for the first instructions in blocks, so usually not used.

Proposed changes:

  1. Place the optional imminent values after the pointer to the instruction function, as many of 8 byte multiplies as required. The instruction implementation is responsible for moving the next instruction pointer (PC) after the imminent value.
  2. Instead of string block index for every instruction, insert "BLOCK_START" virtual instruction that will check block before processing with the execution.

chfast avatar Jun 21 '19 14:06 chfast