-
Notifications
You must be signed in to change notification settings - Fork 601
Remove defunct OPs in Perl_scalar/Perl_scalarvoid #23890
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
Open
richardleach
wants to merge
1
commit into
Perl:blead
Choose a base branch
from
richardleach:scalavoid_null
base: blead
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−10
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cc16f93 to
64b96de
Compare
`my $x = (1,2,3);` produces the following OP tree in blead:
2 <;> nextstate(main 1 -e:1) v:{ ->3
6 <1> padsv_store[$x:1,2] vKS/LVINTRO ->7
5 <@> list sKP ->6
3 <0> pushmark v ->4
- <0> ex-const v ->-
- <0> ex-const v ->4
4 <$> const(IV 3) s ->5
- <0> ex-padsv sRM*/LVINTRO ->6
This is functionally equivalent to `my $x = 3;`:
2 <;> nextstate(main 1 -e:1) v:{ ->3
4 <1> padsv_store[$x:1,2] vKS/LVINTRO ->5
3 <$> const(IV 3) s ->4
- <0> ex-padsv sRM*/LVINTRO ->4
Construction of the first tree typically generates "Useless use of X
in scalar context" warnings, but special cases such as the constants
`0` and `1` are excluded from these warnings.
This commit modifies the functions responsible for assigning scalar
or void context to OPs to remove:
* `OP_NULL` nodes with no kids and a following sibling.
* `OP_LIST` nodes with only a single-scalar-pushing kid OP.
This transforms the first OP tree above into the second.
Besides having a "cleaner-looking" optree that's easier to follow when
debuggging Perl code or porting, there are other practical benefits:
* If the op_next chain hasn't been built, LINKLIST won't have to traverse
these OP nodes and link them in. Subsequent compiler steps then won't
re-traverse the same nodes to optimize them out of the op_next chain.
* Anything traversing - or cloning - the full optree has fewer defunct
OP nodes to visit.
* OP slabs may contain a higher proportion of live OPs, reducing
TLB pressure (on systems or workloads where that matters).
64b96de to
9a9c29f
Compare
Contributor
|
The change looks reasonable, though doing a coverage test they aren't hit much, the first part: The second part: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
my $x = (1,2,3);produces the following OP tree in blead:This is functionally equivalent to
my $x = 3;:Construction of the first tree typically generates "Useless use of X in scalar context" warnings, but special cases such as the constants
0and1are excluded from these warnings.This commit modifies the functions responsible for assigning scalar or void context to OPs to remove:
OP_NULLnodes with no kids and a following sibling.OP_LISTnodes with only a single-scalar-pushing kid OP.This transforms the first OP tree above into the second.
Besides having a "cleaner-looking" optree that's easier to follow when debuggging Perl code or porting, there are other practical benefits:
Note: this PR replaces #23523. It was easier to implement in op.c than I'd
originally anticipated and, as mentioned above, doing so reduces the number of
times such defunct nodes have to be processed during compilation.