Skip to content

Commit

Permalink
Make $hp point to the first available byte, instead of the one before…
Browse files Browse the repository at this point in the history
  • Loading branch information
Dentosal committed Mar 10, 2023
1 parent 884701a commit 2821d15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/vm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ Whenever memory is written to (i.e. with [`SB`](./instruction_set.md#sb-store-by
If the context is external, the owned memory range is:

1. `[$ssp, $sp)`: the writable stack area.
1. `($hp - 1, VM_MAX_RAM - 1]`: the heap area allocated by this script or predicate.
1. `[$hp, VM_MAX_RAM)`: the heap area allocated by this script or predicate.

If the context is internal, the owned memory range for a call frame is:

1. `[$ssp, $sp)`: the writable stack area of the call frame.
1. `($hp - 1, $fp->$hp - 1]`: the heap area allocated by this call frame.
1. `[$hp, $fp->$hp)`: the heap area allocated by this call frame.
8 changes: 4 additions & 4 deletions src/vm/instruction_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,8 @@ All these instructions advance the program counter `$pc` by `4` after performing

Panic if:

- `$hp - $rA - 1` underflows
- `$hp - $rA - 1 < $sp`
- `$hp - $rA` underflows
- `$hp - $rA < $sp`

### CFEI: Extend call frame immediate

Expand All @@ -820,7 +820,7 @@ Panic if:
Panic if:

- `$sp + imm` overflows
- `$sp + imm > $hp - 1`
- `$sp + imm > $hp`

### CFSI: Shrink call frame immediate

Expand Down Expand Up @@ -1224,7 +1224,7 @@ Panic if:
- `$rA + 32` overflows
- `$ssp + $rC > VM_MAX_RAM`
- `$rA + 32 > VM_MAX_RAM`
- `$ssp + $rC > $hp - 1`
- `$ssp + $rC >= $hp`
- `$rC > CONTRACT_MAX_SIZE`
- `$rC > MEM_MAX_ACCESS_SIZE`
- Contract with ID `MEM[$rA, 32]` is not in `tx.inputs`
Expand Down

0 comments on commit 2821d15

Please sign in to comment.