diff options
author | Damien George <damien.p.george@gmail.com> | 2016-02-11 22:30:53 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-02-25 10:05:46 +0000 |
commit | ea23520403777f9b026f49245d39f8be1ccdbdac (patch) | |
tree | 949532b08d2614af11e8616a2d902ac8ca9ad3c2 /py/mpstate.h | |
parent | 57b96a7be214c8f2493db7d430348f5efcc8ad34 (diff) |
py: Add MICROPY_DYNAMIC_COMPILER option to config compiler at runtime.
This new compile-time option allows to make the bytecode compiler
configurable at runtime by setting the fields in the mp_dynamic_compiler
structure. By using this feature, the compiler can generate bytecode
that targets any MicroPython runtime/VM, regardless of the host and
target compile-time settings.
Options so far that fall under this dynamic setting are:
- maximum number of bits that a small int can hold;
- whether caching of lookups is used in the bytecode;
- whether to use unicode strings or not (lexer behaviour differs, and
therefore generated string constants differ).
Diffstat (limited to 'py/mpstate.h')
-rw-r--r-- | py/mpstate.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/py/mpstate.h b/py/mpstate.h index 7f8325b9a..0e77e6583 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -39,6 +39,16 @@ // memory system, runtime and virtual machine. The state is a global // variable, but in the future it is hoped that the state can become local. +// This structure contains dynamic configuration for the compiler. +#if MICROPY_DYNAMIC_COMPILER +typedef struct mp_dynamic_compiler_t { + uint8_t small_int_bits; // must be <= host small_int_bits + bool opt_cache_map_lookup_in_bytecode; + bool py_builtins_str_unicode; +} mp_dynamic_compiler_t; +extern mp_dynamic_compiler_t mp_dynamic_compiler; +#endif + // This structure hold information about the memory allocation system. typedef struct _mp_state_mem_t { #if MICROPY_MEM_STATS |