File tree 1 file changed +5
-8
lines changed
1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,11 @@ STATIC mp_uint_t gc_alloc_table_byte_len;
58
58
#if MICROPY_ENABLE_FINALISER
59
59
STATIC byte * gc_finaliser_table_start ;
60
60
#endif
61
- STATIC mp_uint_t * gc_pool_start ;
61
+ // We initialise gc_pool_start to a dummy value so it stays out of the bss
62
+ // section. This makes sure we don't trace this pointer in a collect cycle.
63
+ // If we did trace it, it would make the first block of the heap always
64
+ // reachable, and hence we can never free that block.
65
+ STATIC mp_uint_t * gc_pool_start = (void * )4 ;
62
66
STATIC mp_uint_t * gc_pool_end ;
63
67
64
68
STATIC int gc_stack_overflow ;
@@ -153,13 +157,6 @@ void gc_init(void *start, void *end) {
153
157
memset (gc_finaliser_table_start , 0 , gc_finaliser_table_byte_len );
154
158
#endif
155
159
156
- // allocate first block because gc_pool_start points there and it will never
157
- // be freed, so allocating 1 block with null pointers will minimise memory loss
158
- ATB_FREE_TO_HEAD (0 );
159
- for (int i = 0 ; i < WORDS_PER_BLOCK ; i ++ ) {
160
- gc_pool_start [i ] = 0 ;
161
- }
162
-
163
160
// set last free ATB index to start of heap
164
161
gc_last_free_atb_index = 0 ;
165
162
You can’t perform that action at this time.
0 commit comments