Skip to content

Commit 5604b71

Browse files
committed
py/emitglue: When assigning bytecode only pass bytecode len if needed.
Most embedded targets will have this bit of the code disabled, saving a small amount of code space.
1 parent e98ff40 commit 5604b71

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

py/emitbc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ void mp_emit_bc_end_pass(emit_t *emit) {
437437

438438
} else if (emit->pass == MP_PASS_EMIT) {
439439
mp_emit_glue_assign_bytecode(emit->scope->raw_code, emit->code_base,
440+
#if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
440441
emit->code_info_size + emit->bytecode_size,
442+
#endif
441443
emit->const_table,
442444
#if MICROPY_PERSISTENT_CODE_SAVE
443445
emit->ct_cur_obj, emit->ct_cur_raw_code,

py/emitglue.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ mp_raw_code_t *mp_emit_glue_new_raw_code(void) {
5555
return rc;
5656
}
5757

58-
void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len,
58+
void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
59+
#if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
60+
size_t len,
61+
#endif
5962
const mp_uint_t *const_table,
6063
#if MICROPY_PERSISTENT_CODE_SAVE
6164
uint16_t n_obj, uint16_t n_raw_code,

py/emitglue.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ typedef struct _mp_raw_code_t {
6363

6464
mp_raw_code_t *mp_emit_glue_new_raw_code(void);
6565

66-
void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len,
66+
void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
67+
#if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
68+
size_t len,
69+
#endif
6770
const mp_uint_t *const_table,
6871
#if MICROPY_PERSISTENT_CODE_SAVE
6972
uint16_t n_obj, uint16_t n_raw_code,

py/persistentcode.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,11 @@ STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader) {
200200

201201
// create raw_code and return it
202202
mp_raw_code_t *rc = mp_emit_glue_new_raw_code();
203-
mp_emit_glue_assign_bytecode(rc, bytecode, bc_len, const_table,
203+
mp_emit_glue_assign_bytecode(rc, bytecode,
204+
#if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
205+
bc_len,
206+
#endif
207+
const_table,
204208
#if MICROPY_PERSISTENT_CODE_SAVE
205209
n_obj, n_raw_code,
206210
#endif

0 commit comments

Comments
 (0)