summaryrefslogtreecommitdiff
path: root/yjit
diff options
context:
space:
mode:
authorJimmy Miller <jimmy.miller@shopify.com>2022-11-10 12:56:22 -0500
committerGitHub <noreply@github.com>2022-11-10 12:56:22 -0500
commit8b3347950e6344474430ed08f5fa19f613883660 (patch)
treea932fb4a9e0e51cc4c81bc5e6325d945ea99c03f /yjit
parent0de3bc92b4fc3bb9fc0930e98baed37044ed44e1 (diff)
Enable --yjit-stats for release builds (#6694)
* Enable --yjit-stats for release builds In order for people in the real world to report information about how their application runs with YJIT, we want to expose stats without requiring rebuilding ruby. We can do this without overhead, with the exception of count ratio in yjit, since this relies on the interpreter also counting instructions. This change exposes those stats, while not showing ratio in yjit if we are not in a stats build. * Update yjit.rb Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'yjit')
-rw-r--r--yjit/src/codegen.rs17
-rw-r--r--yjit/src/stats.rs15
2 files changed, 11 insertions, 21 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 530bcf9eda..b1b854ad7f 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -7,7 +7,6 @@ use crate::core::*;
use crate::cruby::*;
use crate::invariants::*;
use crate::options::*;
-#[cfg(feature = "stats")]
use crate::stats::*;
use crate::utils::*;
use CodegenStatus::*;
@@ -181,12 +180,6 @@ fn jit_peek_at_block_handler(jit: &JITState, level: u32) -> VALUE {
}
}
-/// Increment a profiling counter with counter_name
-#[cfg(not(feature = "stats"))]
-macro_rules! gen_counter_incr {
- ($asm:tt, $counter_name:ident) => {};
-}
-#[cfg(feature = "stats")]
macro_rules! gen_counter_incr {
($asm:tt, $counter_name:ident) => {
if (get_option!(gen_stats)) {
@@ -204,15 +197,6 @@ macro_rules! gen_counter_incr {
};
}
-/// Increment a counter then take an existing side exit
-#[cfg(not(feature = "stats"))]
-macro_rules! counted_exit {
- ($ocb:tt, $existing_side_exit:tt, $counter_name:ident) => {{
- let _ = $ocb;
- $existing_side_exit
- }};
-}
-#[cfg(feature = "stats")]
macro_rules! counted_exit {
($ocb:tt, $existing_side_exit:tt, $counter_name:ident) => {
// The counter is only incremented when stats are enabled
@@ -422,7 +406,6 @@ fn gen_exit(exit_pc: *mut VALUE, ctx: &Context, asm: &mut Assembler) {
);
// Accumulate stats about interpreter exits
- #[cfg(feature = "stats")]
if get_option!(gen_stats) {
asm.ccall(
rb_yjit_count_side_exit_op as *const u8,
diff --git a/yjit/src/stats.rs b/yjit/src/stats.rs
index b7bbb4ae3e..128672a959 100644
--- a/yjit/src/stats.rs
+++ b/yjit/src/stats.rs
@@ -289,12 +289,12 @@ make_counters! {
/// Check if stats generation is enabled
#[no_mangle]
pub extern "C" fn rb_yjit_stats_enabled_p(_ec: EcPtr, _ruby_self: VALUE) -> VALUE {
- #[cfg(feature = "stats")]
+
if get_option!(gen_stats) {
return Qtrue;
+ } else {
+ return Qfalse;
}
-
- return Qfalse;
}
/// Primitive called in yjit.rb.
@@ -404,7 +404,7 @@ fn rb_yjit_gen_stats_dict() -> VALUE {
}
// If the stats feature is enabled
- #[cfg(feature = "stats")]
+
unsafe {
// Indicate that the complete set of stats is available
rb_hash_aset(hash, rust_str_to_sym("all_stats"), Qtrue);
@@ -415,6 +415,13 @@ fn rb_yjit_gen_stats_dict() -> VALUE {
let counter_ptr = get_counter_ptr(counter_name);
let counter_val = *counter_ptr;
+ #[cfg(not(feature = "stats"))]
+ if counter_name == &"vm_insns_count" {
+ // If the stats feature is disabled, we don't have vm_insns_count
+ // so we are going to exlcude the key
+ continue;
+ }
+
// Put counter into hash
let key = rust_str_to_sym(counter_name);
let value = VALUE::fixnum_from_usize(counter_val as usize);