diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-16 21:50:39 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-16 21:50:39 +0100 |
commit | 37ada236b32e04338d24cb0e8a952af6b6bde55d (patch) | |
tree | fcb57dd4ed604e5447bdd6f74c787f7105be525e /py | |
parent | 923a8a83200f7f1061b8bdad9457d093f7cec147 (diff) | |
download | micropython-37ada236b32e04338d24cb0e8a952af6b6bde55d.tar.gz micropython-37ada236b32e04338d24cb0e8a952af6b6bde55d.zip |
py: Take gc_pool_start out of bss section, to reclaim 1st block of heap.
Diffstat (limited to 'py')
-rw-r--r-- | py/gc.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -58,7 +58,11 @@ STATIC mp_uint_t gc_alloc_table_byte_len; #if MICROPY_ENABLE_FINALISER STATIC byte *gc_finaliser_table_start; #endif -STATIC mp_uint_t *gc_pool_start; +// We initialise gc_pool_start to a dummy value so it stays out of the bss +// section. This makes sure we don't trace this pointer in a collect cycle. +// If we did trace it, it would make the first block of the heap always +// reachable, and hence we can never free that block. +STATIC mp_uint_t *gc_pool_start = (void*)4; STATIC mp_uint_t *gc_pool_end; STATIC int gc_stack_overflow; @@ -153,13 +157,6 @@ void gc_init(void *start, void *end) { memset(gc_finaliser_table_start, 0, gc_finaliser_table_byte_len); #endif - // allocate first block because gc_pool_start points there and it will never - // be freed, so allocating 1 block with null pointers will minimise memory loss - ATB_FREE_TO_HEAD(0); - for (int i = 0; i < WORDS_PER_BLOCK; i++) { - gc_pool_start[i] = 0; - } - // set last free ATB index to start of heap gc_last_free_atb_index = 0; |