Skip to content

GH-138378: Move globals-to-consts pass into main optimizer pass#138379

Merged
markshannon merged 7 commits intopython:mainfrom
faster-cpython:move-globals-removal-to-main-optimizer-pass
Sep 18, 2025
Merged

GH-138378: Move globals-to-consts pass into main optimizer pass#138379
markshannon merged 7 commits intopython:mainfrom
faster-cpython:move-globals-removal-to-main-optimizer-pass

Conversation

@markshannon
Copy link
Copy Markdown
Member

@markshannon markshannon commented Sep 2, 2025

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 nice improvement!

Comment thread Include/internal/pycore_optimizer.h Outdated
// Max stacklen
int stack_len;
int locals_len;
uint32_t globals_checked_version;
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.

For consistency, this should be placed after the last few fields in the current struct and they should be commented. E.g. // globals to constant promotion.

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.

Fields should be in either ascending or descending order, for best packing, so I can't just add the fields at the end.
I'll add the comment.

Comment thread Python/optimizer_bytecodes.c Outdated
Comment thread Python/optimizer_bytecodes.c Outdated
Comment thread Python/optimizer_bytecodes.c Outdated
@markshannon markshannon marked this pull request as ready for review September 3, 2025 14:33
@markshannon markshannon requested a review from tomasr8 as a code owner September 3, 2025 14:33
@markshannon markshannon merged commit 3b83257 into python:main Sep 18, 2025
70 checks passed
@markshannon markshannon deleted the move-globals-removal-to-main-optimizer-pass branch September 18, 2025 09:10
Sign up for free to 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.

JIT global-to-constant promotion doesn't properly validate the globals dictionary at runtime

2 participants