py: Add MICROPY_ENABLE_COMPILER and MICROPY_PY_BUILTINS_EVAL_EXEC opts.
MICROPY_ENABLE_COMPILER can be used to enable/disable the entire compiler,
which is useful when only loading of pre-compiled bytecode is supported.
It is enabled by default.
MICROPY_PY_BUILTINS_EVAL_EXEC controls support of eval and exec builtin
functions. By default they are only included if MICROPY_ENABLE_COMPILER
is enabled.
Disabling both options saves about 40k of code size on 32-bit x86.
diff --git a/py/runtime.c b/py/runtime.c
index c9a56f6..3a1f588 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -1304,6 +1304,8 @@
}
}
+#if MICROPY_ENABLE_COMPILER
+
// this is implemented in this file so it can optimise access to locals/globals
mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals) {
// save context
@@ -1342,6 +1344,8 @@
}
}
+#endif // MICROPY_ENABLE_COMPILER
+
void *m_malloc_fail(size_t num_bytes) {
DEBUG_printf("memory allocation failed, allocating " UINT_FMT " bytes\n", num_bytes);
if (0) {