Skip to content

Commit 14e34fa

Browse files
committed
ZJIT: Print class objects more nicely in HIR
1 parent ff89e47 commit 14e34fa

File tree

2 files changed

+45
-43
lines changed

2 files changed

+45
-43
lines changed

zjit/src/hir/opt_tests.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ mod hir_opt_tests {
22992299
bb2(v6:BasicObject):
23002300
PatchPoint SingleRactorMode
23012301
PatchPoint StableConstantNames(0x1000, C)
2302-
v18:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
2302+
v18:Class[C@0x1008] = Const Value(VALUE(0x1008))
23032303
CheckInterrupts
23042304
Return v18
23052305
");
@@ -2323,16 +2323,16 @@ mod hir_opt_tests {
23232323
bb2(v6:BasicObject):
23242324
PatchPoint SingleRactorMode
23252325
PatchPoint StableConstantNames(0x1000, String)
2326-
v29:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
2326+
v29:Class[String@0x1008] = Const Value(VALUE(0x1008))
23272327
PatchPoint SingleRactorMode
23282328
PatchPoint StableConstantNames(0x1010, Class)
2329-
v32:Class[VALUE(0x1018)] = Const Value(VALUE(0x1018))
2329+
v32:Class[Class@0x1018] = Const Value(VALUE(0x1018))
23302330
PatchPoint SingleRactorMode
23312331
PatchPoint StableConstantNames(0x1020, Module)
2332-
v35:Class[VALUE(0x1028)] = Const Value(VALUE(0x1028))
2332+
v35:Class[Module@0x1028] = Const Value(VALUE(0x1028))
23332333
PatchPoint SingleRactorMode
23342334
PatchPoint StableConstantNames(0x1030, BasicObject)
2335-
v38:Class[VALUE(0x1038)] = Const Value(VALUE(0x1038))
2335+
v38:Class[BasicObject@0x1038] = Const Value(VALUE(0x1038))
23362336
v22:ArrayExact = NewArray v29, v32, v35, v38
23372337
CheckInterrupts
23382338
Return v22
@@ -2954,7 +2954,7 @@ mod hir_opt_tests {
29542954
bb2(v6:BasicObject):
29552955
PatchPoint SingleRactorMode
29562956
PatchPoint StableConstantNames(0x1000, Foo::Bar::C)
2957-
v18:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
2957+
v18:Class[Foo::Bar::C@0x1008] = Const Value(VALUE(0x1008))
29582958
CheckInterrupts
29592959
Return v18
29602960
");
@@ -2979,11 +2979,11 @@ mod hir_opt_tests {
29792979
bb2(v6:BasicObject):
29802980
PatchPoint SingleRactorMode
29812981
PatchPoint StableConstantNames(0x1000, C)
2982-
v43:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
2982+
v43:Class[C@0x1008] = Const Value(VALUE(0x1008))
29832983
v13:NilClass = Const Value(nil)
2984-
PatchPoint MethodRedefined(C@0x1008, new@0x1010, cme:0x1018)
2984+
PatchPoint MethodRedefined(C@0x1008, new@0x1009, cme:0x1010)
29852985
v46:HeapObject[class_exact:C] = ObjectAllocClass C:VALUE(0x1008)
2986-
PatchPoint MethodRedefined(C@0x1008, initialize@0x1040, cme:0x1048)
2986+
PatchPoint MethodRedefined(C@0x1008, initialize@0x1038, cme:0x1040)
29872987
PatchPoint NoSingletonClass(C@0x1008)
29882988
v50:NilClass = Const Value(nil)
29892989
IncrCounter inline_cfunc_optimized_send_count
@@ -3016,14 +3016,14 @@ mod hir_opt_tests {
30163016
bb2(v6:BasicObject):
30173017
PatchPoint SingleRactorMode
30183018
PatchPoint StableConstantNames(0x1000, C)
3019-
v46:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
3019+
v46:Class[C@0x1008] = Const Value(VALUE(0x1008))
30203020
v13:NilClass = Const Value(nil)
30213021
v16:Fixnum[1] = Const Value(1)
3022-
PatchPoint MethodRedefined(C@0x1008, new@0x1010, cme:0x1018)
3022+
PatchPoint MethodRedefined(C@0x1008, new@0x1009, cme:0x1010)
30233023
v49:HeapObject[class_exact:C] = ObjectAllocClass C:VALUE(0x1008)
3024-
PatchPoint MethodRedefined(C@0x1008, initialize@0x1040, cme:0x1048)
3024+
PatchPoint MethodRedefined(C@0x1008, initialize@0x1038, cme:0x1040)
30253025
PatchPoint NoSingletonClass(C@0x1008)
3026-
v52:BasicObject = SendWithoutBlockDirect v49, :initialize (0x1070), v16
3026+
v52:BasicObject = SendWithoutBlockDirect v49, :initialize (0x1068), v16
30273027
CheckInterrupts
30283028
CheckInterrupts
30293029
Return v49
@@ -3048,11 +3048,11 @@ mod hir_opt_tests {
30483048
bb2(v6:BasicObject):
30493049
PatchPoint SingleRactorMode
30503050
PatchPoint StableConstantNames(0x1000, Object)
3051-
v43:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
3051+
v43:Class[Object@0x1008] = Const Value(VALUE(0x1008))
30523052
v13:NilClass = Const Value(nil)
3053-
PatchPoint MethodRedefined(Object@0x1008, new@0x1010, cme:0x1018)
3053+
PatchPoint MethodRedefined(Object@0x1008, new@0x1009, cme:0x1010)
30543054
v46:ObjectExact = ObjectAllocClass Object:VALUE(0x1008)
3055-
PatchPoint MethodRedefined(Object@0x1008, initialize@0x1040, cme:0x1048)
3055+
PatchPoint MethodRedefined(Object@0x1008, initialize@0x1038, cme:0x1040)
30563056
PatchPoint NoSingletonClass(Object@0x1008)
30573057
v50:NilClass = Const Value(nil)
30583058
IncrCounter inline_cfunc_optimized_send_count
@@ -3080,11 +3080,11 @@ mod hir_opt_tests {
30803080
bb2(v6:BasicObject):
30813081
PatchPoint SingleRactorMode
30823082
PatchPoint StableConstantNames(0x1000, BasicObject)
3083-
v43:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
3083+
v43:Class[BasicObject@0x1008] = Const Value(VALUE(0x1008))
30843084
v13:NilClass = Const Value(nil)
3085-
PatchPoint MethodRedefined(BasicObject@0x1008, new@0x1010, cme:0x1018)
3085+
PatchPoint MethodRedefined(BasicObject@0x1008, new@0x1009, cme:0x1010)
30863086
v46:BasicObjectExact = ObjectAllocClass BasicObject:VALUE(0x1008)
3087-
PatchPoint MethodRedefined(BasicObject@0x1008, initialize@0x1040, cme:0x1048)
3087+
PatchPoint MethodRedefined(BasicObject@0x1008, initialize@0x1038, cme:0x1040)
30883088
PatchPoint NoSingletonClass(BasicObject@0x1008)
30893089
v50:NilClass = Const Value(nil)
30903090
IncrCounter inline_cfunc_optimized_send_count
@@ -3112,9 +3112,9 @@ mod hir_opt_tests {
31123112
bb2(v6:BasicObject):
31133113
PatchPoint SingleRactorMode
31143114
PatchPoint StableConstantNames(0x1000, Hash)
3115-
v43:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
3115+
v43:Class[Hash@0x1008] = Const Value(VALUE(0x1008))
31163116
v13:NilClass = Const Value(nil)
3117-
PatchPoint MethodRedefined(Hash@0x1008, new@0x1010, cme:0x1018)
3117+
PatchPoint MethodRedefined(Hash@0x1008, new@0x1009, cme:0x1010)
31183118
v46:HashExact = ObjectAllocClass Hash:VALUE(0x1008)
31193119
IncrCounter complex_arg_pass_param_kw
31203120
IncrCounter complex_arg_pass_param_block
@@ -3144,13 +3144,13 @@ mod hir_opt_tests {
31443144
bb2(v6:BasicObject):
31453145
PatchPoint SingleRactorMode
31463146
PatchPoint StableConstantNames(0x1000, Array)
3147-
v46:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
3147+
v46:Class[Array@0x1008] = Const Value(VALUE(0x1008))
31483148
v13:NilClass = Const Value(nil)
31493149
v16:Fixnum[1] = Const Value(1)
3150-
PatchPoint MethodRedefined(Array@0x1008, new@0x1010, cme:0x1018)
3151-
PatchPoint MethodRedefined(Class@0x1040, new@0x1010, cme:0x1018)
3152-
PatchPoint NoSingletonClass(Class@0x1040)
3153-
v57:BasicObject = CCallVariadic Array.new@0x1048, v46, v16
3150+
PatchPoint MethodRedefined(Array@0x1008, new@0x1009, cme:0x1010)
3151+
PatchPoint MethodRedefined(Class@0x1038, new@0x1009, cme:0x1010)
3152+
PatchPoint NoSingletonClass(Class@0x1038)
3153+
v57:BasicObject = CCallVariadic Array.new@0x1040, v46, v16
31543154
CheckInterrupts
31553155
Return v57
31563156
");
@@ -3174,14 +3174,14 @@ mod hir_opt_tests {
31743174
bb2(v6:BasicObject):
31753175
PatchPoint SingleRactorMode
31763176
PatchPoint StableConstantNames(0x1000, Set)
3177-
v43:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
3177+
v43:Class[Set@0x1008] = Const Value(VALUE(0x1008))
31783178
v13:NilClass = Const Value(nil)
3179-
PatchPoint MethodRedefined(Set@0x1008, new@0x1010, cme:0x1018)
3179+
PatchPoint MethodRedefined(Set@0x1008, new@0x1009, cme:0x1010)
31803180
v18:HeapBasicObject = ObjectAlloc v43
3181-
PatchPoint MethodRedefined(Set@0x1008, initialize@0x1040, cme:0x1048)
3181+
PatchPoint MethodRedefined(Set@0x1008, initialize@0x1038, cme:0x1040)
31823182
PatchPoint NoSingletonClass(Set@0x1008)
31833183
v49:SetExact = GuardType v18, SetExact
3184-
v50:BasicObject = CCallVariadic Set#initialize@0x1070, v49
3184+
v50:BasicObject = CCallVariadic Set#initialize@0x1068, v49
31853185
CheckInterrupts
31863186
CheckInterrupts
31873187
Return v18
@@ -3206,12 +3206,12 @@ mod hir_opt_tests {
32063206
bb2(v6:BasicObject):
32073207
PatchPoint SingleRactorMode
32083208
PatchPoint StableConstantNames(0x1000, String)
3209-
v43:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
3209+
v43:Class[String@0x1008] = Const Value(VALUE(0x1008))
32103210
v13:NilClass = Const Value(nil)
3211-
PatchPoint MethodRedefined(String@0x1008, new@0x1010, cme:0x1018)
3212-
PatchPoint MethodRedefined(Class@0x1040, new@0x1010, cme:0x1018)
3213-
PatchPoint NoSingletonClass(Class@0x1040)
3214-
v54:BasicObject = CCallVariadic String.new@0x1048, v43
3211+
PatchPoint MethodRedefined(String@0x1008, new@0x1009, cme:0x1010)
3212+
PatchPoint MethodRedefined(Class@0x1038, new@0x1009, cme:0x1010)
3213+
PatchPoint NoSingletonClass(Class@0x1038)
3214+
v54:BasicObject = CCallVariadic String.new@0x1040, v43
32153215
CheckInterrupts
32163216
Return v54
32173217
");
@@ -3235,7 +3235,7 @@ mod hir_opt_tests {
32353235
bb2(v6:BasicObject):
32363236
PatchPoint SingleRactorMode
32373237
PatchPoint StableConstantNames(0x1000, Regexp)
3238-
v47:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
3238+
v47:Class[Regexp@0x1008] = Const Value(VALUE(0x1008))
32393239
v13:NilClass = Const Value(nil)
32403240
v16:StringExact[VALUE(0x1010)] = Const Value(VALUE(0x1010))
32413241
v17:StringExact = StringCopy v16
@@ -4406,7 +4406,7 @@ mod hir_opt_tests {
44064406
bb2(v6:BasicObject):
44074407
PatchPoint SingleRactorMode
44084408
PatchPoint StableConstantNames(0x1000, Foo)
4409-
v22:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
4409+
v22:Class[Foo@0x1008] = Const Value(VALUE(0x1008))
44104410
v13:Fixnum[100] = Const Value(100)
44114411
PatchPoint MethodRedefined(Class@0x1010, identity@0x1018, cme:0x1020)
44124412
PatchPoint NoSingletonClass(Class@0x1010)
@@ -5962,7 +5962,7 @@ mod hir_opt_tests {
59625962
bb2(v6:BasicObject):
59635963
PatchPoint SingleRactorMode
59645964
PatchPoint StableConstantNames(0x1000, Thread)
5965-
v20:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5965+
v20:Class[Thread@0x1008] = Const Value(VALUE(0x1008))
59665966
PatchPoint MethodRedefined(Class@0x1010, current@0x1018, cme:0x1020)
59675967
PatchPoint NoSingletonClass(Class@0x1010)
59685968
v24:CPtr = LoadEC
@@ -8002,7 +8002,7 @@ mod hir_opt_tests {
80028002
bb2(v8:BasicObject, v9:BasicObject):
80038003
PatchPoint SingleRactorMode
80048004
PatchPoint StableConstantNames(0x1000, String)
8005-
v26:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
8005+
v26:Class[String@0x1008] = Const Value(VALUE(0x1008))
80068006
PatchPoint NoEPEscape(test)
80078007
PatchPoint MethodRedefined(Class@0x1010, ===@0x1018, cme:0x1020)
80088008
PatchPoint NoSingletonClass(Class@0x1010)
@@ -8062,8 +8062,8 @@ mod hir_opt_tests {
80628062
bb2(v8:BasicObject, v9:BasicObject):
80638063
PatchPoint SingleRactorMode
80648064
PatchPoint StableConstantNames(0x1000, String)
8065-
v24:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
8066-
PatchPoint MethodRedefined(String@0x1008, is_a?@0x1010, cme:0x1018)
8065+
v24:Class[String@0x1008] = Const Value(VALUE(0x1008))
8066+
PatchPoint MethodRedefined(String@0x1008, is_a?@0x1009, cme:0x1010)
80678067
PatchPoint NoSingletonClass(String@0x1008)
80688068
v28:StringExact = GuardType v9, StringExact
80698069
v29:BoolExact = IsA v28, v24
@@ -8124,7 +8124,7 @@ mod hir_opt_tests {
81248124
bb2(v8:BasicObject, v9:BasicObject):
81258125
PatchPoint SingleRactorMode
81268126
PatchPoint StableConstantNames(0x1000, Integer)
8127-
v28:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
8127+
v28:Class[Integer@0x1008] = Const Value(VALUE(0x1008))
81288128
PatchPoint MethodRedefined(String@0x1010, is_a?@0x1018, cme:0x1020)
81298129
PatchPoint NoSingletonClass(String@0x1010)
81308130
v32:StringExact = GuardType v9, StringExact
@@ -8157,7 +8157,7 @@ mod hir_opt_tests {
81578157
bb2(v8:BasicObject, v9:BasicObject):
81588158
PatchPoint SingleRactorMode
81598159
PatchPoint StableConstantNames(0x1000, Integer)
8160-
v30:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
8160+
v30:Class[Integer@0x1008] = Const Value(VALUE(0x1008))
81618161
PatchPoint NoEPEscape(test)
81628162
PatchPoint MethodRedefined(Class@0x1010, ===@0x1018, cme:0x1020)
81638163
PatchPoint NoSingletonClass(Class@0x1010)

zjit/src/hir_type/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ fn write_spec(f: &mut std::fmt::Formatter, printer: &TypePrinter) -> std::fmt::R
7777
Specialization::Object(val) if val == unsafe { rb_mRubyVMFrozenCore } => write!(f, "[VMFrozenCore]"),
7878
Specialization::Object(val) if val == unsafe { rb_block_param_proxy } => write!(f, "[BlockParamProxy]"),
7979
Specialization::Object(val) if ty.is_subtype(types::Symbol) => write!(f, "[:{}]", ruby_sym_to_rust_string(val)),
80+
Specialization::Object(val) if ty.is_subtype(types::Class) =>
81+
write!(f, "[{}@{:p}]", get_class_name(val), printer.ptr_map.map_ptr(val.0 as *const std::ffi::c_void)),
8082
Specialization::Object(val) => write!(f, "[{}]", val.print(printer.ptr_map)),
8183
// TODO(max): Ensure singleton classes never have Type specialization
8284
Specialization::Type(val) if unsafe { rb_zjit_singleton_class_p(val) } =>

0 commit comments

Comments
 (0)