mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
py/persistentcode: Decouple native code loading from emitters' presence.
This commit lets the interpreter load MPY files containing native code even if the target platform does not have a native emitter, or if native code generation is disabled. Native code loading has been tied to native code generation being enabled as a discriminant to allow said operation. This blocks native code loading on platforms that could benefit from such a thing but they don't (and probably won't) have a native code generation target written for them (ie. AArch64 and RISC-V 64). This also forces a firmware image to have a full native code compiler present even if it doesn't need to generate anything, as native modules already have all the code they will ever need to load. There is a new configuration setting, MICROPY_PERSISTENT_CODE_LOAD_NATIVE, that if enabled it will allow loading native code modules even if code generation (MICROPY_EMIT_<platform> and MICROPY_EMIT_INLINE_<platform>) is explicitly turned off. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
10
py/objfun.c
10
py/objfun.c
@@ -136,7 +136,7 @@ qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) {
|
||||
const mp_obj_fun_bc_t *fun = MP_OBJ_TO_PTR(fun_in);
|
||||
const byte *bc = fun->bytecode;
|
||||
|
||||
#if MICROPY_EMIT_NATIVE
|
||||
#if MICROPY_ENABLE_NATIVE_CODE
|
||||
if (fun->base.type == &mp_type_fun_native || fun->base.type == &mp_type_native_gen_wrap) {
|
||||
bc = mp_obj_fun_native_get_prelude_ptr(fun);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_
|
||||
/******************************************************************************/
|
||||
/* native functions */
|
||||
|
||||
#if MICROPY_EMIT_NATIVE
|
||||
#if MICROPY_ENABLE_NATIVE_CODE
|
||||
|
||||
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_cstack_check();
|
||||
@@ -472,13 +472,9 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
call, fun_native_call
|
||||
);
|
||||
|
||||
#endif // MICROPY_EMIT_NATIVE
|
||||
|
||||
/******************************************************************************/
|
||||
/* viper functions */
|
||||
|
||||
#if MICROPY_EMIT_NATIVE
|
||||
|
||||
static mp_obj_t fun_viper_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_cstack_check();
|
||||
mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
@@ -493,7 +489,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
call, fun_viper_call
|
||||
);
|
||||
|
||||
#endif // MICROPY_EMIT_NATIVE
|
||||
#endif // MICROPY_ENABLE_NATIVE_CODE
|
||||
|
||||
/******************************************************************************/
|
||||
/* inline assembler functions */
|
||||
|
||||
Reference in New Issue
Block a user