Commit 64b96de
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 c7edb9f commit 64b96de
3 files changed
+120
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
| |||
683 | 682 | | |
684 | 683 | | |
685 | 684 | | |
686 | | - | |
687 | 685 | | |
688 | 686 | | |
689 | 687 | | |
| |||
692 | 690 | | |
693 | 691 | | |
694 | 692 | | |
695 | | - | |
696 | 693 | | |
697 | 694 | | |
698 | 695 | | |
| |||
1271 | 1268 | | |
1272 | 1269 | | |
1273 | 1270 | | |
1274 | | - | |
1275 | 1271 | | |
1276 | 1272 | | |
1277 | 1273 | | |
| |||
1294 | 1290 | | |
1295 | 1291 | | |
1296 | 1292 | | |
1297 | | - | |
1298 | 1293 | | |
1299 | 1294 | | |
1300 | 1295 | | |
1301 | | - | |
1302 | 1296 | | |
1303 | 1297 | | |
1304 | 1298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2047 | 2047 | | |
2048 | 2048 | | |
2049 | 2049 | | |
2050 | | - | |
| 2050 | + | |
| 2051 | + | |
2051 | 2052 | | |
2052 | 2053 | | |
2053 | 2054 | | |
| |||
2069 | 2070 | | |
2070 | 2071 | | |
2071 | 2072 | | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
2072 | 2099 | | |
| 2100 | + | |
2073 | 2101 | | |
2074 | 2102 | | |
2075 | 2103 | | |
2076 | 2104 | | |
2077 | 2105 | | |
2078 | | - | |
| 2106 | + | |
2079 | 2107 | | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
2080 | 2133 | | |
2081 | 2134 | | |
| 2135 | + | |
2082 | 2136 | | |
2083 | 2137 | | |
2084 | 2138 | | |
| |||
2523 | 2577 | | |
2524 | 2578 | | |
2525 | 2579 | | |
2526 | | - | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
2527 | 2612 | | |
| 2613 | + | |
2528 | 2614 | | |
2529 | 2615 | | |
2530 | 2616 | | |
| |||
2705 | 2791 | | |
2706 | 2792 | | |
2707 | 2793 | | |
| 2794 | + | |
2708 | 2795 | | |
2709 | 2796 | | |
2710 | 2797 | | |
| 2798 | + | |
2711 | 2799 | | |
2712 | 2800 | | |
| 2801 | + | |
2713 | 2802 | | |
2714 | 2803 | | |
2715 | 2804 | | |
2716 | 2805 | | |
2717 | 2806 | | |
2718 | 2807 | | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
2719 | 2811 | | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
2720 | 2830 | | |
| 2831 | + | |
2721 | 2832 | | |
2722 | 2833 | | |
2723 | 2834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
366 | 372 | | |
367 | 373 | | |
368 | 374 | | |
| |||
0 commit comments