Skip to main content

GPUSH

Push a garbage collector root onto the GP stack.

OpcodeBytesCyclesFormExample
$1e12gpush pushedgpush pushed
$3423gpush i:_gpush i:4
$3523gpush null i:_gpush null i:4

Notes

  • The GP stack is used by the Hybrix memory manager to track GC roots for the purpose of garbage collection (GC). Each GC root stores the memory address of a pointer variable that should be analyzed by the garbage collector.

  • The GP stack grows backwards (pushing decreases the gp register), whereas the SP stack grows forwards. (The "top" of the GP stack is actually the lowest memory address.)

  • Since the Hybrix hardware uses a 24-bit memory bus, Chombit's GP stack is configured to store 3-byte trio pointers. When pushing a larger value, the extra bits are discarded.

  • The effect of gpush i:4 for example is to push i:4 onto the GP stack. It first stores gp - 3 in gp. Then it stores the address of i:4 (not the value of i:4) at the memory address pointed to by gp.

  • gpush null i:4 for example performs all those actions and then also assigns 0 to i:4. This form is used to initialize a local variable to contain a null pointer.

  • gpush pushed works differently: It first stores gp - 3 in gp, then assigns sp - 4 to the memory address pointed to by gp. sp - 4 is assumed to be a recently pushed int pointer. For example, if we just did push i:4, then gpush pushed is equivalent to gpush i:4.

  • If io::stack_guard is 1, then gpush will trigger a stack fault event if the sp register becomes larger than the gp register.

  • gpop undoes the action of gpush.

  • This instruction does not affect the CPU condition flags.