diff options
| author | Ayke van Laethem <aykevanlaethem@gmail.com> | 2018-03-26 15:01:35 +0200 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2018-07-18 17:12:26 +1000 |
| commit | 65f8d9a6438caf18b75b43ffe00672347411b2cc (patch) | |
| tree | 394018986ba86866a8bd547b82ec94be5c2020b8 | |
| parent | 013c23712cc8883fdf3ffcdcf63bda1511b394a6 (diff) | |
nrf/gccollect: Use the SP register instead of MSP.
Using the current stack pointer directly saves 8 bytes of code.
We need the *current* register anyway for GC (which is always MSP).
| -rw-r--r-- | ports/nrf/gccollect.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ports/nrf/gccollect.c b/ports/nrf/gccollect.c index b7aa57a55..68b818853 100644 --- a/ports/nrf/gccollect.c +++ b/ports/nrf/gccollect.c @@ -31,19 +31,19 @@ #include "py/gc.h" #include "gccollect.h" -static inline uint32_t get_msp(void) -{ - register uint32_t result; - __asm volatile ("MRS %0, msp\n" : "=r" (result) ); - return(result); +static inline uintptr_t get_sp(void) { + uintptr_t result; + __asm__ ("mov %0, sp\n" : "=r" (result) ); + return result; } void gc_collect(void) { // start the GC gc_collect_start(); - mp_uint_t sp = get_msp(); // Get stack pointer - + // Get stack pointer + uintptr_t sp = get_sp(); + // trace the stack, including the registers (since they live on the stack in this function) gc_collect_root((void**)sp, ((uint32_t)&_ram_end - sp) / sizeof(uint32_t)); |
