summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-08-06 14:44:33 +1000
committerDamien George <damien.p.george@gmail.com>2018-08-06 14:44:33 +1000
commit652a58698edadfe9b587324197e6f922790cf05f (patch)
treed02211629ae72e6a884523fcf31d6ffd3e4c3f4d
parent3bef7bd7820c1739192d0cfbb354c225c945714d (diff)
py/emitnative: Simplify handling of exception objects from nlr_buf_t.
There is no need to have three copies of the exception object on the top of the native value stack. Instead, the values on the stack should be the first two items in an nlr_buf_t: the prev pointer and the ret_val pointer. This is all that is needed and is what the rest of the native emitter expects is on the stack. This patch is essentially an optimisation. Behaviour is unchanged, although the stack layout for native exception handling now makes more sense.
-rw-r--r--py/emitnative.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 5b16990fe..cb653cee4 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -2205,18 +2205,14 @@ STATIC void emit_native_yield(emit_t *emit, int kind) {
}
STATIC void emit_native_start_except_handler(emit_t *emit) {
- // This instruction follows an nlr_pop, so the stack counter is back to zero, when really
+ // This instruction follows a pop_block call, so the stack counter is up by one when really
// it should be up by a whole nlr_buf_t. We then want to pop the nlr_buf_t here, but save
// the first 2 elements, so we can get the thrown value.
adjust_stack(emit, 1);
- vtype_kind_t vtype_nlr;
- emit_pre_pop_reg(emit, &vtype_nlr, REG_ARG_1); // get the thrown value
- emit_pre_pop_discard(emit); // discard the linked-list pointer in the nlr_buf
- emit_post_push_reg_reg_reg(emit, VTYPE_PYOBJ, REG_ARG_1, VTYPE_PYOBJ, REG_ARG_1, VTYPE_PYOBJ, REG_ARG_1); // push the 3 exception items
}
STATIC void emit_native_end_except_handler(emit_t *emit) {
- adjust_stack(emit, -1);
+ (void)emit;
}
const emit_method_table_t EXPORT_FUN(method_table) = {