qemu/main: Make GC heap size configurable on a per-arch basis.
In certain circumstances depending on the code size, the `deflate_decompress` test fails on both ARM and RV32 with a memory allocation failure error. The issue is mitigated by having a larger GC heap, in this case around 20 KBytes more than the original 100 KBytes default. This commit makes the GC heap size configurable on a per-arch basis, with both ARM and RV32 using the enlarged 120 KBytes heap. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
parent
268acb714d
commit
36aa7545b0
3 changed files with 11 additions and 3 deletions
|
|
@ -19,9 +19,11 @@ QSTR_DEFS = qstrdefsport.h
|
|||
MICROPY_ROM_TEXT_COMPRESSION ?= 1
|
||||
|
||||
ifeq ($(QEMU_ARCH),arm)
|
||||
MICROPY_HEAP_SIZE ?= 122880
|
||||
FROZEN_MANIFEST ?= "require('unittest'); freeze('test-frzmpy', ('frozen_asm_thumb.py', 'frozen_const.py', 'frozen_viper.py', 'native_frozen_align.py'))"
|
||||
endif
|
||||
ifeq ($(QEMU_ARCH),riscv32)
|
||||
MICROPY_HEAP_SIZE ?= 122880
|
||||
FROZEN_MANIFEST ?= "require('unittest'); freeze('test-frzmpy', ('frozen_asm_rv32.py', 'frozen_const.py', 'frozen_viper.py', 'native_frozen_align.py'))"
|
||||
endif
|
||||
|
||||
|
|
@ -29,6 +31,8 @@ endif
|
|||
include $(TOP)/py/py.mk
|
||||
include $(TOP)/extmod/extmod.mk
|
||||
|
||||
CFLAGS += -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE)
|
||||
|
||||
################################################################################
|
||||
# ARM specific settings
|
||||
|
||||
|
|
|
|||
|
|
@ -122,3 +122,5 @@ The following options can be specified on the `make` command line:
|
|||
- `QEMU_DEBUG_ARGS`: defaults to `-s` (gdb on TCP port 1234), but can be overridden
|
||||
with different qemu gdb arguments.
|
||||
- `QEMU_DEBUG_EXTRA`: extra options to pass to qemu when `QEMU_DEBUG=1` is used.
|
||||
- `MICROPY_HEAP_SIZE`: pass in an optional value (in bytes) for overriding the GC
|
||||
heap size used by the port.
|
||||
|
|
|
|||
|
|
@ -34,14 +34,16 @@
|
|||
#include "shared/runtime/gchelper.h"
|
||||
#include "shared/runtime/pyexec.h"
|
||||
|
||||
#define HEAP_SIZE (100 * 1024)
|
||||
#if MICROPY_HEAP_SIZE <= 0
|
||||
#error MICROPY_HEAP_SIZE must be a positive integer.
|
||||
#endif
|
||||
|
||||
static uint32_t gc_heap[HEAP_SIZE / sizeof(uint32_t)];
|
||||
static uint32_t gc_heap[MICROPY_HEAP_SIZE / sizeof(uint32_t)];
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
mp_stack_ctrl_init();
|
||||
mp_stack_set_limit(10240);
|
||||
gc_init(gc_heap, (char *)gc_heap + HEAP_SIZE);
|
||||
gc_init(gc_heap, (char *)gc_heap + MICROPY_HEAP_SIZE);
|
||||
|
||||
for (;;) {
|
||||
mp_init();
|
||||
|
|
|
|||
Loading…
Reference in a new issue