Skip to content

Commit 0ea980a

Browse files
authored
ZJIT: Fix test for new distribution size (ruby#18593)
We need to call more and have more classes for this test to make sense.
1 parent 8d80fd4 commit 0ea980a

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

zjit/src/hir/opt_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18117,17 +18117,17 @@ mod hir_opt_tests {
1811718117
}
1811818118

1811918119
#[test]
18120-
#[ignore = "started failing after profiling bucket was changed from 4 to 8"]
1812118120
fn test_specialize_inlined_megamorphic_receiver() {
18122-
set_call_threshold(6);
18121+
assert_eq!(crate::profile::DISTRIBUTION_SIZE, 8, "If you change distribution size, update the number of classes used");
18122+
set_call_threshold((crate::profile::DISTRIBUTION_SIZE + 2).try_into().unwrap());
1812318123
eval("
1812418124
def klass_eq(klass) = klass == Integer
1812518125

1812618126
def test = klass_eq(String)
1812718127

18128-
# 5 distinct receiver classes at the == site: one more than the profile's
18129-
# 4 buckets, so the distribution is megamorphic.
18130-
klass_eq(Integer); klass_eq(Array); klass_eq(Hash); klass_eq(Symbol); klass_eq(Float)
18128+
# 9 distinct receiver classes at the == site: one more than the profile's
18129+
# 8 buckets, so the distribution is megamorphic.
18130+
klass_eq(Integer); klass_eq(Array); klass_eq(Hash); klass_eq(Symbol); klass_eq(Float); klass_eq(NilClass); klass_eq(TrueClass); klass_eq(FalseClass); klass_eq(String)
1813118131
6.times { test }
1813218132
");
1813318133
assert_snapshot!(hir_string("test"), @"
@@ -18149,11 +18149,11 @@ mod hir_opt_tests {
1814918149
PatchPoint StableConstantNames(0x1068, Integer)
1815018150
v31:ClassSubclass[Integer@0x1070] = Const Value(VALUE(0x1070))
1815118151
PatchPoint MethodRedefined(Class@0x1078, ==@0x1080, cme:0x1088)
18152-
v45:CBool = IsBitEqual v12, v31
18153-
v46:BoolExact = BoxBool v45
18152+
v82:CBool = IsBitEqual v12, v31
18153+
v83:BoolExact = BoxBool v82
1815418154
CheckInterrupts
1815518155
PopInlineFrame
18156-
Return v46
18156+
Return v83
1815718157
");
1815818158
}
1815918159

zjit/src/profile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub fn num_arguments_on_stack(cd: *const rb_call_data) -> usize {
143143
(unsafe { vm_ci_argc(ci) }) as usize + has_blockarg as usize
144144
}
145145

146-
const DISTRIBUTION_SIZE: usize = 8;
146+
pub const DISTRIBUTION_SIZE: usize = 8;
147147

148148
pub type TypeDistribution = Distribution<ProfiledType, DISTRIBUTION_SIZE>;
149149

0 commit comments

Comments
 (0)