summaryrefslogtreecommitdiff
path: root/py/emitnative.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-03-29 22:40:02 +1100
committerDamien George <damien@micropython.org>2022-03-30 16:32:17 +1100
commit7e8222ae063d78ae8f901bb0f9fef663edd2edb6 (patch)
tree679b8833e2d21b6e765e4ae6fe5219184e5ab68d /py/emitnative.c
parentbf3585b33c4fcd47edcf39494b7bc464a018b4fc (diff)
py/emitnative: Don't store prelude at end of machine code if not needed.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/emitnative.c')
-rw-r--r--py/emitnative.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index bddd66142..a207dd30f 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -723,7 +723,13 @@ STATIC bool emit_native_end_pass(emit_t *emit) {
if (emit->pass == MP_PASS_EMIT) {
void *f = mp_asm_base_get_code(&emit->as->base);
+ #if N_PRELUDE_AS_BYTES_OBJ
+ // Keep only the machine code, not the prelude, which is in a separate bytes object.
+ mp_uint_t f_len = emit->prelude_offset;
+ #else
+ // Keep both the machine code and the prelude.
mp_uint_t f_len = mp_asm_base_get_code_size(&emit->as->base);
+ #endif
mp_emit_glue_assign_native(emit->scope->raw_code,
emit->do_viper_types ? MP_CODE_NATIVE_VIPER : MP_CODE_NATIVE_PY,