mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
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>
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user