tinygo/src/runtime/gc_riscv.S
Ayke van Laethem bfa29f17da runtime: move/refactor some GC-related code
Instead of putting tinygo_scanCurrentStack in scheduler_*.S files, put
them in dedicated files. The function tinygo_scanCurrentStack has
nothing to do with scheduling and so doesn't belong there. Additionally,
while scheduling code is made specific for the Cortex-M, the
tinygo_scanCurrentStack is generic to all ARM targets so this move
removes some duplication there.

Specifically:

  * tinygo_scanCurrentStack is moved out of scheduler_cortexm.S as it
    isn't really part of the scheduler. It is now gc_arm.S.
  * Same for the AVR target.
  * Same for the RISCV target.
  * scheduler_gba.S is removed, using gc_arm.S instead as it only
    contains tinygo_scanCurrentStack.
2020-10-02 08:54:43 +02:00

42 строки
909 Б
ArmAsm

#if __riscv_xlen==64
#define REGSIZE 8
#define SREG sd
#define LREG ld
#else
#define REGSIZE 4
#define SREG sw
#define LREG lw
#endif
.section .text.tinygo_scanCurrentStack
.global tinygo_scanCurrentStack
.type tinygo_scanCurrentStack, %function
tinygo_scanCurrentStack:
// Push callee-saved registers onto the stack.
addi sp, sp, -13*REGSIZE
SREG ra, 0*REGSIZE(sp)
SREG s11, 1*REGSIZE(sp)
SREG s10, 2*REGSIZE(sp)
SREG s9, 3*REGSIZE(sp)
SREG s8, 4*REGSIZE(sp)
SREG s7, 5*REGSIZE(sp)
SREG s6, 6*REGSIZE(sp)
SREG s5, 7*REGSIZE(sp)
SREG s4, 8*REGSIZE(sp)
SREG s3, 9*REGSIZE(sp)
SREG s2, 10*REGSIZE(sp)
SREG s1, 11*REGSIZE(sp)
SREG s0, 12*REGSIZE(sp)
// Scan the stack.
mv a0, sp
call tinygo_scanstack
// Restore return address.
LREG ra, 0(sp)
// Restore stack state.
addi sp, sp, 13*REGSIZE
// Return to the caller.
ret