Skip to content

Commit 87589d0

Browse files
committed
More accurately model Class types
1 parent 39489fc commit 87589d0

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
@@ -4199,10 +4199,10 @@ mod tests {
41994199
assert_method_hir("test", expect![[r#"
42004200
fn test:
42014201
bb0(v0:BasicObject, v1:BasicObject):
4202-
v3:ClassExact[VMFrozenCore] = Const Value(VALUE(0x1000))
4202+
v3:Class[VMFrozenCore] = Const Value(VALUE(0x1000))
42034203
v5:HashExact = NewHash
42044204
v7:BasicObject = SendWithoutBlock v3, :core#hash_merge_kwd, v5, v1
4205-
v8:ClassExact[VMFrozenCore] = Const Value(VALUE(0x1000))
4205+
v8:Class[VMFrozenCore] = Const Value(VALUE(0x1000))
42064206
v9:StaticSymbol[:b] = Const Value(VALUE(0x1008))
42074207
v10:Fixnum[1] = Const Value(1)
42084208
v12:BasicObject = SendWithoutBlock v8, :core#hash_merge_ptr, v7, v9, v10
@@ -4651,7 +4651,7 @@ mod tests {
46514651
assert_method_hir_with_opcode("test", YARVINSN_putspecialobject, expect![[r#"
46524652
fn test:
46534653
bb0(v0:BasicObject):
4654-
v2:ClassExact[VMFrozenCore] = Const Value(VALUE(0x1000))
4654+
v2:Class[VMFrozenCore] = Const Value(VALUE(0x1000))
46554655
v3:BasicObject = PutSpecialObject CBase
46564656
v4:StaticSymbol[:aliased] = Const Value(VALUE(0x1008))
46574657
v5:StaticSymbol[:__callee__] = Const Value(VALUE(0x1010))
@@ -5892,7 +5892,7 @@ mod opt_tests {
58925892
bb0(v0:BasicObject):
58935893
PatchPoint SingleRactorMode
58945894
PatchPoint StableConstantNames(0x1000, C)
5895-
v7:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5895+
v7:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
58965896
Return v7
58975897
"#]]);
58985898
}
@@ -5908,16 +5908,16 @@ mod opt_tests {
59085908
bb0(v0:BasicObject):
59095909
PatchPoint SingleRactorMode
59105910
PatchPoint StableConstantNames(0x1000, String)
5911-
v15:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
5911+
v15:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
59125912
PatchPoint SingleRactorMode
59135913
PatchPoint StableConstantNames(0x1010, Class)
5914-
v18:ClassExact[VALUE(0x1018)] = Const Value(VALUE(0x1018))
5914+
v18:Class[VALUE(0x1018)] = Const Value(VALUE(0x1018))
59155915
PatchPoint SingleRactorMode
59165916
PatchPoint StableConstantNames(0x1020, Module)
5917-
v21:ClassExact[VALUE(0x1028)] = Const Value(VALUE(0x1028))
5917+
v21:Class[VALUE(0x1028)] = Const Value(VALUE(0x1028))
59185918
PatchPoint SingleRactorMode
59195919
PatchPoint StableConstantNames(0x1030, BasicObject)
5920-
v24:ClassExact[VALUE(0x1038)] = Const Value(VALUE(0x1038))
5920+
v24:Class[VALUE(0x1038)] = Const Value(VALUE(0x1038))
59215921
v11:ArrayExact = NewArray v15, v18, v21, v24
59225922
Return v11
59235923
"#]]);
@@ -6110,7 +6110,7 @@ mod opt_tests {
61106110
bb0(v0:BasicObject):
61116111
PatchPoint SingleRactorMode
61126112
PatchPoint StableConstantNames(0x1000, Foo::Bar::C)
6113-
v7:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
6113+
v7:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
61146114
Return v7
61156115
"#]]);
61166116
}
@@ -6127,7 +6127,7 @@ mod opt_tests {
61276127
bb0(v0:BasicObject):
61286128
PatchPoint SingleRactorMode
61296129
PatchPoint StableConstantNames(0x1000, C)
6130-
v20:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
6130+
v20:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
61316131
v4:NilClassExact = Const Value(nil)
61326132
v11:BasicObject = SendWithoutBlock v20, :new
61336133
Return v11
@@ -6150,7 +6150,7 @@ mod opt_tests {
61506150
bb0(v0:BasicObject):
61516151
PatchPoint SingleRactorMode
61526152
PatchPoint StableConstantNames(0x1000, C)
6153-
v22:ClassExact[VALUE(0x1008)] = Const Value(VALUE(0x1008))
6153+
v22:Class[VALUE(0x1008)] = Const Value(VALUE(0x1008))
61546154
v4:NilClassExact = Const Value(nil)
61556155
v5:Fixnum[1] = Const Value(1)
61566156
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)