Commit cc16f93
committed
Remove defunct OPs in Perl_scalar/Perl_scalarvoid
`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).1 parent 03f24b8 commit cc16f93
2 files changed
+114
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | 145 | | |
147 | 146 | | |
148 | 147 | | |
| |||
601 | 600 | | |
602 | 601 | | |
603 | 602 | | |
604 | | - | |
605 | 603 | | |
606 | 604 | | |
607 | 605 | | |
| |||
610 | 608 | | |
611 | 609 | | |
612 | 610 | | |
613 | | - | |
614 | 611 | | |
615 | 612 | | |
616 | 613 | | |
| |||
1189 | 1186 | | |
1190 | 1187 | | |
1191 | 1188 | | |
1192 | | - | |
1193 | 1189 | | |
1194 | 1190 | | |
1195 | 1191 | | |
| |||
1212 | 1208 | | |
1213 | 1209 | | |
1214 | 1210 | | |
1215 | | - | |
1216 | 1211 | | |
1217 | 1212 | | |
1218 | 1213 | | |
1219 | | - | |
1220 | 1214 | | |
1221 | 1215 | | |
1222 | 1216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2037 | 2037 | | |
2038 | 2038 | | |
2039 | 2039 | | |
2040 | | - | |
| 2040 | + | |
| 2041 | + | |
2041 | 2042 | | |
2042 | 2043 | | |
2043 | 2044 | | |
| |||
2059 | 2060 | | |
2060 | 2061 | | |
2061 | 2062 | | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
2062 | 2089 | | |
| 2090 | + | |
2063 | 2091 | | |
2064 | 2092 | | |
2065 | 2093 | | |
2066 | 2094 | | |
2067 | 2095 | | |
2068 | | - | |
| 2096 | + | |
2069 | 2097 | | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
2070 | 2123 | | |
2071 | 2124 | | |
| 2125 | + | |
2072 | 2126 | | |
2073 | 2127 | | |
2074 | 2128 | | |
| |||
2510 | 2564 | | |
2511 | 2565 | | |
2512 | 2566 | | |
2513 | | - | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
2514 | 2599 | | |
| 2600 | + | |
2515 | 2601 | | |
2516 | 2602 | | |
2517 | 2603 | | |
| |||
2692 | 2778 | | |
2693 | 2779 | | |
2694 | 2780 | | |
| 2781 | + | |
2695 | 2782 | | |
2696 | 2783 | | |
2697 | 2784 | | |
| 2785 | + | |
2698 | 2786 | | |
2699 | 2787 | | |
| 2788 | + | |
2700 | 2789 | | |
2701 | 2790 | | |
2702 | 2791 | | |
2703 | 2792 | | |
2704 | 2793 | | |
2705 | 2794 | | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
2706 | 2798 | | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
2707 | 2817 | | |
| 2818 | + | |
2708 | 2819 | | |
2709 | 2820 | | |
2710 | 2821 | | |
| |||
0 commit comments