diff options
author | Damien George <damien@micropython.org> | 2024-02-09 17:41:48 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-02-16 14:17:01 +1100 |
commit | e2ff00e81113d7a3f32f860652017644b5d68bf1 (patch) | |
tree | 061a1d917a23be78706c3a4cfd6a46b1307a4ebf /py/dynruntime.h | |
parent | 5e3006f1172d0eabbbefeb3268dfb942ec7cf9cd (diff) | |
download | micropython-e2ff00e81113d7a3f32f860652017644b5d68bf1.tar.gz micropython-e2ff00e81113d7a3f32f860652017644b5d68bf1.zip |
py/emitglue: Introduce mp_proto_fun_t as a more general mp_raw_code_t.
Allows bytecode itself to be used instead of an mp_raw_code_t in the simple
and common cases of a bytecode function without any children.
This can be used to further reduce frozen code size, and has the potential
to optimise other areas like importing.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/dynruntime.h')
-rw-r--r-- | py/dynruntime.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/py/dynruntime.h b/py/dynruntime.h index 3e660f19fd..7765fca40d 100644 --- a/py/dynruntime.h +++ b/py/dynruntime.h @@ -196,8 +196,8 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type #define mp_unary_op(op, obj) (mp_fun_table.unary_op((op), (obj))) #define mp_binary_op(op, lhs, rhs) (mp_fun_table.binary_op((op), (lhs), (rhs))) -#define mp_make_function_from_raw_code(rc, context, def_args) \ - (mp_fun_table.make_function_from_raw_code((rc), (context), (def_args))) +#define mp_make_function_from_proto_fun(rc, context, def_args) \ + (mp_fun_table.make_function_from_proto_fun((rc), (context), (def_args))) #define mp_call_function_n_kw(fun, n_args, n_kw, args) \ (mp_fun_table.call_function_n_kw((fun), (n_args) | ((n_kw) << 8), args)) @@ -208,6 +208,8 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type #define MP_DYNRUNTIME_INIT_ENTRY \ mp_obj_t old_globals = mp_fun_table.swap_globals(self->context->module.globals); \ mp_raw_code_truncated_t rc; \ + rc.proto_fun_indicator[0] = MP_PROTO_FUN_INDICATOR_RAW_CODE_0; \ + rc.proto_fun_indicator[1] = MP_PROTO_FUN_INDICATOR_RAW_CODE_1; \ rc.kind = MP_CODE_NATIVE_VIPER; \ rc.is_generator = 0; \ (void)rc; @@ -217,7 +219,7 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type return mp_const_none; #define MP_DYNRUNTIME_MAKE_FUNCTION(f) \ - (mp_make_function_from_raw_code((rc.fun_data = (f), (const mp_raw_code_t *)&rc), self->context, NULL)) + (mp_make_function_from_proto_fun((rc.fun_data = (f), (const mp_raw_code_t *)&rc), self->context, NULL)) #define mp_import_name(name, fromlist, level) \ (mp_fun_table.import_name((name), (fromlist), (level))) |