It's an estimator for application size and could be used as a
compilation heuristic later.

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
This commit is contained in:
Alan Wu 2023-10-18 19:46:35 -04:00 коммит произвёл GitHub
Родитель 0ac6fb225d
Коммит d2b0c9da2e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -3429,6 +3429,7 @@ compile.$(OBJEXT): {$(VPATH)}vm_callinfo.h
compile.$(OBJEXT): {$(VPATH)}vm_core.h
compile.$(OBJEXT): {$(VPATH)}vm_debug.h
compile.$(OBJEXT): {$(VPATH)}vm_opts.h
compile.$(OBJEXT): {$(VPATH)}yjit.h
complex.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
complex.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
complex.$(OBJEXT): $(CCAN_DIR)/list/list.h

Просмотреть файл

@ -39,6 +39,7 @@
#include "vm_core.h"
#include "vm_callinfo.h"
#include "vm_debug.h"
#include "yjit.h"
#include "builtin.h"
#include "insns.inc"
@ -1019,6 +1020,11 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
}
FL_SET((VALUE)iseq, ISEQ_TRANSLATED);
#endif
#if USE_YJIT
rb_yjit_live_iseq_count++;
#endif
return COMPILE_OK;
}

2
iseq.c
Просмотреть файл

@ -168,6 +168,8 @@ rb_iseq_free(const rb_iseq_t *iseq)
rb_rjit_free_iseq(iseq); /* Notify RJIT */
#if USE_YJIT
rb_yjit_iseq_free(body->yjit_payload);
RUBY_ASSERT(rb_yjit_live_iseq_count > 0);
rb_yjit_live_iseq_count--;
#endif
ruby_xfree((void *)body->iseq_encoded);
ruby_xfree((void *)body->insns_info.body);

1
yjit.h
Просмотреть файл

@ -27,6 +27,7 @@
// Expose these as declarations since we are building YJIT.
extern uint64_t rb_yjit_call_threshold;
extern uint64_t rb_yjit_cold_threshold;
extern uint64_t rb_yjit_live_iseq_count;
void rb_yjit_incr_counter(const char *counter_name);
bool rb_yjit_enabled_p(void);
bool rb_yjit_compile_new_iseqs(void);

Просмотреть файл

@ -316,6 +316,7 @@ module RubyVM::YJIT
out.puts "bindings_allocations: " + format_number(13, stats[:binding_allocations])
out.puts "bindings_set: " + format_number(13, stats[:binding_set])
out.puts "compilation_failure: " + format_number(13, compilation_failure) if compilation_failure != 0
out.puts "live_iseq_count: " + format_number(13, stats[:live_iseq_count])
out.puts "compiled_iseq_entry: " + format_number(13, stats[:compiled_iseq_entry])
out.puts "cold_iseq_entry: " + format_number_pct(13, stats[:cold_iseq_entry], stats[:compiled_iseq_entry] + stats[:cold_iseq_entry])
out.puts "compiled_iseq_count: " + format_number(13, stats[:compiled_iseq_count])

Просмотреть файл

@ -14,6 +14,10 @@ use crate::cruby::*;
use crate::options::*;
use crate::yjit::yjit_enabled_p;
/// A running total of how many ISeqs are in the system.
#[no_mangle]
pub static mut rb_yjit_live_iseq_count: u64 = 0;
/// A middleware to count Rust-allocated bytes as yjit_alloc_size.
#[global_allocator]
static GLOBAL_ALLOCATOR: StatsAlloc = StatsAlloc { alloc_size: AtomicUsize::new(0) };
@ -635,6 +639,8 @@ fn rb_yjit_gen_stats_dict(context: bool) -> VALUE {
// VM instructions count
hash_aset_usize!(hash, "vm_insns_count", rb_vm_insns_count as usize);
hash_aset_usize!(hash, "live_iseq_count", rb_yjit_live_iseq_count as usize);
}
// If we're not generating stats, put only default counters