@@ -6,24 +6,26 @@ use crate::cruby::*;
66use std:: collections:: HashSet ;
77
88/// Default --zjit-num-profiles
9- const DEFAULT_NUM_PROFILES : u32 = 5 ;
9+ const DEFAULT_NUM_PROFILES : NumProfiles = 5 ;
10+ pub type NumProfiles = u32 ;
1011
1112/// Default --zjit-call-threshold. This should be large enough to avoid compiling
1213/// warmup code, but small enough to perform well on micro-benchmarks.
13- pub const DEFAULT_CALL_THRESHOLD : u64 = 30 ;
14+ pub const DEFAULT_CALL_THRESHOLD : CallThreshold = 30 ;
15+ pub type CallThreshold = u64 ;
1416
1517/// Number of calls to start profiling YARV instructions.
1618/// They are profiled `rb_zjit_call_threshold - rb_zjit_profile_threshold` times,
1719/// which is equal to --zjit-num-profiles.
1820#[ unsafe( no_mangle) ]
1921#[ allow( non_upper_case_globals) ]
20- pub static mut rb_zjit_profile_threshold: u64 = DEFAULT_CALL_THRESHOLD - DEFAULT_NUM_PROFILES as u64 ;
22+ pub static mut rb_zjit_profile_threshold: CallThreshold = DEFAULT_CALL_THRESHOLD - DEFAULT_NUM_PROFILES as CallThreshold ;
2123
2224/// Number of calls to compile ISEQ with ZJIT at jit_compile() in vm.c.
2325/// --zjit-call-threshold=1 compiles on first execution without profiling information.
2426#[ unsafe( no_mangle) ]
2527#[ allow( non_upper_case_globals) ]
26- pub static mut rb_zjit_call_threshold: u64 = DEFAULT_CALL_THRESHOLD ;
28+ pub static mut rb_zjit_call_threshold: CallThreshold = DEFAULT_CALL_THRESHOLD ;
2729
2830/// ZJIT command-line options. This is set before rb_zjit_init() sets
2931/// ZJITState so that we can query some options while loading builtins.
@@ -40,7 +42,7 @@ pub struct Options {
4042 pub mem_bytes : usize ,
4143
4244 /// Number of times YARV instructions should be profiled.
43- pub num_profiles : u32 ,
45+ pub num_profiles : NumProfiles ,
4446
4547 /// Enable YJIT statsitics
4648 pub stats : bool ,
@@ -319,14 +321,14 @@ fn update_profile_threshold() {
319321 unsafe { rb_zjit_profile_threshold = 0 ; }
320322 } else {
321323 // Otherwise, profile instructions at least once.
322- let num_profiles = get_option ! ( num_profiles) as u64 ;
323- unsafe { rb_zjit_profile_threshold = rb_zjit_call_threshold. saturating_sub ( num_profiles) . max ( 1 ) } ;
324+ let num_profiles = get_option ! ( num_profiles) ;
325+ unsafe { rb_zjit_profile_threshold = rb_zjit_call_threshold. saturating_sub ( num_profiles. into ( ) ) . max ( 1 ) } ;
324326 }
325327}
326328
327329/// Update --zjit-call-threshold for testing
328330#[ cfg( test) ]
329- pub fn set_call_threshold ( call_threshold : u64 ) {
331+ pub fn set_call_threshold ( call_threshold : CallThreshold ) {
330332 unsafe { rb_zjit_call_threshold = call_threshold; }
331333 rb_zjit_prepare_options ( ) ;
332334 update_profile_threshold ( ) ;
0 commit comments