Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
gh-106581: Split
CALL_PY_EXACT_ARGS
into uops #107760New 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-106581: Split
CALL_PY_EXACT_ARGS
into uops #107760Changes from all commits
56133bb
907ff95
2c6be6d
6d78ff2
0d8e66c
b75f30e
61c2822
f73ea90
12910fc
2fafa2c
2717b07
e487908
1d549af
f40fb1f
4f6f8f8
6facc8d
94630d4
cf8e2c0
1e62876
05af848
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Since
_PUSH_FRAME
is justframe->return_offset = 0; DISPATCH_INLINED(new_frame);
, it would make sense to spell outDISPATCH_INLINED
to clarify which operations that need to be different for tier 1 and tier 2.Something like:
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.
For example: 2b3e6f2
In which case the code generators needs to know to push the temporary stack values to the real stack before
SAVE_FRAME_STATE()
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.
I have to study this more. A problem is that the Tier 1 and Tier 2 versions of
_PUSH_FRAME
are so different. I am working on a mechanism to be able to sayI'm not sure yet what you mean with your last remark about pushing temp stack values.
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.
Comparing carefully the two versions of
DISPATCH_INLINED
(addingframe->return_offset = 0
which precedes it in both cases):In Tier 1:
In Tier 2:
Diff:
Note that the Tier 2 version must be preceded by a
SAVE_IP
, which does the equivalent offrame->prev_instr = next_instr
. If we had a Tier 1 version ofSAVE_IP
we could include it in the macro definition:which would reduce the special-casing in the code generator a bit (it would still need to do something special for
SAVE_IP
to ensure that itsoparg
has the right value, different from theoparg
of the macro (which is the argument count). This would take care of the first diff chunk (what to assign toframe->prev_inst
), but it would still be pretty fragile. (Like my current version, it would entice the optimizer to incorrectly try to remove theSAVE_IP
uop.)The second diff chunk relates to how we set
cframe.current_frame
-- in Tier 2 we must access this through thetstate
.The third and final diff chunk relates to really start using the new frame. In Tier 1, this must actually do the following:
stack_pointer
next_instr
This is done by the code at
start_frame
.In Tier 2 there is no
start_frame
label (the only uop that can go to a label isEXIT_TRACE
, and of courseDEOPT_IF
andERROR_IF
also jump). So we loadstack_frame
here. There is no direct equivalent tonext_instr
, but we have to setip_offset
, whichSAVE_IP
adds to itsoparg
to get theprev_instr
value. (This variable is a cache forframe->code->co_code_adaptive
, to save some memory loads, so wheneverframe
changes we must update it.)(More later.)
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.
There's another thing though, and I think that is what Mark meant. In Tier 1 the code generation for macros is special-cased for
_PUSH_FRAME
so that both the stack adjustment and thenext_instr
adjustment are emitted before the_PUSH_FRAME
opcode. This is done so that the flushing of these variables to the frame in theDISPATCH_INLINED
macro flush the correct values.But this is really ugly and unprincipled, and the logic is much hairier than the other special cases for
_PUSH_FRAME
. One of Mark's ideas here is to make this special case look for uops using theSAVE_FRAME_STATE
macro rather than for the specific uop_PUSH_FRAME
. But detecting when to trigger the special case is only part of the problem -- IMO the worse problem is that the special case itself is so ugly:The last 4 lines here, starting with
# Use clone()
, occur further down too, for the normal case (after the final uop). I don't even recall why thetemp.deeper()
call is needed!I'll mull this over some more.
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.
I think I have addressed this. @markshannon Please have another look. Assuming the tests look okay I'll un-draft this.