diff --git a/ports/webassembly/main.c b/ports/webassembly/main.c index 1b053046bf..ebde8ac700 100644 --- a/ports/webassembly/main.c +++ b/ports/webassembly/main.c @@ -113,6 +113,19 @@ void mp_js_init_repl() { pyexec_event_repl_init(); } +#if MICROPY_GC_SPLIT_HEAP_AUTO + +// The largest new region that is available to become Python heap. +size_t gc_get_max_new_split(void) { + return 128 * 1024 * 1024; +} + +// Don't collect anything. Instead require the heap to grow. +void gc_collect(void) { +} + +#else + static void gc_scan_func(void *begin, void *end) { gc_collect_root((void **)begin, (void **)end - (void **)begin + 1); } @@ -124,6 +137,8 @@ void gc_collect(void) { gc_collect_end(); } +#endif + #if !MICROPY_VFS mp_lexer_t *mp_lexer_new_from_file(qstr filename) { mp_raise_OSError(MP_ENOENT); diff --git a/ports/webassembly/mpconfigport.h b/ports/webassembly/mpconfigport.h index 6b0f2753a9..d026136239 100644 --- a/ports/webassembly/mpconfigport.h +++ b/ports/webassembly/mpconfigport.h @@ -26,6 +26,7 @@ */ #include +#include // for malloc, for MICROPY_GC_SPLIT_HEAP_AUTO // options to control how MicroPython is built