YJIT: add stats to keep track of when branch direction is known (#7544)

This measures the impact of changes made by @jhawthorn last year.
This commit is contained in:
Maxime Chevalier-Boisvert 2023-03-16 17:24:08 -04:00 коммит произвёл GitHub
Родитель 617c9b4656
Коммит 473009d7cb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 16 добавлений и 0 удалений

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

@ -272,6 +272,10 @@ module RubyVM::YJIT
$stderr.puts "block_next_count: " + format_number(13, stats[:block_next_count])
$stderr.puts "defer_count: " + format_number(13, stats[:defer_count])
$stderr.puts "defer_empty_count: " + format_number(13, stats[:defer_empty_count])
$stderr.puts "branch_insn_count: " + format_number(13, stats[:branch_insn_count])
$stderr.puts "branch_known_count: " + format_number_pct(13, stats[:branch_known_count], stats[:branch_insn_count])
$stderr.puts "freed_iseq_count: " + format_number(13, stats[:freed_iseq_count])
$stderr.puts "invalidation_count: " + format_number(13, stats[:invalidation_count])
$stderr.puts "constant_state_bumps: " + format_number(13, stats[:constant_state_bumps])

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

@ -3577,9 +3577,12 @@ fn gen_branchif(
let val_type = ctx.get_opnd_type(StackOpnd(0));
let val_opnd = ctx.stack_pop(1);
incr_counter!(branch_insn_count);
if let Some(result) = val_type.known_truthy() {
let target = if result { jump_block } else { next_block };
gen_direct_jump(jit, ctx, target, asm);
incr_counter!(branch_known_count);
} else {
asm.test(val_opnd, Opnd::Imm(!Qnil.as_i64()));
@ -3628,9 +3631,12 @@ fn gen_branchunless(
let val_type = ctx.get_opnd_type(StackOpnd(0));
let val_opnd = ctx.stack_pop(1);
incr_counter!(branch_insn_count);
if let Some(result) = val_type.known_truthy() {
let target = if result { next_block } else { jump_block };
gen_direct_jump(jit, ctx, target, asm);
incr_counter!(branch_known_count);
} else {
// Test if any bit (outside of the Qnil bit) is on
// See RB_TEST()
@ -3682,9 +3688,12 @@ fn gen_branchnil(
let val_type = ctx.get_opnd_type(StackOpnd(0));
let val_opnd = ctx.stack_pop(1);
incr_counter!(branch_insn_count);
if let Some(result) = val_type.known_nil() {
let target = if result { jump_block } else { next_block };
gen_direct_jump(jit, ctx, target, asm);
incr_counter!(branch_known_count);
} else {
// Test if the value is Qnil
asm.cmp(val_opnd, Opnd::UImm(Qnil.into()));

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

@ -324,6 +324,9 @@ make_counters! {
block_next_count,
defer_count,
defer_empty_count,
branch_insn_count,
branch_known_count,
freed_iseq_count,
exit_from_branch_stub,