You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`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).
0 commit comments