Skip to content

Commit 8317c66

Browse files
committed
ZJIT: More accurately model Class types
1 parent 4839739 commit 8317c66

4 files changed

Lines changed: 51 additions & 57 deletions

File tree

zjit/src/hir.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,10 +4196,10 @@ mod tests {
41964196
assert_method_hir("test", expect![[r#"
41974197
fn test:
41984198
bb0(v0:BasicObject, v1:BasicObject):
4199-
v3:ClassExact[VMFrozenCore] = Const Value(VALUE(0x1000))
4199+
v3:Class[VMFrozenCore] = Const Value(VALUE(0x1000))
42004200
v5:HashExact = NewHash
42014201
v7:BasicObject = SendWithoutBlock v3, :core#hash_merge_kwd, v5, v1
4202-
v8:ClassExact[VMFrozenCore] = Const Value(VALUE(0x1000))
4202+
v8:Class[VMFrozenCore] = Const Value(VALUE(0x1000))
42034203
v9:StaticSymbol[:b] = Const Value(VALUE(0x1008))
42044204
v10:Fixnum[1] = Const Value(1)
42054205
v12:BasicObject = SendWithoutBlock v8, :core#hash_merge_ptr, v7, v9, v10
@@ -4648,7 +4648,7 @@ mod tests {
46484648
assert_method_hir_with_opcode("test", YARVINSN_putspecialobject, expect![[r#"
46494649
fn test:
46504650
bb0(v0:BasicObject):
4651-
v2:ClassExact[VMFrozenCore] = Const Value(VALUE(0x1000))
4651+
v2:Class[VMFrozenCore] = Const Value(VALUE(0x1000))
46524652
v3:BasicObject = PutSpecialObject CBase
46534653
v4:StaticSymbol[:aliased] = Const Value(VALUE(0x1008))
46544654
v5:StaticSymbol[:__callee__] = Const Value(VALUE(0x1010))
@@ -5889,7 +5889,7 @@ mod opt_tests {
58895889
bb0(v0:BasicObject):
58905890
PatchPoint SingleRactorMode
58915891
PatchPoint StableConstantNames(0x1000, C)
5892-
v7:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5892+
v7:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
58935893
Return v7
58945894
"#]]);
58955895
}
@@ -5905,16 +5905,16 @@ mod opt_tests {
59055905
bb0(v0:BasicObject):
59065906
PatchPoint SingleRactorMode
59075907
PatchPoint StableConstantNames(0x1000, String)
5908-
v15:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5908+
v15:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
59095909
PatchPoint SingleRactorMode
59105910
PatchPoint StableConstantNames(0x1010, Class)
5911-
v18:ClassExact[VALUE(0x1018)] = Const Value(VALUE(0x1018))
5911+
v18:Class[VALUE(0x1018)] = Const Value(VALUE(0x1018))
59125912
PatchPoint SingleRactorMode
59135913
PatchPoint StableConstantNames(0x1020, Module)
5914-
v21:ClassExact[VALUE(0x1028)] = Const Value(VALUE(0x1028))
5914+
v21:Class[VALUE(0x1028)] = Const Value(VALUE(0x1028))
59155915
PatchPoint SingleRactorMode
59165916
PatchPoint StableConstantNames(0x1030, BasicObject)
5917-
v24:ClassExact[VALUE(0x1038)] = Const Value(VALUE(0x1038))
5917+
v24:Class[VALUE(0x1038)] = Const Value(VALUE(0x1038))
59185918
v11:ArrayExact = NewArray v15, v18, v21, v24
59195919
Return v11
59205920
"#]]);
@@ -6107,7 +6107,7 @@ mod opt_tests {
61076107
bb0(v0:BasicObject):
61086108
PatchPoint SingleRactorMode
61096109
PatchPoint StableConstantNames(0x1000, Foo::Bar::C)
6110-
v7:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
6110+
v7:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
61116111
Return v7
61126112
"#]]);
61136113
}
@@ -6124,7 +6124,7 @@ mod opt_tests {
61246124
bb0(v0:BasicObject):
61256125
PatchPoint SingleRactorMode
61266126
PatchPoint StableConstantNames(0x1000, C)
6127-
v20:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
6127+
v20:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
61286128
v4:NilClassExact = Const Value(nil)
61296129
v11:BasicObject = SendWithoutBlock v20, :new
61306130
Return v11
@@ -6147,7 +6147,7 @@ mod opt_tests {
61476147
bb0(v0:BasicObject):
61486148
PatchPoint SingleRactorMode
61496149
PatchPoint StableConstantNames(0x1000, C)
6150-
v22:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
6150+
v22:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
61516151
v4:NilClassExact = Const Value(nil)
61526152
v5:Fixnum[1] = Const Value(1)
61536153
v13:BasicObject = SendWithoutBlock v22, :new, v5

zjit/src/hir_type/gen_hir_type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def base_type name
7474
base_type "Range"
7575
base_type "Set"
7676
base_type "Regexp"
77-
base_type "Class"
78-
base_type "Module"
77+
module_class, _ = base_type "Module"
78+
module_class.subtype "Class"
7979

8080
(integer, integer_exact) = base_type "Integer"
8181
# CRuby partitions Integer into immediate and non-immediate variants.

zjit/src/hir_type/hir_type.inc.rs

Lines changed: 36 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zjit/src/hir_type/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl Type {
214214
Type { bits: bits::ModuleExact, spec: Specialization::Object(val) }
215215
}
216216
else if val.builtin_type() == RUBY_T_CLASS {
217-
Type { bits: bits::ClassExact, spec: Specialization::Object(val) }
217+
Type { bits: bits::Class, spec: Specialization::Object(val) }
218218
}
219219
else if val.class_of() == unsafe { rb_cRegexp } {
220220
Type { bits: bits::RegexpExact, spec: Specialization::Object(val) }
@@ -417,7 +417,7 @@ impl Type {
417417
return Some(val);
418418
}
419419
if self.is_subtype(types::ArrayExact) { return Some(unsafe { rb_cArray }); }
420-
if self.is_subtype(types::ClassExact) { return Some(unsafe { rb_cClass }); }
420+
if self.is_subtype(types::Class) { return Some(unsafe { rb_cClass }); }
421421
if self.is_subtype(types::FalseClassExact) { return Some(unsafe { rb_cFalseClass }); }
422422
if self.is_subtype(types::FloatExact) { return Some(unsafe { rb_cFloat }); }
423423
if self.is_subtype(types::HashExact) { return Some(unsafe { rb_cHash }); }

0 commit comments

Comments
 (0)