aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-19 14:45:34 +0100
committerDamien George <damien.p.george@gmail.com>2014-10-19 14:45:34 +0100
commitb4c05c2966a9362a038e641ea9b29990a0ffe876 (patch)
treea2be4c54cadb018c6e9a5e55062d386dd6f06f95
parent788f191e0693989fd5d2a9917c32933a1e83eb5a (diff)
py: Move pointer to next free block earlier in alloc.reentrant-gc
-rw-r--r--py/gc.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/py/gc.c b/py/gc.c
index a267477b9..ab7257813 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -480,9 +480,20 @@ found:
end_block = i;
start_block = i - n_free + 1;
- // mark first block as used head
#if MICROPY_REENTRANT_GC
mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION();
+ #endif
+
+ // Set last free ATB index to block after last block we found, for start of
+ // next scan. To reduce fragmentation, we only do this if there are no free
+ // blocks before this one. Also, whenever we free or shink a block we must
+ // check if this index needs adjusting (see gc_realloc and gc_free).
+ if ((i + 1) / BLOCKS_PER_ATB < gc_last_free_atb_index) {
+ gc_last_free_atb_index = (i + 1) / BLOCKS_PER_ATB;
+ }
+
+ // mark first block as used head
+ #if MICROPY_REENTRANT_GC
if (ATB_GET_KIND(start_block) == AT_FREE) {
// TODO might need to make MARK
ATB_FREE_TO_HEAD(start_block);
@@ -518,14 +529,6 @@ found:
#endif
}
- // Set last free ATB index to block after last block we found, for start of
- // next scan. To reduce fragmentation, we only do this if there are no free
- // blocks before this one. Also, whenever we free or shink a block we must
- // check if this index needs adjusting (see gc_realloc and gc_free).
- if ((i + 1) / BLOCKS_PER_ATB < gc_last_free_atb_index) {
- gc_last_free_atb_index = (i + 1) / BLOCKS_PER_ATB;
- }
-
#if MICROPY_REENTRANT_GC
MICROPY_END_ATOMIC_SECTION(atomic_state);
#endif