diff --git a/py/asmbase.c b/py/asmbase.c index c941e917b..83a699cd4 100644 --- a/py/asmbase.c +++ b/py/asmbase.c @@ -47,8 +47,10 @@ void mp_asm_base_deinit(mp_asm_base_t *as, bool free_code) { void mp_asm_base_start_pass(mp_asm_base_t *as, int pass) { if (pass == MP_ASM_PASS_COMPUTE) { - // reset all labels + #ifndef NDEBUG + // With debugging enabled labels are checked for unique assignment memset(as->label_offsets, -1, as->max_num_labels * sizeof(size_t)); + #endif } else if (pass == MP_ASM_PASS_EMIT) { // allocating executable RAM is platform specific MP_PLAT_ALLOC_EXEC(as->code_offset, (void**)&as->code_base, &as->code_size); diff --git a/py/emitbc.c b/py/emitbc.c index 3f4dfc178..5e7fa623a 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -313,9 +313,12 @@ void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { emit->scope = scope; emit->last_source_line_offset = 0; emit->last_source_line = 1; + #ifndef NDEBUG + // With debugging enabled labels are checked for unique assignment if (pass < MP_PASS_EMIT) { memset(emit->label_offsets, -1, emit->max_num_labels * sizeof(mp_uint_t)); } + #endif emit->bytecode_offset = 0; emit->code_info_offset = 0; @@ -495,7 +498,6 @@ void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) { emit->label_offsets[l] = emit->bytecode_offset; } else { // ensure label offset has not changed from MP_PASS_CODE_SIZE to MP_PASS_EMIT - //printf("l%d: (at %d vs %d)\n", l, emit->bytecode_offset, emit->label_offsets[l]); assert(emit->label_offsets[l] == emit->bytecode_offset); } }