py/emitnative: Don't store prelude at end of machine code if not needed.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-03-29 22:40:02 +11:00
parent bf3585b33c
commit 7e8222ae06
1 changed files with 6 additions and 0 deletions

View File

@ -723,7 +723,13 @@ STATIC bool emit_native_end_pass(emit_t *emit) {
if (emit->pass == MP_PASS_EMIT) { if (emit->pass == MP_PASS_EMIT) {
void *f = mp_asm_base_get_code(&emit->as->base); 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); mp_uint_t f_len = mp_asm_base_get_code_size(&emit->as->base);
#endif
mp_emit_glue_assign_native(emit->scope->raw_code, mp_emit_glue_assign_native(emit->scope->raw_code,
emit->do_viper_types ? MP_CODE_NATIVE_VIPER : MP_CODE_NATIVE_PY, emit->do_viper_types ? MP_CODE_NATIVE_VIPER : MP_CODE_NATIVE_PY,