diff options
| author | Damien George | 2017-06-09 13:31:57 +1000 |
|---|---|---|
| committer | Damien George | 2017-06-09 13:36:33 +1000 |
| commit | a8a5d1e8c8db3b7c64e1921005ceb5a5d47280f4 (patch) | |
| tree | 8b6ba37193f4c3eaaa9a1115d2be6d90055ce565 /py/objgenerator.c | |
| parent | 4352b944d2fe0919b34774bec1a6ea440649a1df (diff) | |
py: Provide mp_decode_uint_skip() to help reduce stack usage.
Taking the address of a local variable leads to increased stack usage, so
the mp_decode_uint_skip() function is added to reduce the need for taking
addresses. The changes in this patch reduce stack usage of a Python call
by 8 bytes on ARM Thumb, by 16 bytes on non-windowing Xtensa archs, and by
16 bytes on x86-64. Code size is also slightly reduced on most archs by
around 32 bytes.
Diffstat (limited to 'py/objgenerator.c')
| -rw-r--r-- | py/objgenerator.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/py/objgenerator.c b/py/objgenerator.c index 2e57fdf4b..8cb0e60cc 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -54,12 +54,9 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun; assert(self_fun->base.type == &mp_type_fun_bc); - // get start of bytecode - const byte *ip = self_fun->bytecode; - // bytecode prelude: get state size and exception stack size - mp_uint_t n_state = mp_decode_uint(&ip); - mp_uint_t n_exc_stack = mp_decode_uint(&ip); + size_t n_state = mp_decode_uint_value(self_fun->bytecode); + size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self_fun->bytecode)); // allocate the generator object, with room for local stack and exception stack mp_obj_gen_instance_t *o = m_new_obj_var(mp_obj_gen_instance_t, byte, |
