Skip to content

Conversation

@Fidget-Spinner
Copy link
Member

@Fidget-SpinnerFidget-Spinner commented Jun 20, 2025

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

Very nice.

You can streamline the optimization a bit using sym_is_immortal and you might want to add a test for optimizing the POP_TOP after a call that returns None.

JitOptRef temp = retval;
// We wrap and unwrap the value to mimic PyStackRef_MakeHeapSafe
// in bytecodes.c
JitOptRef temp = PyJitRef_Wrap(PyJitRef_Unwrap(retval));
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This was a bug in the previous implementation. This was only exposed in this PR.

if (sym->tag == JIT_SYM_KNOWN_CLASS_TAG){
return sym->cls.type == &PyBool_Type;
}
if (sym->tag == JIT_SYM_TRUTHINESS_TAG){
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

A truthiness is not immortal. This is a false asumption.

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

Looks good.

This should wait for TOS caching, otherwise it is adding overhead to STORE_FAST. But once that is in, this makes a nice improvement.

@Fidget-SpinnerFidget-Spinner changed the title gh-134584: Specialize STORE_FAST by reference and type in JITgh-134584: Specialize POP_TOP by reference and type in JITJun 23, 2025
@Fidget-SpinnerFidget-Spinner merged commit 569fc68 into python:mainJun 23, 2025
69 checks passed
@Fidget-SpinnerFidget-Spinner deleted the eliminate_store_fast_refcount branch June 23, 2025 16:57
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Fidget-Spinner@markshannon@brianschubert