diff options
| author | Rob Knegjens <rob@knegjens.net> | 2022-04-12 21:26:16 -0700 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-07-23 00:43:08 +1000 |
| commit | 4a48531803843f53caf2b535da7ff3bb2a802106 (patch) | |
| tree | ebe17f66c83b0cb52d544e741e3d18e822bffb46 /py/mpstate.h | |
| parent | bcc827d695e20b644ff4626bd529e3d8706716d7 (diff) | |
py/gc: Reduce code size when MICROPY_GC_SPLIT_HEAP is disabled.
Use C macros to reduce the size of firmware images when the GC split-heap
feature is disabled.
The code size difference of this commit versus HEAD~2 (ie the commit prior
to MICROPY_GC_SPLIT_HEAP being introduced) when split-heap is disabled is:
bare-arm: +0 +0.000%
minimal x86: +0 +0.000%
unix x64: -16 -0.003%
unix nanbox: -20 -0.004%
stm32: -8 -0.002% PYBV10
cc3200: +0 +0.000%
esp8266: +8 +0.001% GENERIC
esp32: +0 +0.000% GENERIC
nrf: -20 -0.011% pca10040
rp2: +0 +0.000% PICO
samd: -4 -0.003% ADAFRUIT_ITSYBITSY_M4_EXPRESS
The code size difference of this commit versus HEAD~2 split-heap is enabled
with MICROPY_GC_MULTIHEAP=1 (but no extra code to add more heaps):
unix x64: +1032 +0.197% [incl +544(bss)]
esp32: +592 +0.039% GENERIC[incl +16(data) +264(bss)]
Diffstat (limited to 'py/mpstate.h')
| -rw-r--r-- | py/mpstate.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/py/mpstate.h b/py/mpstate.h index ea069c24d..ba47c7648 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -89,15 +89,6 @@ typedef struct _mp_state_mem_area_t { size_t gc_last_free_atb_index; } mp_state_mem_area_t; -// This structure holds a single stacked block and the area it is on. Used -// during garbage collection. -typedef struct { - #if MICROPY_GC_SPLIT_HEAP - mp_state_mem_area_t *area; - #endif - size_t block; -} mp_gc_stack_item_t; - // This structure hold information about the memory allocation system. typedef struct _mp_state_mem_t { #if MICROPY_MEM_STATS @@ -109,7 +100,11 @@ typedef struct _mp_state_mem_t { mp_state_mem_area_t area; int gc_stack_overflow; - mp_gc_stack_item_t gc_stack[MICROPY_ALLOC_GC_STACK_SIZE]; + MICROPY_GC_STACK_ENTRY_TYPE gc_block_stack[MICROPY_ALLOC_GC_STACK_SIZE]; + #if MICROPY_GC_SPLIT_HEAP + // Array that tracks the area for each block on gc_block_stack. + mp_state_mem_area_t *gc_area_stack[MICROPY_ALLOC_GC_STACK_SIZE]; + #endif // This variable controls auto garbage collection. If set to 0 then the // GC won't automatically run when gc_alloc can't find enough blocks. But |
