Skip to content

Commit 347046d

Browse files
committed
gc: Clear the gap byte for the no-finalisers case.
Signed-off-by: Jeff Epler <jepler@gmail.com>
1 parent fee374c commit 347046d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

py/gc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@
9090
#define PTR_FROM_BLOCK(block) (((block) * BYTES_PER_BLOCK + (uintptr_t)MP_STATE_MEM(gc_pool_start)))
9191
#define ATB_FROM_BLOCK(bl) ((bl) / BLOCKS_PER_ATB)
9292

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-
9993
// After the ATB, there must be a byte filled with AT_FREE so that gc_mark_tree
10094
// cannot erroneously conclude that a block extends past the end of the GC heap
10195
// due to bit patterns in the FTB (or first block, if finalizers are disabled)
10296
// being interpreted as AT_TAIL.
10397
#define ALLOC_TABLE_GAP_BYTE (1)
10498

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+
105105
#define FTB_GET(block) ((MP_STATE_MEM(gc_finaliser_table_start)[(block) / BLOCKS_PER_FTB] >> ((block) & 7)) & 1)
106106
#define FTB_SET(block) do { MP_STATE_MEM(gc_finaliser_table_start)[(block) / BLOCKS_PER_FTB] |= (1 << ((block) & 7)); } while (0)
107107
#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) {
154154
memset(MP_STATE_MEM(gc_finaliser_table_start), 0, gc_finaliser_table_byte_len + gc_alloc_table_byte_len + ALLOC_TABLE_GAP_BYTE);
155155
#else
156156
// 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);
158158
#endif
159159

160160
// set last free ATB index to start of heap

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy