summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-01-24 18:01:20 +1100
committerDamien George <damien.p.george@gmail.com>2020-01-27 13:21:49 +1100
commit0de304e7dabbee443dd96935a8045a227eba455b (patch)
tree968251a412cb93064948bf6673b57c4cff4af7bb /py
parent1f4b607116ea0f06111847510ba5b1cd8080bf7f (diff)
downloadmicropython-0de304e7dabbee443dd96935a8045a227eba455b.tar.gz
micropython-0de304e7dabbee443dd96935a8045a227eba455b.zip
py/emitnative: Use NULL for pending exception (not None).
This previously made the native emitter incompatible with the bytecode emitter, and mp_resume (and subsequently mp_obj_generator_resume) expects the bytecode emitter behavior (i.e. throw==NULL).
Diffstat (limited to 'py')
-rw-r--r--py/emitnative.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 07b984b780..0affbeb0b2 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -2058,7 +2058,7 @@ STATIC void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t exc
ASM_MOV_REG_PCREL(emit->as, REG_RET, label & ~MP_EMIT_BREAK_FROM_FOR);
ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_HANDLER_UNWIND(emit), REG_RET);
// Cancel any active exception (see also emit_native_pop_except_jump)
- emit_native_mov_reg_const(emit, REG_RET, MP_F_CONST_NONE_OBJ);
+ ASM_MOV_REG_IMM(emit->as, REG_RET, (mp_uint_t)MP_OBJ_NULL);
ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_VAL(emit), REG_RET);
// Jump to the innermost active finally
label = first_finally->label;
@@ -2153,9 +2153,8 @@ STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
ASM_MOV_REG_LOCAL(emit->as, REG_ARG_1, LOCAL_IDX_EXC_VAL(emit)); // get exc
- // Check if exc is None and jump to non-exc handler if it is
- emit_native_mov_reg_const(emit, REG_ARG_2, MP_F_CONST_NONE_OBJ);
- ASM_JUMP_IF_REG_EQ(emit->as, REG_ARG_1, REG_ARG_2, *emit->label_slot + 2);
+ // Check if exc is MP_OBJ_NULL (i.e. zero) and jump to non-exc handler if it is
+ ASM_JUMP_IF_REG_ZERO(emit->as, REG_ARG_1, *emit->label_slot + 2, false);
ASM_LOAD_REG_REG_OFFSET(emit->as, REG_ARG_2, REG_ARG_1, 0); // get type(exc)
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_ARG_2); // push type(exc)
@@ -2175,9 +2174,9 @@ STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
emit_call(emit, MP_F_OBJ_IS_TRUE);
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, *emit->label_slot + 1, true);
- // Replace exception with None
+ // Replace exception with MP_OBJ_NULL.
emit_native_label_assign(emit, *emit->label_slot);
- emit_native_mov_reg_const(emit, REG_TEMP0, MP_F_CONST_NONE_OBJ);
+ ASM_MOV_REG_IMM(emit->as, REG_TEMP0, (mp_uint_t)MP_OBJ_NULL);
ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_VAL(emit), REG_TEMP0);
// end of with cleanup nlr_catch block
@@ -2255,7 +2254,7 @@ STATIC void emit_native_for_iter_end(emit_t *emit) {
STATIC void emit_native_pop_except_jump(emit_t *emit, mp_uint_t label, bool within_exc_handler) {
if (within_exc_handler) {
// Cancel any active exception so subsequent handlers don't see it
- emit_native_mov_reg_const(emit, REG_TEMP0, MP_F_CONST_NONE_OBJ);
+ ASM_MOV_REG_IMM(emit->as, REG_TEMP0, (mp_uint_t)MP_OBJ_NULL);
ASM_MOV_LOCAL_REG(emit->as, LOCAL_IDX_EXC_VAL(emit), REG_TEMP0);
} else {
emit_native_leave_exc_stack(emit, false);