Feature or enhancement
Proposal:
Motivation
We should implement unique reference tracking in Tier 2 to facilitate optimizations that reduce reference counting overhead. For example, when a tuple is known to be uniquely referenced, we can "steal" its element references during unpacking without performing any reference counting operations.
For reference: discussion in #142952
Technical Approach
- Reference Tracking Infrastructure
- Add an
REF_IS_UNIQUE bit (bit 1) to the JitOptRef union in pycore_optimizer.h (code reference).
- Implement
PyJitRef_MakeUnique() and PyJitRef_IsUnique() helper functions.
- Update helper utilities including
PyJitRef_StripReferenceInfo and JIT_BITS_TO_PTR_MASKED to support this unique reference bit.
- Apply unique reference tracking to UNPACK_SEQUENCE uops
- Expand support to more uops
- After verifying performance and correctness, extend the use of unique reference tracking to additional uops and optimizations as identified.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs