diff options
| author | Damien George <damien.p.george@gmail.com> | 2015-11-02 17:27:18 +0000 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2015-11-13 12:49:18 +0000 |
| commit | c8e9c0d89afa90694790fd48e1bf527487a5beb7 (patch) | |
| tree | 91ca77ecc152b0c2ffc682c705b05b97ef55cf31 /py/emitnative.c | |
| parent | 713ea1800d1f0c82a0c75885ad034705556ab5ef (diff) | |
py: Add MICROPY_PERSISTENT_CODE so code can persist beyond the runtime.
Main changes when MICROPY_PERSISTENT_CODE is enabled are:
- qstrs are encoded as 2-byte fixed width in the bytecode
- all pointers are removed from bytecode and put in const_table (this
includes const objects and raw code pointers)
Ultimately this option will enable persistence for not just bytecode but
also native code.
Diffstat (limited to 'py/emitnative.c')
| -rw-r--r-- | py/emitnative.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/py/emitnative.c b/py/emitnative.c index d8f1640c0..2abc46c93 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -830,10 +830,16 @@ STATIC void emit_native_end_pass(emit_t *emit) { ASM_DATA(emit->as, 1, emit->scope->num_kwonly_args); ASM_DATA(emit->as, 1, emit->scope->num_def_pos_args); - // write code info (just contains block name and source file) + // write code info + #if MICROPY_PERSISTENT_CODE ASM_DATA(emit->as, 1, 5); - ASM_DATA(emit->as, 2, emit->scope->simple_name); - ASM_DATA(emit->as, 2, emit->scope->source_file); + ASM_DATA(emit->as, 1, emit->scope->simple_name); + ASM_DATA(emit->as, 1, emit->scope->simple_name >> 8); + ASM_DATA(emit->as, 1, emit->scope->source_file); + ASM_DATA(emit->as, 1, emit->scope->source_file >> 8); + #else + ASM_DATA(emit->as, 1, 1); + #endif // bytecode prelude: initialise closed over variables for (int i = 0; i < emit->scope->id_info_len; i++) { |
