Skip to content

Commit 319b5bb

Browse files
committed
ZJIT: Remove WriteBarrier for immediates
It doesn't end up generating any code (we catch this in codegen too) but we might as well not have the instruction lying around in our IR.
1 parent 3f994a3 commit 319b5bb

2 files changed

Lines changed: 4 additions & 30 deletions

File tree

zjit/src/hir.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6447,6 +6447,10 @@ impl Function {
64476447
_ => insn_id,
64486448
}
64496449
}
6450+
&Insn::WriteBarrier { val, .. } if self.is_a(val, types::Immediate) => {
6451+
// The write barrier does nothing for immediates.
6452+
continue;
6453+
}
64506454
&Insn::ArrayLength { array } => {
64516455
match self.type_of(array).ruby_object() {
64526456
Some(array_obj) if array_obj.is_frozen() => {

zjit/src/hir/opt_tests.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6172,7 +6172,6 @@ mod hir_opt_tests {
61726172
v63:CShape = LoadField v45, :shape_id@0x1090
61736173
v64:CShape[0x1091] = GuardBitEquals v63, CShape(0x1091) recompile
61746174
StoreField v45, :@x@0x1092, v15
6175-
WriteBarrier v45, v15
61766175
v67:CShape[0x1093] = Const CShape(0x1093)
61776176
StoreField v45, :shape_id@0x1090, v67
61786177
CheckInterrupts
@@ -7844,7 +7843,6 @@ mod hir_opt_tests {
78447843
v15:CShape = LoadField v14, :shape_id@0x1000
78457844
v16:CShape[0x1001] = GuardBitEquals v15, CShape(0x1001) recompile
78467845
StoreField v14, :@foo@0x1002, v10
7847-
WriteBarrier v14, v10
78487846
CheckInterrupts
78497847
Return v10
78507848
");
@@ -7916,7 +7914,6 @@ mod hir_opt_tests {
79167914
v15:CShape = LoadField v14, :shape_id@0x1000
79177915
v16:CShape[0x1001] = GuardBitEquals v15, CShape(0x1001) recompile
79187916
StoreField v14, :@foo@0x1002, v10
7919-
WriteBarrier v14, v10
79207917
v19:CShape[0x1003] = Const CShape(0x1003)
79217918
StoreField v14, :shape_id@0x1000, v19
79227919
CheckInterrupts
@@ -7985,13 +7982,11 @@ mod hir_opt_tests {
79857982
v14:CShape = LoadField v13, :shape_id@0x1000
79867983
v15:CShape[0x1001] = GuardBitEquals v14, CShape(0x1001) recompile
79877984
StoreField v13, :@foo@0x1002, v10
7988-
WriteBarrier v13, v10
79897985
v18:CShape[0x1003] = Const CShape(0x1003)
79907986
StoreField v13, :shape_id@0x1000, v18
79917987
v23:Fixnum[2] = Const Value(2)
79927988
PatchPoint SingleRactorMode
79937989
StoreField v13, :@bar@0x1004, v23
7994-
WriteBarrier v13, v23
79957990
v32:CShape[0x1005] = Const CShape(0x1005)
79967991
StoreField v13, :shape_id@0x1000, v32
79977992
CheckInterrupts
@@ -8064,14 +8059,12 @@ mod hir_opt_tests {
80648059
CondBranch v17, bb5(), bb6()
80658060
bb5():
80668061
StoreField v14, :@a@0x1002, v10
8067-
WriteBarrier v14, v10
80688062
v21:CShape[0x1003] = Const CShape(0x1003)
80698063
StoreField v14, :shape_id@0x1000, v21
80708064
Jump bb4()
80718065
bb6():
80728066
v24:CShape[0x1004] = GuardBitEquals v15, CShape(0x1004) recompile
80738067
StoreField v14, :@a@0x1005, v10
8074-
WriteBarrier v14, v10
80758068
Jump bb4()
80768069
bb4():
80778070
CheckInterrupts
@@ -10368,12 +10361,10 @@ mod hir_opt_tests {
1036810361
CondBranch v17, bb5(), bb6()
1036910362
bb5():
1037010363
StoreField v6, :@foo@0x1002, v10
10371-
WriteBarrier v6, v10
1037210364
Jump bb4()
1037310365
bb6():
1037410366
v22:CShape[0x1003] = GuardBitEquals v15, CShape(0x1003) recompile
1037510367
StoreField v6, :@foo@0x1004, v10
10376-
WriteBarrier v6, v10
1037710368
Jump bb4()
1037810369
bb4():
1037910370
CheckInterrupts
@@ -11677,7 +11668,6 @@ mod hir_opt_tests {
1167711668
v30:CShape = LoadField v28, :shape_id@0x1040
1167811669
v31:CShape[0x1041] = GuardBitEquals v30, CShape(0x1041)
1167911670
StoreField v28, :@foo@0x1042, v17
11680-
WriteBarrier v28, v17
1168111671
v34:CShape[0x1043] = Const CShape(0x1043)
1168211672
StoreField v28, :shape_id@0x1040, v34
1168311673
CheckInterrupts
@@ -11716,7 +11706,6 @@ mod hir_opt_tests {
1171611706
v30:CShape = LoadField v28, :shape_id@0x1040
1171711707
v31:CShape[0x1041] = GuardBitEquals v30, CShape(0x1041)
1171811708
StoreField v28, :@foo@0x1042, v17
11719-
WriteBarrier v28, v17
1172011709
v34:CShape[0x1043] = Const CShape(0x1043)
1172111710
StoreField v28, :shape_id@0x1040, v34
1172211711
CheckInterrupts
@@ -12547,7 +12536,6 @@ mod hir_opt_tests {
1254712536
v39:CInt64 = ArrayLength v33
1254812537
v40:CInt64[1] = GuardLess v46, v39
1254912538
ArrayAset v33, v40, v19
12550-
WriteBarrier v33, v19
1255112539
CheckInterrupts
1255212540
Return v19
1255312541
");
@@ -18783,12 +18771,10 @@ mod hir_opt_tests {
1878318771
v20:CShape = LoadField v19, :shape_id@0x1000
1878418772
v21:CShape[0x1001] = GuardBitEquals v20, CShape(0x1001) recompile
1878518773
StoreField v19, :@a@0x1002, v13
18786-
WriteBarrier v19, v13
1878718774
v24:CShape[0x1003] = Const CShape(0x1003)
1878818775
StoreField v19, :shape_id@0x1000, v24
1878918776
PatchPoint NoEPEscape(initialize)
1879018777
PatchPoint SingleRactorMode
18791-
WriteBarrier v19, v13
1879218778
CheckInterrupts
1879318779
Return v13
1879418780
");
@@ -18828,15 +18814,13 @@ mod hir_opt_tests {
1882818814
v23:CShape = LoadField v22, :shape_id@0x1000
1882918815
v24:CShape[0x1001] = GuardBitEquals v23, CShape(0x1001) recompile
1883018816
StoreField v22, :@a@0x1002, v16
18831-
WriteBarrier v22, v16
1883218817
v27:CShape[0x1003] = Const CShape(0x1003)
1883318818
StoreField v22, :shape_id@0x1000, v27
1883418819
v32:Fixnum[5] = Const Value(5)
1883518820
PatchPoint NoEPEscape(initialize)
1883618821
PatchPoint MethodRedefined(Integer@0x1008, +@0x1010, cme:0x1018)
1883718822
v65:Fixnum[6] = Const Value(6)
1883818823
PatchPoint SingleRactorMode
18839-
WriteBarrier v22, v16
1884018824
CheckInterrupts
1884118825
Return v16
1884218826
");
@@ -18874,13 +18858,10 @@ mod hir_opt_tests {
1887418858
v20:CShape = LoadField v19, :shape_id@0x1000
1887518859
v21:CShape[0x1001] = GuardBitEquals v20, CShape(0x1001) recompile
1887618860
StoreField v19, :@a@0x1002, v13
18877-
WriteBarrier v19, v13
1887818861
v24:CShape[0x1003] = Const CShape(0x1003)
1887918862
StoreField v19, :shape_id@0x1000, v24
1888018863
PatchPoint NoEPEscape(initialize)
1888118864
PatchPoint SingleRactorMode
18882-
WriteBarrier v19, v13
18883-
WriteBarrier v19, v13
1888418865
CheckInterrupts
1888518866
Return v13
1888618867
");
@@ -19369,7 +19350,6 @@ mod hir_opt_tests {
1936919350
v68:CShape = LoadField v18, :shape_id@0x1038
1937019351
v69:CShape[0x103b] = GuardBitEquals v68, CShape(0x103b) recompile
1937119352
StoreField v18, :@levar@0x103a, v19
19372-
WriteBarrier v18, v19
1937319353
v72:CShape[0x1039] = Const CShape(0x1039)
1937419354
StoreField v18, :shape_id@0x1038, v72
1937519355
Jump bb5(v18)
@@ -20160,15 +20140,13 @@ mod hir_opt_tests {
2016020140
CondBranch v23, bb5(), bb6()
2016120141
bb5():
2016220142
StoreField v11, :@a@0x1003, v17
20163-
WriteBarrier v11, v17
2016420143
Jump bb4()
2016520144
bb6():
2016620145
v28:CShape[0x1004] = Const CShape(0x1004)
2016720146
v29:CBool = IsBitEqual v21, v28
2016820147
CondBranch v29, bb7(), bb8()
2016920148
bb7():
2017020149
StoreField v11, :@a@0x1003, v17
20171-
WriteBarrier v11, v17
2017220150
v35:CShape[0x1002] = Const CShape(0x1002)
2017320151
StoreField v11, :shape_id@0x1001, v35
2017420152
Jump bb4()
@@ -20188,7 +20166,6 @@ mod hir_opt_tests {
2018820166
CondBranch v57, bb10(), bb11()
2018920167
bb10():
2019020168
StoreField v11, :@a@0x1003, v73
20191-
WriteBarrier v11, v73
2019220169
Jump bb9()
2019320170
bb11():
2019420171
SetIvar v11, :@a, v73
@@ -20219,15 +20196,13 @@ mod hir_opt_tests {
2021920196
CondBranch v23, bb5(), bb6()
2022020197
bb5():
2022120198
StoreField v11, :@a@0x1003, v17
20222-
WriteBarrier v11, v17
2022320199
Jump bb4()
2022420200
bb6():
2022520201
v28:CShape[0x1004] = Const CShape(0x1004)
2022620202
v29:CBool = IsBitEqual v21, v28
2022720203
CondBranch v29, bb7(), bb8()
2022820204
bb7():
2022920205
StoreField v11, :@a@0x1003, v17
20230-
WriteBarrier v11, v17
2023120206
v35:CShape[0x1002] = Const CShape(0x1002)
2023220207
StoreField v11, :shape_id@0x1001, v35
2023320208
Jump bb4()
@@ -21693,13 +21668,11 @@ mod hir_opt_tests {
2169321668
v117:CShape = LoadField v85, :shape_id@0x1090
2169421669
v118:CShape[0x1091] = GuardBitEquals v117, CShape(0x1091) recompile
2169521670
StoreField v85, :@x@0x1092, v15
21696-
WriteBarrier v85, v15
2169721671
v121:CShape[0x1093] = Const CShape(0x1093)
2169821672
StoreField v85, :shape_id@0x1090, v121
2169921673
PatchPoint NoEPEscape(initialize)
2170021674
PatchPoint SingleRactorMode
2170121675
StoreField v85, :@y@0x1094, v17
21702-
WriteBarrier v85, v17
2170321676
v136:CShape[0x1095] = Const CShape(0x1095)
2170421677
StoreField v85, :shape_id@0x1090, v136
2170521678
CheckInterrupts
@@ -21718,13 +21691,11 @@ mod hir_opt_tests {
2171821691
v157:CShape = LoadField v95, :shape_id@0x1090
2171921692
v158:CShape[0x1091] = GuardBitEquals v157, CShape(0x1091) recompile
2172021693
StoreField v95, :@x@0x1092, v47
21721-
WriteBarrier v95, v47
2172221694
v161:CShape[0x1093] = Const CShape(0x1093)
2172321695
StoreField v95, :shape_id@0x1090, v161
2172421696
PatchPoint NoEPEscape(initialize)
2172521697
PatchPoint SingleRactorMode
2172621698
StoreField v95, :@y@0x1094, v49
21727-
WriteBarrier v95, v49
2172821699
v176:CShape[0x1095] = Const CShape(0x1095)
2172921700
StoreField v95, :shape_id@0x1090, v176
2173021701
CheckInterrupts
@@ -21896,7 +21867,6 @@ mod hir_opt_tests {
2189621867
v71:Fixnum = GuardType v15, Fixnum recompile
2189721868
v72:Fixnum = FixnumAdd v71, v17
2189821869
StoreField v14, :@hclk@0x1003, v72
21899-
WriteBarrier v14, v72
2190021870
PatchPoint SingleRactorMode
2190121871
v37:BasicObject = LoadField v14, :@hclk_target@0x1040
2190221872
PatchPoint MethodRedefined(Integer@0x1008, <=@0x1041, cme:0x1048)

0 commit comments

Comments
 (0)