aboutsummaryrefslogtreecommitdiff
path: root/py/vm.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-09-29 23:25:08 +1000
committerDamien George <damien.p.george@gmail.com>2018-09-29 23:25:08 +1000
commitd95947b48a30f818638c3619b92110ce6d07f5e3 (patch)
treea6754c314e919019382ef87b32f5272c295b29ce /py/vm.c
parentdd288904dbaaa6f085252b7457dd10e5abfdb1f2 (diff)
py/vm: When VM raises exception put exc obj at beginning of func state.
Instead of at end of state, n_state - 1. It was originally (way back in v1.0) put at the end of the state because the VM didn't have a pointer to the start. But now that the VM takes a mp_code_state_t pointer it does have a pointer to the start of the state so can put the exception object there. This commit saves about 30 bytes of code on all architectures, and, more importantly, reduces C-stack usage by a couple of words (8 bytes on Thumb2 and 16 bytes on x86-64) for every (non-generator) call of a bytecode function because fun_bc_call no longer needs to remember the n_state variable.
Diffstat (limited to 'py/vm.c')
-rw-r--r--py/vm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/vm.c b/py/vm.c
index 8da40c9b6..828ea79e5 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -1468,7 +1468,7 @@ unwind_loop:
} else {
// propagate exception to higher level
// Note: ip and sp don't have usable values at this point
- fastn[0] = MP_OBJ_FROM_PTR(nlr.ret_val); // must put exception here because sp is invalid
+ code_state->state[0] = MP_OBJ_FROM_PTR(nlr.ret_val); // put exception here because sp is invalid
return MP_VM_RETURN_EXCEPTION;
}
}