|
90 | 90 | #define PTR_FROM_BLOCK(block) (((block) * BYTES_PER_BLOCK + (uintptr_t)MP_STATE_MEM(gc_pool_start)))
|
91 | 91 | #define ATB_FROM_BLOCK(bl) ((bl) / BLOCKS_PER_ATB)
|
92 | 92 |
|
93 |
| -#if MICROPY_ENABLE_FINALISER |
94 |
| -// FTB = finaliser table byte |
95 |
| -// if set, then the corresponding block may have a finaliser |
96 |
| - |
97 |
| -#define BLOCKS_PER_FTB (8) |
98 |
| - |
99 | 93 | // After the ATB, there must be a byte filled with AT_FREE so that gc_mark_tree
|
100 | 94 | // cannot erroneously conclude that a block extends past the end of the GC heap
|
101 | 95 | // due to bit patterns in the FTB (or first block, if finalizers are disabled)
|
102 | 96 | // being interpreted as AT_TAIL.
|
103 | 97 | #define ALLOC_TABLE_GAP_BYTE (1)
|
104 | 98 |
|
| 99 | +#if MICROPY_ENABLE_FINALISER |
| 100 | +// FTB = finaliser table byte |
| 101 | +// if set, then the corresponding block may have a finaliser |
| 102 | + |
| 103 | +#define BLOCKS_PER_FTB (8) |
| 104 | + |
105 | 105 | #define FTB_GET(block) ((MP_STATE_MEM(gc_finaliser_table_start)[(block) / BLOCKS_PER_FTB] >> ((block) & 7)) & 1)
|
106 | 106 | #define FTB_SET(block) do { MP_STATE_MEM(gc_finaliser_table_start)[(block) / BLOCKS_PER_FTB] |= (1 << ((block) & 7)); } while (0)
|
107 | 107 | #define FTB_CLEAR(block) do { MP_STATE_MEM(gc_finaliser_table_start)[(block) / BLOCKS_PER_FTB] &= (~(1 << ((block) & 7))); } while (0)
|
@@ -154,7 +154,7 @@ void gc_init(void *start, void *end) {
|
154 | 154 | memset(MP_STATE_MEM(gc_finaliser_table_start), 0, gc_finaliser_table_byte_len + gc_alloc_table_byte_len + ALLOC_TABLE_GAP_BYTE);
|
155 | 155 | #else
|
156 | 156 | // clear ATBs
|
157 |
| - memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len)); |
| 157 | + memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len) + ALLOC_TABLE_GAP_BYTE); |
158 | 158 | #endif
|
159 | 159 |
|
160 | 160 | // set last free ATB index to start of heap
|
|
0 commit comments