summaryrefslogtreecommitdiff
path: root/unix/gccollect.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-01 23:30:53 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-07 20:33:00 +0000
commitb4b10fd350852e321624d74983cca286091b55a1 (patch)
tree7ac4aa40d70be0170a61f649e9d73c42faa4ba33 /unix/gccollect.c
parentad2307c92c15f0aa90dbd0741fd2538719d0b5e1 (diff)
py: Put all global state together in state structures.
This patch consolidates all global variables in py/ core into one place, in a global structure. Root pointers are all located together to make GC tracing easier and more efficient.
Diffstat (limited to 'unix/gccollect.c')
-rw-r--r--unix/gccollect.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/unix/gccollect.c b/unix/gccollect.c
index ab20220d3..f8bcbf965 100644
--- a/unix/gccollect.c
+++ b/unix/gccollect.c
@@ -26,6 +26,7 @@
#include <stdio.h>
+#include "py/mpstate.h"
#include "py/gc.h"
#if MICROPY_ENABLE_GC
@@ -127,23 +128,11 @@ void gc_collect(void) {
//gc_dump_info();
gc_collect_start();
- // this traces the .bss section
-#if defined( __CYGWIN__ )
-#define BSS_START __bss_start__
-#elif defined( _MSC_VER ) || defined( __MINGW32__ )
-#define BSS_START *bss_start
-#define _end *bss_end
-#else
-#define BSS_START __bss_start
-#endif
- extern char BSS_START, _end;
- //printf(".bss: %p-%p\n", &BSS_START, &_end);
- gc_collect_root((void**)&BSS_START, ((mp_uint_t)&_end - (mp_uint_t)&BSS_START) / sizeof(mp_uint_t));
regs_t regs;
gc_helper_get_regs(regs);
// GC stack (and regs because we captured them)
void **regs_ptr = (void**)(void*)&regs;
- gc_collect_root(regs_ptr, ((mp_uint_t)stack_top - (mp_uint_t)&regs) / sizeof(mp_uint_t));
+ gc_collect_root(regs_ptr, ((mp_uint_t)MP_STATE_VM(stack_top) - (mp_uint_t)&regs) / sizeof(mp_uint_t));
gc_collect_end();
//printf("-----\n");