py/asmbase: Revert removal of clearing of label offsets for native emit.
The assembler back-end for most architectures needs to know if a jump is backwards in order to emit optimised machine code, and they do this by checking if the destination label has been set or not. So always reset label offsets to -1 (this reverts partially the previous commit, with some minor optimisation for the if-logic with the pass variable).
This commit is contained in:
parent
f935bce3c5
commit
53e111800f
@ -46,12 +46,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) {
|
void mp_asm_base_start_pass(mp_asm_base_t *as, int pass) {
|
||||||
if (pass == MP_ASM_PASS_COMPUTE) {
|
if (pass < MP_ASM_PASS_EMIT) {
|
||||||
#ifndef NDEBUG
|
// Reset labels so we can detect backwards jumps (and verify unique assignment)
|
||||||
// With debugging enabled labels are checked for unique assignment
|
|
||||||
memset(as->label_offsets, -1, as->max_num_labels * sizeof(size_t));
|
memset(as->label_offsets, -1, as->max_num_labels * sizeof(size_t));
|
||||||
#endif
|
} else {
|
||||||
} else if (pass == MP_ASM_PASS_EMIT) {
|
|
||||||
// allocating executable RAM is platform specific
|
// allocating executable RAM is platform specific
|
||||||
MP_PLAT_ALLOC_EXEC(as->code_offset, (void**)&as->code_base, &as->code_size);
|
MP_PLAT_ALLOC_EXEC(as->code_offset, (void**)&as->code_base, &as->code_size);
|
||||||
assert(as->code_base != NULL);
|
assert(as->code_base != NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user