Skip to content

Commit f1c2faf

Browse files
authored
ZJIT: Ratchet down Guard* effects (ruby#16236)
Guards don't write to (e.g. PatchPoint) memory, just change if we side-exit into the interpreter or not, so lower their effects.
1 parent 7da5756 commit f1c2faf

2 files changed

Lines changed: 7 additions & 22 deletions

File tree

zjit/src/hir.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,13 +1230,13 @@ impl Insn {
12301230
Insn::FixnumRShift { .. } => effects::Empty,
12311231
Insn::ObjToString { .. } => effects::Any,
12321232
Insn::AnyToString { .. } => effects::Any,
1233-
Insn::GuardType { .. } => effects::Any,
1234-
Insn::GuardTypeNot { .. } => effects::Any,
1235-
Insn::GuardBitEquals { .. } => effects::Any,
1236-
Insn::GuardAnyBitSet { .. } => effects::Any,
1237-
Insn::GuardNoBitsSet { .. } => effects::Any,
1238-
Insn::GuardGreaterEq { .. } => effects::Any,
1239-
Insn::GuardLess { .. } => effects::Any,
1233+
Insn::GuardType { .. } => Effect::read_write(abstract_heaps::Empty, abstract_heaps::Control),
1234+
Insn::GuardTypeNot { .. } => Effect::read_write(abstract_heaps::Empty, abstract_heaps::Control),
1235+
Insn::GuardBitEquals { .. } => Effect::read_write(abstract_heaps::Empty, abstract_heaps::Control),
1236+
Insn::GuardAnyBitSet { .. } => Effect::read_write(abstract_heaps::Empty, abstract_heaps::Control),
1237+
Insn::GuardNoBitsSet { .. } => Effect::read_write(abstract_heaps::Empty, abstract_heaps::Control),
1238+
Insn::GuardGreaterEq { .. } => Effect::read_write(abstract_heaps::Empty, abstract_heaps::Control),
1239+
Insn::GuardLess { .. } => Effect::read_write(abstract_heaps::Empty, abstract_heaps::Control),
12401240
Insn::PatchPoint { .. } => Effect::read_write(abstract_heaps::PatchPoint, abstract_heaps::Control),
12411241
Insn::SideExit { .. } => effects::Any,
12421242
Insn::IncrCounter(_) => Effect::read_write(abstract_heaps::Empty, abstract_heaps::Other),
@@ -8507,7 +8507,6 @@ mod graphviz_tests {
85078507
<TR><TD ALIGN="left" PORT="v28">v28:Fixnum = GuardType v12, Fixnum&nbsp;</TD></TR>
85088508
<TR><TD ALIGN="left" PORT="v29">v29:Fixnum = FixnumOr v27, v28&nbsp;</TD></TR>
85098509
<TR><TD ALIGN="left" PORT="v30">IncrCounter inline_cfunc_optimized_send_count&nbsp;</TD></TR>
8510-
<TR><TD ALIGN="left" PORT="v21">PatchPoint NoTracePoint&nbsp;</TD></TR>
85118510
<TR><TD ALIGN="left" PORT="v22">CheckInterrupts&nbsp;</TD></TR>
85128511
<TR><TD ALIGN="left" PORT="v23">Return v29&nbsp;</TD></TR>
85138512
</TABLE>>];

zjit/src/hir/opt_tests.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ mod hir_opt_tests {
235235
v46:Fixnum[0] = Const Value(0)
236236
IncrCounter inline_cfunc_optimized_send_count
237237
v20:Fixnum[0] = Const Value(0)
238-
PatchPoint MethodRedefined(Integer@0x1000, *@0x1008, cme:0x1010)
239238
v39:Fixnum = GuardType v9, Fixnum
240239
v47:Fixnum[0] = Const Value(0)
241240
IncrCounter inline_cfunc_optimized_send_count
@@ -6091,8 +6090,6 @@ mod hir_opt_tests {
60916090
v23:HeapObject[class_exact*:Object@VALUE(0x1000)] = GuardType v6, HeapObject[class_exact*:Object@VALUE(0x1000)]
60926091
IncrCounter inline_iseq_optimized_send_count
60936092
v31:StaticSymbol[:b] = Const Value(VALUE(0x1038))
6094-
PatchPoint SingleRactorMode
6095-
PatchPoint NoSingletonClass(Object@0x1000)
60966093
PatchPoint MethodRedefined(Object@0x1000, one@0x1040, cme:0x1048)
60976094
v28:HeapObject[class_exact*:Object@VALUE(0x1000)] = GuardType v6, HeapObject[class_exact*:Object@VALUE(0x1000)]
60986095
IncrCounter inline_iseq_optimized_send_count
@@ -8649,7 +8646,6 @@ mod hir_opt_tests {
86498646
v20:CallableMethodEntry[VALUE(0x1040)] = GuardBitEquals v19, Value(VALUE(0x1040))
86508647
v21:RubyValue = LoadField v18, :_ep_specval@0x1048
86518648
v22:FalseClass = GuardBitEquals v21, Value(false)
8652-
PatchPoint MethodRedefined(Array@0x1000, pop@0x1008, cme:0x1010)
86538649
v28:CPtr = GetLEP
86548650
v29:RubyValue = LoadField v28, :_ep_method_entry@0x1038
86558651
v30:CallableMethodEntry[VALUE(0x1040)] = GuardBitEquals v29, Value(VALUE(0x1040))
@@ -8693,7 +8689,6 @@ mod hir_opt_tests {
86938689
v24:CallableMethodEntry[VALUE(0x1040)] = GuardBitEquals v23, Value(VALUE(0x1040))
86948690
v25:RubyValue = LoadField v22, :_ep_specval@0x1048
86958691
v26:FalseClass = GuardBitEquals v25, Value(false)
8696-
PatchPoint MethodRedefined(Array@0x1000, []@0x1008, cme:0x1010)
86978692
v36:CPtr = GetLEP
86988693
v37:RubyValue = LoadField v36, :_ep_method_entry@0x1038
86998694
v38:CallableMethodEntry[VALUE(0x1040)] = GuardBitEquals v37, Value(VALUE(0x1040))
@@ -9916,7 +9911,6 @@ mod hir_opt_tests {
99169911
PatchPoint NoSingletonClass(C@0x1008)
99179912
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
99189913
v25:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
9919-
PatchPoint NoSingletonClass(C@0x1008)
99209914
PatchPoint MethodRedefined(C@0x1008, foo@0x1040, cme:0x1048)
99219915
v29:TrueClass = Const Value(true)
99229916
IncrCounter inline_cfunc_optimized_send_count
@@ -9951,7 +9945,6 @@ mod hir_opt_tests {
99519945
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
99529946
v25:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
99539947
PatchPoint MethodRedefined(C@0x1008, respond_to_missing?@0x1040, cme:0x1048)
9954-
PatchPoint NoSingletonClass(C@0x1008)
99559948
PatchPoint MethodRedefined(C@0x1008, foo@0x1070, cme:0x1078)
99569949
v31:FalseClass = Const Value(false)
99579950
IncrCounter inline_cfunc_optimized_send_count
@@ -9987,7 +9980,6 @@ mod hir_opt_tests {
99879980
PatchPoint NoSingletonClass(C@0x1008)
99889981
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
99899982
v25:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
9990-
PatchPoint NoSingletonClass(C@0x1008)
99919983
PatchPoint MethodRedefined(C@0x1008, foo@0x1040, cme:0x1048)
99929984
v29:FalseClass = Const Value(false)
99939985
IncrCounter inline_cfunc_optimized_send_count
@@ -10024,7 +10016,6 @@ mod hir_opt_tests {
1002410016
PatchPoint NoSingletonClass(C@0x1008)
1002510017
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
1002610018
v27:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
10027-
PatchPoint NoSingletonClass(C@0x1008)
1002810019
PatchPoint MethodRedefined(C@0x1008, foo@0x1040, cme:0x1048)
1002910020
v31:FalseClass = Const Value(false)
1003010021
IncrCounter inline_cfunc_optimized_send_count
@@ -10061,7 +10052,6 @@ mod hir_opt_tests {
1006110052
PatchPoint NoSingletonClass(C@0x1008)
1006210053
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
1006310054
v27:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
10064-
PatchPoint NoSingletonClass(C@0x1008)
1006510055
PatchPoint MethodRedefined(C@0x1008, foo@0x1040, cme:0x1048)
1006610056
v31:FalseClass = Const Value(false)
1006710057
IncrCounter inline_cfunc_optimized_send_count
@@ -10098,7 +10088,6 @@ mod hir_opt_tests {
1009810088
PatchPoint NoSingletonClass(C@0x1008)
1009910089
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
1010010090
v27:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
10101-
PatchPoint NoSingletonClass(C@0x1008)
1010210091
PatchPoint MethodRedefined(C@0x1008, foo@0x1040, cme:0x1048)
1010310092
v31:TrueClass = Const Value(true)
1010410093
IncrCounter inline_cfunc_optimized_send_count
@@ -10134,7 +10123,6 @@ mod hir_opt_tests {
1013410123
PatchPoint NoSingletonClass(C@0x1008)
1013510124
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
1013610125
v27:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
10137-
PatchPoint NoSingletonClass(C@0x1008)
1013810126
PatchPoint MethodRedefined(C@0x1008, foo@0x1040, cme:0x1048)
1013910127
v31:TrueClass = Const Value(true)
1014010128
IncrCounter inline_cfunc_optimized_send_count
@@ -10170,7 +10158,6 @@ mod hir_opt_tests {
1017010158
PatchPoint NoSingletonClass(C@0x1008)
1017110159
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
1017210160
v27:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
10173-
PatchPoint NoSingletonClass(C@0x1008)
1017410161
PatchPoint MethodRedefined(C@0x1008, foo@0x1040, cme:0x1048)
1017510162
v31:TrueClass = Const Value(true)
1017610163
IncrCounter inline_cfunc_optimized_send_count
@@ -10205,7 +10192,6 @@ mod hir_opt_tests {
1020510192
PatchPoint MethodRedefined(C@0x1008, respond_to?@0x1010, cme:0x1018)
1020610193
v25:HeapObject[class_exact:C] = GuardType v9, HeapObject[class_exact:C]
1020710194
PatchPoint MethodRedefined(C@0x1008, respond_to_missing?@0x1040, cme:0x1048)
10208-
PatchPoint NoSingletonClass(C@0x1008)
1020910195
PatchPoint MethodRedefined(C@0x1008, foo@0x1070, cme:0x1078)
1021010196
v31:FalseClass = Const Value(false)
1021110197
IncrCounter inline_cfunc_optimized_send_count

0 commit comments

Comments
 (0)