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:
Damien George
2024-02-09 17:41:48 +11:00
parent 5e3006f117
commit e2ff00e811
15 changed files with 63 additions and 39 deletions

View File

@@ -3667,7 +3667,7 @@ mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, bool is_repl)
cm.context->module.globals = mp_globals_get();
mp_compile_to_raw_code(parse_tree, source_file, is_repl, &cm);
// return function that executes the outer module
return mp_make_function_from_raw_code(cm.rc, cm.context, NULL);
return mp_make_function_from_proto_fun(cm.rc, cm.context, NULL);
}
#endif // MICROPY_ENABLE_COMPILER