Skip to content

gh-148438: implement _RECORD_BOUND_METHOD in JIT#148457

Merged
Fidget-Spinner merged 7 commits intopython:mainfrom
NekoAsakura:gh-148438/record-bound-method
Apr 12, 2026
Merged

gh-148438: implement _RECORD_BOUND_METHOD in JIT#148457
Fidget-Spinner merged 7 commits intopython:mainfrom
NekoAsakura:gh-148438/record-bound-method

Conversation

@NekoAsakura
Copy link
Copy Markdown
Contributor

@NekoAsakura NekoAsakura commented Apr 12, 2026

_RECORD_BOUND_METHOD records method object now, so _EXACT_ARGS needs to extract im_func out of it as well.

@NekoAsakura
Copy link
Copy Markdown
Contributor Author

Uh, didn't realise ADD_OP replaces the current instruction rather than adds after it. Should be sorted now.

// If no ADD_OP was called during this iteration, copy the original instruction
if (ctx->out_buffer.next == out_ptr) {
*(ctx->out_buffer.next++) = *this_instr;
}
assert(ctx->frame != NULL);

Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

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

Very close, thanks. Some tricky bits that I explain below.

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.

We can one-up this. If it's a probable constant callable, and the func_version matches, we can promote the callable to a known one, just like you did in_CHECK_METHOD_VERSION .

Also, heads up I'm merging my PR https://github.com/python/cpython/pull/146300/changes because _CHECK_FUNCTION_VERSION is wrong for the first if case.

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.

Oops sorry, my other PR's change does the same thing now to fix this. Sorry, please undo the change here and then I'll land my PR!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Roger :)

@NekoAsakura
Copy link
Copy Markdown
Contributor Author

Done. Will sort conflicts once #146300 is in. Really appreciate the review, cheers

Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

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

Thank you!

@Fidget-Spinner Fidget-Spinner merged commit 6349262 into python:main Apr 12, 2026
78 checks passed
@NekoAsakura NekoAsakura deleted the gh-148438/record-bound-method branch April 12, 2026 19:03
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