summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-07-12 18:08:01 +1000
committerDamien George <damien.p.george@gmail.com>2018-07-12 18:08:01 +1000
commit8c9c167dc6986a44acf9f255ff96e6822165e3e0 (patch)
treeb60c813777a7acc168953b4f3c309f8db451a8b6
parentd974ee1c2fc3256ab367eeeb020921f8a5b0dd61 (diff)
py/emitnative: Optimise for iteration asm code for non-debug build.
In non-debug mode MP_OBJ_STOP_ITERATION is zero and comparing something to zero can be done more efficiently in assembler than comparing to a non-zero value.
-rw-r--r--py/emitnative.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index ad8f04aac..3bc637ac6 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -1737,8 +1737,13 @@ STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_1, MP_OBJ_ITER_BUF_NSLOTS);
adjust_stack(emit, MP_OBJ_ITER_BUF_NSLOTS);
emit_call(emit, MP_F_NATIVE_ITERNEXT);
+ #ifdef NDEBUG
+ MP_STATIC_ASSERT(MP_OBJ_STOP_ITERATION == 0);
+ ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label);
+ #else
ASM_MOV_REG_IMM(emit->as, REG_TEMP1, (mp_uint_t)MP_OBJ_STOP_ITERATION);
ASM_JUMP_IF_REG_EQ(emit->as, REG_RET, REG_TEMP1, label);
+ #endif
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
}