summaryrefslogtreecommitdiff
path: root/py/emitnative.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-09-24 15:57:08 +1000
committerDamien George <damien.p.george@gmail.com>2019-10-01 12:26:22 +1000
commit81d04a0200e0d4038c011e4946bfae5707ef9d9c (patch)
tree63abd765209f3aa447285db2d8f35c3a53eccb52 /py/emitnative.c
parent4c5e1a036831a3ac36866e4daab3a50c772b4443 (diff)
py: Add n_state to mp_code_state_t struct.
This value is used often enough that it is better to cache it instead of decode it each time.
Diffstat (limited to 'py/emitnative.c')
-rw-r--r--py/emitnative.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 760c7fb0c..f5a18c987 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -521,6 +521,9 @@ STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop
// TODO this encoding may change size in the final pass, need to make it fixed
emit_native_mov_state_imm_via(emit, emit->code_state_start + OFFSETOF_CODE_STATE_IP, emit->prelude_offset, REG_ARG_1);
+ // Set code_state.n_state (only works on little endian targets due to n_state being uint16_t)
+ emit_native_mov_state_imm_via(emit, emit->code_state_start + offsetof(mp_code_state_t, n_state) / sizeof(uintptr_t), emit->n_state, REG_ARG_1);
+
// Put address of code_state into first arg
ASM_MOV_REG_LOCAL_ADDR(emit->as, REG_ARG_1, emit->code_state_start);