webassembly: Enable C-stack checking.

This gets the recursive stress-tests working on this port.

For relatively small Python functions the maximum recursive depth is about
150 nested calls.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-08-11 13:26:19 +10:00
parent f9b6d8e608
commit c16fe5b5ed
2 changed files with 5 additions and 1 deletions

View File

@@ -49,6 +49,9 @@
// the top-level call into C.
static size_t external_call_depth = 0;
// Emscripten defaults to a 64k C-stack, so our limit should be less than that.
#define CSTACK_SIZE (32 * 1024)
#if MICROPY_GC_SPLIT_HEAP_AUTO
static void gc_collect_top_level(void);
#endif
@@ -67,6 +70,8 @@ void external_call_depth_dec(void) {
}
void mp_js_init(int pystack_size, int heap_size) {
mp_cstack_init_with_sp_here(CSTACK_SIZE);
#if MICROPY_ENABLE_PYSTACK
mp_obj_t *pystack = (mp_obj_t *)malloc(pystack_size * sizeof(mp_obj_t));
mp_pystack_init(pystack, pystack + pystack_size);

View File

@@ -44,7 +44,6 @@
#define MICROPY_READER_VFS (MICROPY_VFS)
#define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_PYSTACK (1)
#define MICROPY_STACK_CHECK (0)
#define MICROPY_KBD_EXCEPTION (1)
#define MICROPY_REPL_EVENT_DRIVEN (1)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)