summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2023-01-18 11:08:55 -0500
committerGitHub <noreply@github.com>2023-01-18 11:08:55 -0500
commitcd97976328204263c464cf6846e9bafe6424da15 (patch)
tree5b9d2268be9f8e6927b9699b570d9b01dbf9e859
parent03f5db01e6be9b522d6fbbfb54f07d168c1a3a34 (diff)
downloadruby-cd97976328204263c464cf6846e9bafe6424da15.tar.gz
Add stats so we can keep track of x86 rel32 vs register calls (#7142)
* Add stats so we can keep track of x86 rel32 vs register calls To know if we get that "prime real estate" as Alan put it. * Fix bug pointed by Alan
-rw-r--r--yjit.rb5
-rw-r--r--yjit/src/asm/x86_64/mod.rs4
-rw-r--r--yjit/src/stats.rs3
3 files changed, 12 insertions, 0 deletions
diff --git a/yjit.rb b/yjit.rb
index 062784f564..0079d8d895 100644
--- a/yjit.rb
+++ b/yjit.rb
@@ -253,6 +253,11 @@ module RubyVM::YJIT
# Number of failed compiler invocations
compilation_failure = stats[:compilation_failure]
+ if stats[:x86_call_rel32] != 0 || stats[:x86_call_reg] != 0
+ $stderr.puts "x86_call_rel32: " + ("%10d" % stats[:x86_call_rel32])
+ $stderr.puts "x86_call_reg: " + ("%10d" % stats[:x86_call_reg])
+ end
+
$stderr.puts "bindings_allocations: " + ("%10d" % stats[:binding_allocations])
$stderr.puts "bindings_set: " + ("%10d" % stats[:binding_set])
$stderr.puts "compilation_failure: " + ("%10d" % compilation_failure) if compilation_failure != 0
diff --git a/yjit/src/asm/x86_64/mod.rs b/yjit/src/asm/x86_64/mod.rs
index 1a0cb9cae7..67bb5d1ffb 100644
--- a/yjit/src/asm/x86_64/mod.rs
+++ b/yjit/src/asm/x86_64/mod.rs
@@ -690,6 +690,8 @@ pub fn call_rel32(cb: &mut CodeBlock, rel32: i32) {
/// call - Call a pointer, encode with a 32-bit offset if possible
pub fn call_ptr(cb: &mut CodeBlock, scratch_opnd: X86Opnd, dst_ptr: *const u8) {
if let X86Opnd::Reg(_scratch_reg) = scratch_opnd {
+ use crate::stats::{incr_counter};
+
// Pointer to the end of this call instruction
let end_ptr = cb.get_ptr(cb.write_pos + 5);
@@ -698,11 +700,13 @@ pub fn call_ptr(cb: &mut CodeBlock, scratch_opnd: X86Opnd, dst_ptr: *const u8) {
// If the offset fits in 32-bit
if rel64 >= i32::MIN.into() && rel64 <= i32::MAX.into() {
+ incr_counter!(x86_call_rel32);
call_rel32(cb, rel64.try_into().unwrap());
return;
}
// Move the pointer into the scratch register and call
+ incr_counter!(x86_call_reg);
mov(cb, scratch_opnd, const_ptr_opnd(dst_ptr));
call(cb, scratch_opnd);
} else {
diff --git a/yjit/src/stats.rs b/yjit/src/stats.rs
index 8fc9245364..2145cdf923 100644
--- a/yjit/src/stats.rs
+++ b/yjit/src/stats.rs
@@ -299,6 +299,9 @@ make_counters! {
exec_mem_non_bump_alloc,
num_gc_obj_refs,
+
+ x86_call_rel32,
+ x86_call_reg,
}
//===========================================================================