diff options
author | Damien George <damien@micropython.org> | 2021-09-13 22:30:24 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-09-13 22:30:24 +1000 |
commit | 426785a19eeb12aef7383fbda4693575d8c4dddf (patch) | |
tree | 36dcbf57be41384ccaab8570043b465a3632201b /py/emitnative.c | |
parent | c0761d28fc46072d73daf6bdd1c6abbbac0fc9c1 (diff) |
py/emitnative: Ensure load_subscr does not clobber existing REG_RET.
Fixes issue #7782, and part of issue #6314.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/emitnative.c')
-rw-r--r-- | py/emitnative.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/py/emitnative.c b/py/emitnative.c index 7c7c34283..6504f3776 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -1560,6 +1560,7 @@ STATIC void emit_native_load_subscr(emit_t *emit) { int reg_base = REG_ARG_1; int reg_index = REG_ARG_2; emit_pre_pop_reg_flexible(emit, &vtype_base, ®_base, reg_index, reg_index); + need_reg_single(emit, REG_RET, 0); switch (vtype_base) { case VTYPE_PTR8: { // pointer to 8-bit memory @@ -1623,6 +1624,7 @@ STATIC void emit_native_load_subscr(emit_t *emit) { int reg_index = REG_ARG_2; emit_pre_pop_reg_flexible(emit, &vtype_index, ®_index, REG_ARG_1, REG_ARG_1); emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); + need_reg_single(emit, REG_RET, 0); if (vtype_index != VTYPE_INT && vtype_index != VTYPE_UINT) { EMIT_NATIVE_VIPER_TYPE_ERROR(emit, MP_ERROR_TEXT("can't load with '%q' index"), vtype_to_qstr(vtype_index)); |