mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
ZJIT: Add code_region_bytes stat (#14389)
* ZJIT: Add code_region_bytes stat * Share more logic among --zjit and --zjit-stats
This commit is contained in:
parent
041450ad41
commit
bf3d6a17ee
1
zjit.rb
1
zjit.rb
@ -46,6 +46,7 @@ class << RubyVM::ZJIT
|
||||
:gc_time_ns,
|
||||
:invalidation_time_ns,
|
||||
|
||||
:code_region_bytes,
|
||||
:side_exit_count,
|
||||
:total_insn_count,
|
||||
:vm_insn_count,
|
||||
|
||||
@ -84,6 +84,11 @@ impl CodeBlock {
|
||||
}
|
||||
}
|
||||
|
||||
/// Size of the region in bytes that we have allocated physical memory for.
|
||||
pub fn mapped_region_size(&self) -> usize {
|
||||
self.mem_block.borrow().mapped_region_size()
|
||||
}
|
||||
|
||||
/// Add an assembly comment if the feature is on.
|
||||
pub fn add_comment(&mut self, comment: &str) {
|
||||
if !self.keep_comments {
|
||||
|
||||
@ -48,9 +48,8 @@ macro_rules! make_counters {
|
||||
$( Counter::$default_counter_name, )+
|
||||
];
|
||||
|
||||
/// List of all counters
|
||||
pub const ALL_COUNTERS: &'static [Counter] = &[
|
||||
$( Counter::$default_counter_name, )+
|
||||
/// List of counters that are available only for --zjit-stats.
|
||||
pub const STATS_ONLY_COUNTERS: &'static [Counter] = &[
|
||||
$( Counter::$counter_name, )+
|
||||
];
|
||||
}
|
||||
@ -187,16 +186,21 @@ pub extern "C" fn rb_zjit_stats(_ec: EcPtr, _self: VALUE, target_key: VALUE) ->
|
||||
Qnil
|
||||
};
|
||||
|
||||
// If not --zjit-stats, set only default counters
|
||||
// Set default counters
|
||||
for &counter in DEFAULT_COUNTERS {
|
||||
set_stat_usize!(hash, &counter.name(), unsafe { *counter_ptr(counter) });
|
||||
}
|
||||
|
||||
// Memory usage stats
|
||||
set_stat_usize!(hash, "code_region_bytes", ZJITState::get_code_block().mapped_region_size());
|
||||
|
||||
// End of default stats. Every counter beyond this is provided only for --zjit-stats.
|
||||
if !get_option!(stats) {
|
||||
for &counter in DEFAULT_COUNTERS {
|
||||
set_stat_usize!(hash, &counter.name(), unsafe { *counter_ptr(counter) });
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Set all counters for --zjit-stats
|
||||
for &counter in ALL_COUNTERS {
|
||||
// Set stats-only counters
|
||||
for &counter in STATS_ONLY_COUNTERS {
|
||||
set_stat_usize!(hash, &counter.name(), unsafe { *counter_ptr(counter) });
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user