-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Bytecode oparg optimization #7032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bytecode oparg optimization #7032
Conversation
📝 WalkthroughWalkthroughThis PR refactors bytecode enum handling and casting patterns across the compiler. It replaces explicit u32 casts with standard conversion functions (u32::from()), removes the num_enum dependency, adds Debug derives to bytecode types, macro-generates oparg enum definitions and trait implementations, and removes const qualifiers from eval_ord methods. All changes maintain functional equivalence while modernizing the codebase. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| $vis enum $name { | ||
| $( | ||
| $(#[$variant_meta])* | ||
| $variant, // Do assign value to variant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youknowone This breaks RustPython. if I put $variant = $value then everything works just fine.
I suspect that there's some unsafe transmuting somewhere, do you have an idea how can I debug this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After lots of debugging I've figured that the only problematic enum is ComparisonOperator. I'm not sure about why yet, but it's not related to an unsafe transmutation like I initially thought
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ComparisonOperator seems to support bit operation. It doesn't have 0 like other enums
Discussed at #6980 (comment)
Pretty much reverts #6980.
Summary by CodeRabbit
Chores
Refactor