ruby/yjit_iface.h

117 строки
3.0 KiB
C
Исходник Обычный вид История

//
// These are definitions YJIT uses to interface with the CRuby codebase,
// but which are only used internally by YJIT.
//
#ifndef YJIT_IFACE_H
#define YJIT_IFACE_H 1
#include "ruby/ruby.h"
#include "ruby/assert.h" // for RUBY_DEBUG
#include "vm_core.h"
#include "yjit_core.h"
#ifndef YJIT_DEFAULT_CALL_THRESHOLD
# define YJIT_DEFAULT_CALL_THRESHOLD 10
#endif
#if RUBY_DEBUG
#define YJIT_DECLARE_COUNTERS(...) struct rb_yjit_runtime_counters { \
int64_t __VA_ARGS__; \
}; \
static char yjit_counter_names[] = #__VA_ARGS__;
YJIT_DECLARE_COUNTERS(
exec_instruction,
send_callsite_not_simple,
send_kw_splat,
send_ivar_set_method,
send_zsuper_method,
send_undef_method,
send_optimized_method,
send_missing_method,
send_bmethod,
send_refined_method,
send_cfunc_ruby_array_varg,
send_cfunc_argc_mismatch,
send_cfunc_toomany_args,
send_iseq_tailcall,
send_iseq_arity_error,
send_iseq_only_keywords,
send_iseq_complex_callee,
send_not_implemented_method,
send_getter_arity,
send_se_cf_overflow,
send_se_protected_check_failed,
leave_se_interrupt,
leave_interp_return,
leave_start_pc_non_zero,
getivar_se_self_not_heap,
getivar_idx_out_of_range,
getivar_undef,
getivar_name_not_mapped,
setivar_se_self_not_heap,
setivar_idx_out_of_range,
setivar_val_heapobject,
setivar_name_not_mapped,
setivar_not_object,
setivar_frozen,
2021-03-11 19:25:19 +03:00
oaref_argc_not_one,
oaref_arg_not_fixnum,
Collect statistics about binding allocations / local variable set This commit collects statistics about how many binding objects are allocated as well as the number of local variables set on bindings. Statistics are output along with other YJIT stats. Here is an example of the output: ``` ***YJIT: Printing runtime counters from yjit.rb*** Number of Bindings Allocated: 195 Number of locals modified through binding: 0 opt_send_without_block exit reasons: ivar_get_method 7515891 (40.4%) se_cc_klass_differ 3081330 (16.6%) iseq_argc_mismatch 1564578 ( 8.4%) se_receiver_not_heap 1557663 ( 8.4%) ic_empty 1407064 ( 7.6%) optimized_method 995823 ( 5.4%) iseq_not_simple 819413 ( 4.4%) alias_method 706972 ( 3.8%) bmethod 685253 ( 3.7%) callsite_not_simple 225983 ( 1.2%) kw_splat 25999 ( 0.1%) ivar_set_method 902 ( 0.0%) cfunc_toomany_args 394 ( 0.0%) refined_method 42 ( 0.0%) cfunc_ruby_array_varg 29 ( 0.0%) invalid_cme 4 ( 0.0%) leave exit reasons: se_finish_frame 4067107 (100.0%) se_interrupt 24 ( 0.0%) getinstancevariable exit reasons: undef 121177 (100.0%) idx_out_of_range 5 ( 0.0%) opt_aref exit reasons: (all relevant counters are zero) compiled_iseq_count: 3944 main_block_code_size: 1.1 MiB side_block_code_size: 0.6 MiB vm_insns_count: 1137268516 yjit_exec_insns_count: 414015644 ratio_in_yjit: 26.7% avg_len_in_yjit: 7.5 total_exit_count: 55491789 most frequent exit op: opt_send_without_block: 18587628 (33.5%) opt_getinlinecache: 11075822 (20.0%) send: 4949300 (8.9%) leave: 4067131 (7.3%) defined: 3975196 (7.2%) setinstancevariable: 3567315 (6.4%) invokesuper: 2982163 (5.4%) getblockparamproxy: 2168852 (3.9%) opt_nil_p: 2104524 (3.8%) opt_aref: 2013858 (3.6%) ``` Running RailsBench allocates 195 binding objects but doesn't set any local variables.
2021-04-07 22:51:50 +03:00
binding_allocations,
binding_set,
vm_insns_count,
compiled_iseq_count,
2021-07-07 21:45:48 +03:00
expandarray_splat,
expandarray_postarg,
expandarray_not_array,
2021-07-14 20:46:18 +03:00
expandarray_rhs_too_small,
2021-07-07 21:45:48 +03:00
// Member with known name for iterating over counters
last_member
)
#undef YJIT_DECLARE_COUNTERS
struct yjit_comment {
uint32_t offset;
const char *comment;
};
typedef rb_darray(struct yjit_comment) yjit_comment_array_t;
extern yjit_comment_array_t yjit_code_comments;
#endif // if RUBY_DEBUG
RUBY_EXTERN struct rb_yjit_options rb_yjit_opts;
RUBY_EXTERN struct rb_yjit_runtime_counters yjit_runtime_counters;
void yjit_map_addr2insn(void *code_ptr, int insn);
VALUE *yjit_iseq_pc_at_idx(const rb_iseq_t *iseq, uint32_t insn_idx);
int yjit_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc);
2021-03-23 04:04:00 +03:00
void check_cfunc_dispatch(VALUE receiver, struct rb_callinfo *ci, void *callee, rb_callable_method_entry_t *compile_time_cme);
RBIMPL_ATTR_NODISCARD() bool assume_bop_not_redefined(block_t *block, int redefined_flag, enum ruby_basic_operators bop);
2021-03-18 02:07:20 +03:00
void assume_method_lookup_stable(VALUE receiver_klass, const rb_callable_method_entry_t *cme, block_t *block);
RBIMPL_ATTR_NODISCARD() bool assume_single_ractor_mode(block_t *block);
void assume_stable_global_constant_state(block_t *block);
// this function *must* return passed exit_pc
const VALUE *rb_yjit_count_side_exit_op(const VALUE *exit_pc);
void yjit_unlink_method_lookup_dependency(block_t *block);
void yjit_block_assumptions_free(block_t *block);
#endif // #ifndef YJIT_IFACE_H