Skip to content

gh-144145: Cleanups for object property tracking in JIT optimizer - #144366

Closed
Fidget-Spinner wants to merge 4 commits into
python:mainfrom
Fidget-Spinner:gh-144145-fixups
Closed

gh-144145: Cleanups for object property tracking in JIT optimizer#144366
Fidget-Spinner wants to merge 4 commits into
python:mainfrom
Fidget-Spinner:gh-144145-fixups

Conversation

@Fidget-Spinner

@Fidget-SpinnerFidget-Spinner commented Jan 31, 2026

Copy link
Copy Markdown
Member

So the previous PR set a good foundation and was always right as it depends on a runtime check. However, I just noticed some bugs that need cleanup:

  1. we can do better and eliminate the DEOPT_IF(attr != NULL) completely
  2. There's a bug with dealing with escapes. I added a test for that.

@Fidget-Spinner

Copy link
Copy Markdown
MemberAuthor

@cocolato can you review this please?

// Check escape
if (sym->descr.last_escape_index < ctx->last_escape_index) {
sym->descr.num_descrs = 0;
return _Py_uop_sym_new_unknown(ctx);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return_Py_uop_sym_new_unknown(ctx);
sym->descr.num_descrs=0;
sym->descr.last_escape_index=uop_buffer_length(&ctx->out_buffer);

Can we update the last_escape_index here to prevent subsequent set_attr calls from repeatedly clearing num_descrs?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

*(ctx->out_buffer.next++) = *this_instr;
}
// Track escapes - but skip when from init shim frame, since self hasn't escaped yet
bool is_init_shim = CURRENT_FRAME_IS_INIT_SHIM();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool is_init_shim = CURRENT_FRAME_IS_INIT_SHIM();

Perhaps we can remove the is_init_shim now.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to just use the variable for now.

@cocolato

Copy link
Copy Markdown
Member

Sorry for any undiscovered bugs, thanks for the fix!

@cocolato

Copy link
Copy Markdown
Member

Thanks, LGTM.

@Fidget-Spinner

Copy link
Copy Markdown
MemberAuthor

Thanks, LGTM.

Thanks! Please approve, and I will merge.

@cocolato

cocolato commented Feb 1, 2026

Copy link
Copy Markdown
Member

Thanks! Please approve, and I will merge.

Sorry, I don't have approve permission.

@cocolato

Copy link
Copy Markdown
Member

It should close after we revert #144122.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Fidget-Spinner@cocolato