aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2018-08-04 22:41:35 +1000
committerDamien George2018-08-04 22:41:35 +1000
commit3bef7bd7820c1739192d0cfbb354c225c945714d (patch)
tree6dde3162c1da594624ed0d9c94518836eac41269
parent1c0bd46d1d20c8c0256f1dc731c773be3ab1c9ed (diff)
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).
-rw-r--r--py/emitnative.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 7071062a7..5b16990fe 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -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);