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:
Damien George 2018-08-04 22:41:35 +10:00
parent 1c0bd46d1d
commit 3bef7bd782
1 changed files with 3 additions and 0 deletions

View File

@ -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);