-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
GH-111537: Avoid using this_instr in asserts.
#111600
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
GH-111537: Avoid using this_instr in asserts.
#111600
Conversation
…n_offset = next_instr - this_instr' as can rely on C compiler to replace it with a constant
Python/bytecodes.c
Outdated
| new_frame->localsplus[1] = sub; | ||
| assert(1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR == next_instr - this_instr); | ||
| frame->return_offset = 1 + INLINE_CACHE_ENTRIES_BINARY_SUBSCR; | ||
| frame->return_offset = next_instr - this_instr; |
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.
This probably needs a cast to uint16_t
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.
It's guaranteed to be small. So, I think it should be OK. Let's see if MSVC complains.
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.
It does, indeed, complain
Replace
frame->return_offset = 1 + INLINE_CACHE_withframe->return_offset = next_instr - this_instrAs we now specify
this_instrin terms ofnext_instr, we can rely on the C compiler to replacenext_instr - this_instrwith a constantunused variable ‘this_instr’ingenerated_cases.c.h#111537