Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit37ada23

Browse files
committed
py: Take gc_pool_start out of bss section, to reclaim 1st block of heap.
1 parent923a8a8 commit37ada23

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

‎py/gc.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ STATIC mp_uint_t gc_alloc_table_byte_len;
5858
#ifMICROPY_ENABLE_FINALISER
5959
STATICbyte*gc_finaliser_table_start;
6060
#endif
61-
STATICmp_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+
STATICmp_uint_t*gc_pool_start= (void*)4;
6266
STATICmp_uint_t*gc_pool_end;
6367

6468
STATICintgc_stack_overflow;
@@ -153,13 +157,6 @@ void gc_init(void *start, void *end) {
153157
memset(gc_finaliser_table_start,0,gc_finaliser_table_byte_len);
154158
#endif
155159

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 (inti=0;i<WORDS_PER_BLOCK;i++) {
160-
gc_pool_start[i]=0;
161-
}
162-
163160
// set last free ATB index to start of heap
164161
gc_last_free_atb_index=0;
165162

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp