Skip to content

gh-148571: [JIT] Preserve family-head recorder layouts for specialized opcode families#148730

Open
cocolato wants to merge 5 commits intopython:mainfrom
cocolato:jit_record_family
Open

gh-148571: [JIT] Preserve family-head recorder layouts for specialized opcode families#148730
cocolato wants to merge 5 commits intopython:mainfrom
cocolato:jit_record_family

Conversation

@cocolato
Copy link
Copy Markdown
Member

@cocolato cocolato commented Apr 18, 2026

Refer: #148571 (comment)

TRACE_RECORD captures snapshot values before execution, but the bytecode subsequently translated into the trace may have been transformed into specialized ops within the same family.

So if this specialized op inherits the recorder layout from the family head but actually requires a derived value—such as a type object, generator function, or bound method payload—a mismatch arises between the recorder layout and the consumption semantics.

The fix implemented in this change is as follows:

Have the base opcode of each affected family uniformly record the widest raw/base value required by the entire family, while leaving the semantics of existing _RECORD_* uops unchanged. If a specialized family member still requires a derived view, the optimizer projects the raw recorded value into the form it actually needs to consume on-demand during the trace translation phase.

Some related issues: #148716 #148618

family_head = analysis.instructions[inst.family.name]
if family_head.properties.records_value:
source_inst = family_head
is_family_override = family_head is not inst
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think marking it as an override only when the member's recording differs from the head's is better than forcing GET_ITER through a redundant transformation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, but more changes are needed. We might need to add a metadata mapping table for the family slot later on, which would also help us handle multi-record operations. Let’s wait for others to review this.

uint8_t indices[MAX_RECORDED_VALUES];
} _PyOpcodeRecordEntry;
PyAPI_DATA(const _PyOpcodeRecordEntry) _PyOpcode_RecordEntries[256];
PyAPI_DATA(const uint8_t) _PyOpcode_RecordIsFamilyOverride[256];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bool?

Sign up for free to 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