evmone
evmone copied to clipboard
Optimize the "dispatch table"
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:
- The imminent value slot is only used by some instructions.
- 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.
- Block index is only used for the first instructions in blocks, so usually not used.
Proposed changes:
- 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.
- Instead of string block index for every instruction, insert "BLOCK_START" virtual instruction that will check block before processing with the execution.