Commit 0916e47
committed
ZJIT: Skip redundant cfp->sp stores
gen_save_sp() stored cfp->sp before every C call and JIT-to-JIT call,
even when an earlier call in the same basic block had already written
the same value and nothing could have changed it in between: callees
write only their own cfp->sp, side exits and exception unwinding never
return to the same code, and rb_zjit_materialize_frames() only reads
cfp->sp.
Track the stack size of the last cfp->sp store emitted in the current
basic block in the Assembler and skip stores that would write the same
value again. The cache is cleared at block boundaries (but preserved
across split_block_jump() fall-throughs, which have a single
predecessor), when PushInlineFrame/PopInlineFrame change which frame
the SP/CFP registers point at, and after gen_prepare_fallback_call(),
whose VM helpers execute an instruction on the current frame and move
cfp->sp (e.g. vm_sendish() popping the receiver and arguments), which
the test_regression_cfp_sp_set_correctly_before_leaf_gc_call test
caught.1 parent 058aa08 commit 0916e47
2 files changed
Lines changed: 63 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2020 | 2020 | | |
2021 | 2021 | | |
2022 | 2022 | | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
2023 | 2030 | | |
2024 | 2031 | | |
2025 | 2032 | | |
| |||
2038 | 2045 | | |
2039 | 2046 | | |
2040 | 2047 | | |
| 2048 | + | |
2041 | 2049 | | |
2042 | 2050 | | |
2043 | 2051 | | |
| |||
2120 | 2128 | | |
2121 | 2129 | | |
2122 | 2130 | | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
2123 | 2162 | | |
2124 | 2163 | | |
2125 | 2164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
3013 | 3013 | | |
3014 | 3014 | | |
3015 | 3015 | | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
3016 | 3020 | | |
3017 | 3021 | | |
3018 | 3022 | | |
| |||
3034 | 3038 | | |
3035 | 3039 | | |
3036 | 3040 | | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
3037 | 3046 | | |
3038 | 3047 | | |
3039 | 3048 | | |
| |||
5366 | 5375 | | |
5367 | 5376 | | |
5368 | 5377 | | |
| 5378 | + | |
| 5379 | + | |
| 5380 | + | |
| 5381 | + | |
| 5382 | + | |
| 5383 | + | |
| 5384 | + | |
| 5385 | + | |
5369 | 5386 | | |
5370 | 5387 | | |
5371 | 5388 | | |
| |||
5420 | 5437 | | |
5421 | 5438 | | |
5422 | 5439 | | |
| 5440 | + | |
| 5441 | + | |
| 5442 | + | |
| 5443 | + | |
| 5444 | + | |
| 5445 | + | |
5423 | 5446 | | |
5424 | 5447 | | |
5425 | 5448 | | |
| |||
0 commit comments