fuel-specs
fuel-specs copied to clipboard
`$hp` is initialised to incorrect value.
At VM initialization it says:
$hp = VM_MAX_RAM - 1
: the heap area begins at the top and is empty to start.
It makes more sense for $hp
to be initialised to just VM_MAX_RAM
. It always essentially points to either non-addressable memory or previously allocated buffers (via ALOC
), both of which are essentially 'reserved'.
This change would avoid having to offset the value by 1 to use allocated memory, right?
Yep. Doing an aloc would be just:
let buf_addr = asm(size: size) {
aloc size;
hp: u64
}
...as per the discussion in https://github.com/FuelLabs/sway/pull/1627
@Voxelot is there general consensus to go forward with this change?
There is from the client-team side. @otrho also mentioned that the sway team could make a future-compatible workaround so that this change won't immediately break previously compiled code as well. But this workaround may not be needed if we do the change sooner.