py/emitnative: Simplify layout and loading of native function prelude.

Now native functions and native generators have similar behaviour: the
first machine-word of their code is an index to get to the prelude.  This
simplifies the handling of these types of functions, and also reduces the
size of the emitted native machine code by no longer requiring special code
at the start of the function to load a pointer to the prelude.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-02-16 16:53:47 +11:00
parent 9400229766
commit 6d403eb697
5 changed files with 38 additions and 26 deletions

View File

@@ -401,7 +401,7 @@ mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_
STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
MP_STACK_CHECK();
mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode);
mp_call_fun_t fun = mp_obj_fun_native_get_function_start(self);
return fun(self_in, n_args, n_kw, args);
}