Skip to content

py/emitnative: Fix case of clobbered REG_TEMP0 when loading const obj. #15573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions py/emitnative.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ static void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
#endif
}

// This function may clobber REG_TEMP0 (and `reg_dest` can be REG_TEMP0).
static void emit_native_mov_reg_qstr_obj(emit_t *emit, int reg_dest, qstr qst) {
#if MICROPY_PERSISTENT_CODE_SAVE
emit_load_reg_with_object(emit, reg_dest, MP_OBJ_NEW_QSTR(qst));
Expand Down Expand Up @@ -1117,6 +1118,7 @@ static exc_stack_entry_t *emit_native_pop_exc_stack(emit_t *emit) {
return e;
}

// This function will clobber REG_TEMP0 (and `reg` can be REG_TEMP0).
static void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t obj) {
emit->scope->scope_flags |= MP_SCOPE_FLAG_HASCONSTS;
size_t table_off = mp_emit_common_use_const_obj(emit->emit_common, obj);
Expand Down Expand Up @@ -1391,9 +1393,9 @@ static void emit_native_load_const_str(emit_t *emit, qstr qst) {

static void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) {
emit_native_pre(emit);
need_reg_single(emit, REG_RET, 0);
emit_load_reg_with_object(emit, REG_RET, obj);
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
need_reg_single(emit, REG_TEMP0, 0);
emit_load_reg_with_object(emit, REG_TEMP0, obj);
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_TEMP0);
}

static void emit_native_load_null(emit_t *emit) {
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy