summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-05-29 21:17:29 +1000
committerDamien George <damien.p.george@gmail.com>2019-05-29 21:17:29 +1000
commita4f1d82757b8e95c21a095c99b7c3f04ded88104 (patch)
tree6c3f0112c2785e531b8cec986a6740665e1aa300 /py
parentbff4e130099e2ec17478bb00f7eaa5d85fb763dc (diff)
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.
Diffstat (limited to 'py')
-rw-r--r--py/emitnative.c3
-rw-r--r--py/mpconfig.h1
-rw-r--r--py/nativeglue.c2
3 files changed, 5 insertions, 1 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index f123ecbb5..278cc21e7 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 219f8de44..4172e175b 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 8f38ecd16..11d7a283a 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) {