-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
@@ -657,8 +657,7 @@ dummy_func( | |||
STACK_SHRINK(2); | |||
new_frame->localsplus[0] = container; | |||
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_instr
As we now specify
this_instr
in terms ofnext_instr
, we can rely on the C compiler to replacenext_instr - this_instr
with a constantunused variable ‘this_instr’
ingenerated_cases.c.h
#111537