diff options
author | Damien George <damien.p.george@gmail.com> | 2018-09-29 23:25:08 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-09-29 23:25:08 +1000 |
commit | d95947b48a30f818638c3619b92110ce6d07f5e3 (patch) | |
tree | a6754c314e919019382ef87b32f5272c295b29ce /py/objfun.c | |
parent | dd288904dbaaa6f085252b7457dd10e5abfdb1f2 (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/objfun.c')
-rw-r--r-- | py/objfun.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objfun.c b/py/objfun.c index b03d4194f..ce6fd22a5 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -318,7 +318,7 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const // must be an exception because normal functions can't yield assert(vm_return_kind == MP_VM_RETURN_EXCEPTION); // return value is in fastn[0]==state[n_state - 1] - result = code_state->state[n_state - 1]; + result = code_state->state[0]; } #if MICROPY_ENABLE_PYSTACK |