Skip to content

VM v2 wishlist (breaking changes) #629

@Dentosal

Description

@Dentosal

This issue is used to track of things I'd like to consider for a new iteration of the vm, if we ever do one.

  • Remove useless instructions. For instance GT is just LT with arguments swapped.
  • Variable length instructions. At least, loading a full u64 immediate would be great to have.
  • Condition flags, like x86 has. Eases register pressure and makes code more compact. Allows multiple comparisons using a single instruction. Reduces number of instructions, when they can just pattern-match against the flags. For instance jcc and movcc instructions would be quite nice.
  • Addressing modes inside instructions, again like x86. Immediate, register, indirect and maybe double-indirect addressing as well?
  • Allocation-based memory management instead of a single global memory space. This would allow things like
    • Callee-allocated buffers that can be freed by the caller -> remove the $hp register
    • Callee-allocated local stack -> remove the $ssp and $sp registers.
    • Clear and simple memory r/w/x permissions, possibility to change them during calls as well
    • On-demand memory-mapped areas, for instance the storage slots
  • Remove $of. It makes arithmetic instructions needlessly expensive, as it's almost never read. Make the overflow possible to compute using normal instructions if needed.
  • Stop using full call frames, and instead only push return address. Use registers to pass in arguments using a defined call convention.
  • Remove $ret and $retl. Use registers to for return values using a defined call convention.
  • Remove $cgas. It's rather useless and prone to making contracts uncallable if we change gas costs
  • Get rid of the $flags and handle that on instruction level.

Further, simply consider using something like risc-v instruction set directly. Do blockchain-specific operations using ecall. This would allow using Rust directly instead of Sway, as well.

Metadata

Metadata

Assignees

Labels

comp:FVMComponent: FuelVM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions