py/{emitbc,asmbase}: Only clear emit labels to -1 when in debug mode.
Clearing the labels to -1 is purely a debugging measure. For release builds there is no need to do it as the label offset table should always have the correct value assigned.
This commit is contained in:
parent
9ef4be8b41
commit
f935bce3c5
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user