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)]
This commit is contained in:
committed by
Damien George
parent
bcc827d695
commit
4a48531803
15
py/mpstate.h
15
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
|
||||
|
||||
Reference in New Issue
Block a user