GPUSH
Push a garbage collector root onto the GP stack.
| Opcode | Bytes | Cycles | Form | Example |
|---|---|---|---|---|
| $1e | 1 | 2 | gpush pushed | gpush pushed |
| $34 | 2 | 3 | gpush i:_ | gpush i:4 |
| $35 | 2 | 3 | gpush 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
gpregister), 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
triopointers. When pushing a larger value, the extra bits are discarded. -
The effect of
gpush i:4for example is to pushi:4onto the GP stack. It first storesgp - 3ingp. Then it stores the address ofi:4(not the value ofi:4) at the memory address pointed to bygp. -
gpush null i:4for example performs all those actions and then also assigns0toi:4. This form is used to initialize a local variable to contain a null pointer. -
gpush pushedworks differently: It first storesgp - 3ingp, then assignssp - 4to the memory address pointed to bygp.sp - 4is assumed to be a recently pushedintpointer. For example, if we just didpush i:4, thengpush pushedis equivalent togpush i:4. -
If
io::stack_guardis 1, thengpushwill trigger a stack fault event if thespregister becomes larger than thegpregister. -
gpopundoes the action ofgpush. -
This instruction does not affect the CPU condition flags.