diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-29 20:30:52 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-29 20:30:52 +0000 |
commit | d0691ccaec37b367892a3cc924ee5eed24288b38 (patch) | |
tree | 3804facffaac43f454bf4c0d23b066886c88a46c /py/objgenerator.c | |
parent | 01fa4a91643702eb62645346991a41e52c1c8414 (diff) |
py: Simplify fastn in VM; reduce size of unique code struct.
We still have FAST_[0,1,2] byte codes, but they now just access the
fastn array (before they had special local variables). It's now
simpler, a bit faster, and uses a bit less stack space (on STM at least,
which is most important).
The only reason now to keep FAST_[0,1,2] byte codes is for compressed
byte code size.
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 91bbbceb2..67f8eed59 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -16,7 +16,6 @@ typedef struct _mp_obj_gen_wrap_t { mp_obj_base_t base; - uint n_state; mp_obj_t *fun; } mp_obj_gen_wrap_t; @@ -35,7 +34,7 @@ mp_obj_t gen_wrap_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "function does not take keyword arguments")); } - return mp_obj_new_gen_instance(bc_code, self->n_state, n_args, args); + return mp_obj_new_gen_instance(bc_code, bc_n_state, n_args, args); } const mp_obj_type_t gen_wrap_type = { @@ -44,11 +43,9 @@ const mp_obj_type_t gen_wrap_type = { .call = gen_wrap_call, }; -mp_obj_t mp_obj_new_gen_wrap(uint n_locals, uint n_stack, mp_obj_t fun) { +mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) { mp_obj_gen_wrap_t *o = m_new_obj(mp_obj_gen_wrap_t); o->base.type = &gen_wrap_type; - // we have at least 3 locals so the bc can write back fast[0,1,2] safely; should improve how this is done - o->n_state = (n_locals < 3 ? 3 : n_locals) + n_stack; o->fun = fun; return o; } |