diff --git a/zjit.rb b/zjit.rb index 72a6e58651..cfe8bcd6e2 100644 --- a/zjit.rb +++ b/zjit.rb @@ -165,9 +165,9 @@ class << RubyVM::ZJIT print_counters_with_prefix(prefix: 'send_fallback_', prompt: 'send fallback reasons', buf:, stats:, limit: 20) # Show most popular unsupported call features. Because each call can - # use multiple fancy features, a decrease in this number does not + # use multiple complex features, a decrease in this number does not # necessarily mean an increase in number of optimized calls. - print_counters_with_prefix(prefix: 'fancy_arg_pass_', prompt: 'popular unsupported argument-parameter features', buf:, stats:, limit: 10) + print_counters_with_prefix(prefix: 'complex_arg_pass_', prompt: 'popular complex argument-parameter features not optimized', buf:, stats:, limit: 10) # Show exit counters, ordered by the typical amount of exits for the prefix at the time print_counters_with_prefix(prefix: 'unhandled_yarv_insn_', prompt: 'unhandled YARV insns', buf:, stats:, limit: 20) diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index 136f7b452f..09e293a0f6 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -579,7 +579,7 @@ pub enum SendFallbackReason { BmethodNonIseqProc, /// The call has at least one feature on the caller or callee side that the optimizer does not /// support. - FancyFeatureUse, + ComplexArgPass, /// Initial fallback reason for every instruction, which should be mutated to /// a more actionable reason when an attempt to specialize the instruction fails. NotOptimizedInstruction(ruby_vminsn_type), @@ -1417,12 +1417,12 @@ fn can_direct_send(function: &mut Function, block: BlockId, iseq: *const rb_iseq }; use Counter::*; - if unsafe { rb_get_iseq_flags_has_rest(iseq) } { count_failure(fancy_arg_pass_param_rest) } - if unsafe { rb_get_iseq_flags_has_opt(iseq) } { count_failure(fancy_arg_pass_param_opt) } - if unsafe { rb_get_iseq_flags_has_kw(iseq) } { count_failure(fancy_arg_pass_param_kw) } - if unsafe { rb_get_iseq_flags_has_kwrest(iseq) } { count_failure(fancy_arg_pass_param_kwrest) } - if unsafe { rb_get_iseq_flags_has_block(iseq) } { count_failure(fancy_arg_pass_param_block) } - if unsafe { rb_get_iseq_flags_forwardable(iseq) } { count_failure(fancy_arg_pass_param_forwardable) } + if unsafe { rb_get_iseq_flags_has_rest(iseq) } { count_failure(complex_arg_pass_param_rest) } + if unsafe { rb_get_iseq_flags_has_opt(iseq) } { count_failure(complex_arg_pass_param_opt) } + if unsafe { rb_get_iseq_flags_has_kw(iseq) } { count_failure(complex_arg_pass_param_kw) } + if unsafe { rb_get_iseq_flags_has_kwrest(iseq) } { count_failure(complex_arg_pass_param_kwrest) } + if unsafe { rb_get_iseq_flags_has_block(iseq) } { count_failure(complex_arg_pass_param_block) } + if unsafe { rb_get_iseq_flags_forwardable(iseq) } { count_failure(complex_arg_pass_param_forwardable) } can_send } @@ -2153,16 +2153,16 @@ impl Function { self.push_insn(block, Insn::GuardType { val, guard_type, state }) } - fn count_fancy_call_features(&mut self, block: BlockId, ci_flags: c_uint) { + fn count_complex_call_features(&mut self, block: BlockId, ci_flags: c_uint) { use Counter::*; - if 0 != ci_flags & VM_CALL_ARGS_SPLAT { self.push_insn(block, Insn::IncrCounter(fancy_arg_pass_caller_splat)); } - if 0 != ci_flags & VM_CALL_ARGS_BLOCKARG { self.push_insn(block, Insn::IncrCounter(fancy_arg_pass_caller_blockarg)); } - if 0 != ci_flags & VM_CALL_KWARG { self.push_insn(block, Insn::IncrCounter(fancy_arg_pass_caller_kwarg)); } - if 0 != ci_flags & VM_CALL_KW_SPLAT { self.push_insn(block, Insn::IncrCounter(fancy_arg_pass_caller_kw_splat)); } - if 0 != ci_flags & VM_CALL_TAILCALL { self.push_insn(block, Insn::IncrCounter(fancy_arg_pass_caller_tailcall)); } - if 0 != ci_flags & VM_CALL_SUPER { self.push_insn(block, Insn::IncrCounter(fancy_arg_pass_caller_super)); } - if 0 != ci_flags & VM_CALL_ZSUPER { self.push_insn(block, Insn::IncrCounter(fancy_arg_pass_caller_zsuper)); } - if 0 != ci_flags & VM_CALL_FORWARDING { self.push_insn(block, Insn::IncrCounter(fancy_arg_pass_caller_forwarding)); } + if 0 != ci_flags & VM_CALL_ARGS_SPLAT { self.push_insn(block, Insn::IncrCounter(complex_arg_pass_caller_splat)); } + if 0 != ci_flags & VM_CALL_ARGS_BLOCKARG { self.push_insn(block, Insn::IncrCounter(complex_arg_pass_caller_blockarg)); } + if 0 != ci_flags & VM_CALL_KWARG { self.push_insn(block, Insn::IncrCounter(complex_arg_pass_caller_kwarg)); } + if 0 != ci_flags & VM_CALL_KW_SPLAT { self.push_insn(block, Insn::IncrCounter(complex_arg_pass_caller_kw_splat)); } + if 0 != ci_flags & VM_CALL_TAILCALL { self.push_insn(block, Insn::IncrCounter(complex_arg_pass_caller_tailcall)); } + if 0 != ci_flags & VM_CALL_SUPER { self.push_insn(block, Insn::IncrCounter(complex_arg_pass_caller_super)); } + if 0 != ci_flags & VM_CALL_ZSUPER { self.push_insn(block, Insn::IncrCounter(complex_arg_pass_caller_zsuper)); } + if 0 != ci_flags & VM_CALL_FORWARDING { self.push_insn(block, Insn::IncrCounter(complex_arg_pass_caller_forwarding)); } } fn try_rewrite_fixnum_op(&mut self, block: BlockId, orig_insn_id: InsnId, f: &dyn Fn(InsnId, InsnId) -> Insn, bop: u32, left: InsnId, right: InsnId, state: InsnId) { @@ -2314,7 +2314,7 @@ impl Function { // TODO(max): Handle other kinds of parameter passing let iseq = unsafe { get_def_iseq_ptr((*cme).def) }; if !can_direct_send(self, block, iseq) { - self.set_dynamic_send_reason(insn_id, FancyFeatureUse); + self.set_dynamic_send_reason(insn_id, ComplexArgPass); self.push_insn_id(block, insn_id); continue; } self.push_insn(block, Insn::PatchPoint { invariant: Invariant::MethodRedefined { klass, method: mid, cme }, state }); @@ -2340,7 +2340,7 @@ impl Function { let iseq = unsafe { *capture.code.iseq.as_ref() }; if !can_direct_send(self, block, iseq) { - self.set_dynamic_send_reason(insn_id, FancyFeatureUse); + self.set_dynamic_send_reason(insn_id, ComplexArgPass); self.push_insn_id(block, insn_id); continue; } // Can't pass a block to a block for now @@ -2876,7 +2876,7 @@ impl Function { // Filter for simple call sites (i.e. no splats etc.) if ci_flags & VM_CALL_ARGS_SIMPLE == 0 { - fun.count_fancy_call_features(block, ci_flags); + fun.count_complex_call_features(block, ci_flags); return Err(()); } @@ -2948,7 +2948,7 @@ impl Function { // func(int argc, VALUE *argv, VALUE recv) let ci_flags = unsafe { vm_ci_flag(call_info) }; if ci_flags & VM_CALL_ARGS_SIMPLE == 0 { - fun.count_fancy_call_features(block, ci_flags); + fun.count_complex_call_features(block, ci_flags); } else { fun.gen_patch_points_for_optimized_ccall(block, recv_class, method_id, cme, state); diff --git a/zjit/src/hir/opt_tests.rs b/zjit/src/hir/opt_tests.rs index 07f80c0682..97b93e3d7b 100644 --- a/zjit/src/hir/opt_tests.rs +++ b/zjit/src/hir/opt_tests.rs @@ -2549,7 +2549,7 @@ mod hir_opt_tests { Jump bb2(v4) bb2(v6:BasicObject): v10:Fixnum[1] = Const Value(1) - IncrCounter fancy_arg_pass_param_opt + IncrCounter complex_arg_pass_param_opt v12:BasicObject = SendWithoutBlock v6, :foo, v10 CheckInterrupts Return v12 @@ -2633,7 +2633,7 @@ mod hir_opt_tests { Jump bb2(v4) bb2(v6:BasicObject): v10:Fixnum[1] = Const Value(1) - IncrCounter fancy_arg_pass_param_rest + IncrCounter complex_arg_pass_param_rest v12:BasicObject = SendWithoutBlock v6, :foo, v10 CheckInterrupts Return v12 @@ -2940,9 +2940,9 @@ mod hir_opt_tests { v12:NilClass = Const Value(nil) PatchPoint MethodRedefined(Hash@0x1008, new@0x1010, cme:0x1018) v43:HashExact = ObjectAllocClass Hash:VALUE(0x1008) - IncrCounter fancy_arg_pass_param_opt - IncrCounter fancy_arg_pass_param_kw - IncrCounter fancy_arg_pass_param_block + IncrCounter complex_arg_pass_param_opt + IncrCounter complex_arg_pass_param_kw + IncrCounter complex_arg_pass_param_block v18:BasicObject = SendWithoutBlock v43, :initialize CheckInterrupts CheckInterrupts @@ -7222,7 +7222,7 @@ mod hir_opt_tests { } #[test] - fn counting_fancy_feature_use_for_fallback() { + fn counting_complex_feature_use_for_fallback() { eval(" define_method(:fancy) { |_a, *_b, kw: 100, **kw_rest, &block| } def test = fancy(1) @@ -7239,10 +7239,10 @@ mod hir_opt_tests { Jump bb2(v4) bb2(v6:BasicObject): v10:Fixnum[1] = Const Value(1) - IncrCounter fancy_arg_pass_param_rest - IncrCounter fancy_arg_pass_param_kw - IncrCounter fancy_arg_pass_param_kwrest - IncrCounter fancy_arg_pass_param_block + IncrCounter complex_arg_pass_param_rest + IncrCounter complex_arg_pass_param_kw + IncrCounter complex_arg_pass_param_kwrest + IncrCounter complex_arg_pass_param_block v12:BasicObject = SendWithoutBlock v6, :fancy, v10 CheckInterrupts Return v12 @@ -7266,7 +7266,7 @@ mod hir_opt_tests { EntryPoint JIT(0) Jump bb2(v4) bb2(v6:BasicObject): - IncrCounter fancy_arg_pass_param_forwardable + IncrCounter complex_arg_pass_param_forwardable v11:BasicObject = SendWithoutBlock v6, :forwardable CheckInterrupts Return v11 diff --git a/zjit/src/stats.rs b/zjit/src/stats.rs index 35af2b1d9d..30a0966994 100644 --- a/zjit/src/stats.rs +++ b/zjit/src/stats.rs @@ -177,7 +177,7 @@ make_counters! { send_fallback_ccall_with_frame_too_many_args, // The call has at least one feature on the caller or callee side // that the optimizer does not support. - send_fallback_fancy_call_feature, + send_fallback_one_or_more_complex_arg_pass, send_fallback_bmethod_non_iseq_proc, send_fallback_obj_to_string_not_string, send_fallback_not_optimized_instruction, @@ -257,22 +257,22 @@ make_counters! { unspecialized_send_def_type_null, // Unsupported parameter features - fancy_arg_pass_param_rest, - fancy_arg_pass_param_opt, - fancy_arg_pass_param_kw, - fancy_arg_pass_param_kwrest, - fancy_arg_pass_param_block, - fancy_arg_pass_param_forwardable, + complex_arg_pass_param_rest, + complex_arg_pass_param_opt, + complex_arg_pass_param_kw, + complex_arg_pass_param_kwrest, + complex_arg_pass_param_block, + complex_arg_pass_param_forwardable, // Unsupported caller side features - fancy_arg_pass_caller_splat, - fancy_arg_pass_caller_blockarg, - fancy_arg_pass_caller_kwarg, - fancy_arg_pass_caller_kw_splat, - fancy_arg_pass_caller_tailcall, - fancy_arg_pass_caller_super, - fancy_arg_pass_caller_zsuper, - fancy_arg_pass_caller_forwarding, + complex_arg_pass_caller_splat, + complex_arg_pass_caller_blockarg, + complex_arg_pass_caller_kwarg, + complex_arg_pass_caller_kw_splat, + complex_arg_pass_caller_tailcall, + complex_arg_pass_caller_super, + complex_arg_pass_caller_zsuper, + complex_arg_pass_caller_forwarding, // Writes to the VM frame vm_write_pc_count, @@ -427,7 +427,7 @@ pub fn send_fallback_counter(reason: crate::hir::SendFallbackReason) -> Counter SendWithoutBlockDirectTooManyArgs => send_fallback_send_without_block_direct_too_many_args, SendPolymorphic => send_fallback_send_polymorphic, SendNoProfiles => send_fallback_send_no_profiles, - FancyFeatureUse => send_fallback_fancy_call_feature, + ComplexArgPass => send_fallback_one_or_more_complex_arg_pass, BmethodNonIseqProc => send_fallback_bmethod_non_iseq_proc, SendNotOptimizedMethodType(_) => send_fallback_send_not_optimized_method_type, CCallWithFrameTooManyArgs => send_fallback_ccall_with_frame_too_many_args,