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:
8
py/vm.c
8
py/vm.c
@@ -893,7 +893,7 @@ unwind_jump:;
|
||||
|
||||
ENTRY(MP_BC_MAKE_FUNCTION): {
|
||||
DECODE_PTR;
|
||||
PUSH(mp_make_function_from_raw_code(ptr, code_state->fun_bc->context, NULL));
|
||||
PUSH(mp_make_function_from_proto_fun(ptr, code_state->fun_bc->context, NULL));
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
@@ -901,7 +901,7 @@ unwind_jump:;
|
||||
DECODE_PTR;
|
||||
// Stack layout: def_tuple def_dict <- TOS
|
||||
sp -= 1;
|
||||
SET_TOP(mp_make_function_from_raw_code(ptr, code_state->fun_bc->context, sp));
|
||||
SET_TOP(mp_make_function_from_proto_fun(ptr, code_state->fun_bc->context, sp));
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
@@ -910,7 +910,7 @@ unwind_jump:;
|
||||
size_t n_closed_over = *ip++;
|
||||
// Stack layout: closed_overs <- TOS
|
||||
sp -= n_closed_over - 1;
|
||||
SET_TOP(mp_make_closure_from_raw_code(ptr, code_state->fun_bc->context, n_closed_over, sp));
|
||||
SET_TOP(mp_make_closure_from_proto_fun(ptr, code_state->fun_bc->context, n_closed_over, sp));
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ unwind_jump:;
|
||||
size_t n_closed_over = *ip++;
|
||||
// Stack layout: def_tuple def_dict closed_overs <- TOS
|
||||
sp -= 2 + n_closed_over - 1;
|
||||
SET_TOP(mp_make_closure_from_raw_code(ptr, code_state->fun_bc->context, 0x100 | n_closed_over, sp));
|
||||
SET_TOP(mp_make_closure_from_proto_fun(ptr, code_state->fun_bc->context, 0x100 | n_closed_over, sp));
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user