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.
This commit is contained in:
Damien George 2019-05-29 21:17:29 +10:00
parent bff4e13009
commit a4f1d82757
3 changed files with 5 additions and 1 deletions

View File

@ -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;

View File

@ -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

View File

@ -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) {