mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
py/emitnative: Fix native locals stack to start at correct location.
A native function allocates space on its C stack for mp_code_state_t, followed by its Python stack, then its locals. This patch makes sure that the native function actually starts at the start of its Python stack, rather than at the start of mp_code_state_t (which didn't lead to any issues so far because the mp_code_state_t is unused after the native function sets itself up).
This commit is contained in:
@@ -310,6 +310,9 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop
|
||||
// work out size of state (locals plus stack)
|
||||
emit->n_state = scope->num_locals + scope->stack_size;
|
||||
|
||||
// the locals and stack start after the code_state structure
|
||||
emit->stack_start = STATE_START;
|
||||
|
||||
// allocate space on C-stack for code_state structure, which includes state
|
||||
ASM_ENTRY(emit->as, STATE_START + emit->n_state);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user