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 /tools/mpy-tool.py | |
| parent | 5e3006f1172d0eabbbefeb3268dfb942ec7cf9cd (diff) | |
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 'tools/mpy-tool.py')
| -rwxr-xr-x | tools/mpy-tool.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 744800c67..33e59c807 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -684,7 +684,7 @@ class CompiledModule: else: print(" .obj_table = NULL,") print(" },") - print(" .rc = (const mp_raw_code_t *)&raw_code_%s," % self.raw_code.escaped_name) + print(" .proto_fun = &proto_fun_%s," % self.raw_code.escaped_name) print("};") def freeze_constant_obj(self, obj_name, obj): @@ -899,7 +899,7 @@ class RawCode(object): print() print("static const mp_raw_code_t *const children_%s[] = {" % self.escaped_name) for rc in self.children: - print(" (const mp_raw_code_t *)&raw_code_%s," % rc.escaped_name) + print(" (const mp_raw_code_t *)&proto_fun_%s," % rc.escaped_name) if prelude_ptr: print(" (void *)%s," % prelude_ptr) print("};") @@ -911,7 +911,9 @@ class RawCode(object): raw_code_type = "mp_raw_code_t" else: raw_code_type = "mp_raw_code_truncated_t" - print("static const %s raw_code_%s = {" % (raw_code_type, self.escaped_name)) + print("static const %s proto_fun_%s = {" % (raw_code_type, self.escaped_name)) + print(" .proto_fun_indicator[0] = MP_PROTO_FUN_INDICATOR_RAW_CODE_0,") + print(" .proto_fun_indicator[1] = MP_PROTO_FUN_INDICATOR_RAW_CODE_1,") print(" .kind = %s," % RawCode.code_kind_str[self.code_kind]) print(" .is_generator = %d," % bool(self.scope_flags & MP_SCOPE_FLAG_GENERATOR)) print(" .fun_data = fun_data_%s," % self.escaped_name) |
