From a4f1d82757b8e95c21a095c99b7c3f04ded88104 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 29 May 2019 21:17:29 +1000 Subject: [PATCH] py/nativeglue: Remove dependency on mp_fun_table in dyn-compiler mode. mpy-cross uses MICROPY_DYNAMIC_COMPILER and MICROPY_EMIT_NATIVE but does not actually need to execute native functions, and does not need mp_fun_table. This commit makes it so mp_fun_table and all its entries are not built when MICROPY_DYNAMIC_COMPILER is enabled, significantly reducing the size of the mpy-cross executable and allowing it to be built on more machines/OS's. --- py/emitnative.c | 3 +++ py/mpconfig.h | 1 + py/nativeglue.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/py/emitnative.c b/py/emitnative.c index f123ecbb58..278cc21e78 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -609,8 +609,11 @@ STATIC void emit_native_end_pass(emit_t *emit) { const_table_alloc += nqstr; } emit->const_table = m_new(mp_uint_t, const_table_alloc); + #if !MICROPY_DYNAMIC_COMPILER // Store mp_fun_table pointer just after qstrs + // (but in dynamic-compiler mode eliminate dependency on mp_fun_table) emit->const_table[nqstr] = (mp_uint_t)(uintptr_t)mp_fun_table; + #endif #if MICROPY_PERSISTENT_CODE_SAVE size_t qstr_link_alloc = emit->qstr_link_cur; diff --git a/py/mpconfig.h b/py/mpconfig.h index 219f8de44b..4172e175b2 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -338,6 +338,7 @@ #endif // Whether the compiler is dynamically configurable (ie at runtime) +// This will disable the ability to execute native/viper code #ifndef MICROPY_DYNAMIC_COMPILER #define MICROPY_DYNAMIC_COMPILER (0) #endif diff --git a/py/nativeglue.c b/py/nativeglue.c index 8f38ecd16e..11d7a283a2 100644 --- a/py/nativeglue.c +++ b/py/nativeglue.c @@ -95,7 +95,7 @@ mp_obj_t mp_native_to_obj(mp_uint_t val, mp_uint_t type) { #endif -#if MICROPY_EMIT_NATIVE +#if MICROPY_EMIT_NATIVE && !MICROPY_DYNAMIC_COMPILER STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) { if (new_globals == NULL) {