2020-12-08 16:54:41 -05:00
|
|
|
//
|
2021-03-06 18:46:56 -05:00
|
|
|
// These are definitions YJIT uses to interface with the CRuby codebase,
|
|
|
|
// but which are only used internally by YJIT.
|
2020-12-08 16:54:41 -05:00
|
|
|
//
|
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
#ifndef YJIT_IFACE_H
|
|
|
|
#define YJIT_IFACE_H 1
|
2020-12-08 16:54:41 -05:00
|
|
|
|
2021-09-14 15:13:15 -04:00
|
|
|
#include "ruby/internal/config.h"
|
|
|
|
#include "ruby_assert.h" // for RUBY_DEBUG
|
|
|
|
#include "yjit.h" // for YJIT_STATS
|
2020-12-08 16:54:41 -05:00
|
|
|
#include "vm_core.h"
|
2021-03-06 18:46:56 -05:00
|
|
|
#include "yjit_core.h"
|
2020-12-08 16:54:41 -05:00
|
|
|
|
2021-06-23 21:19:10 -04:00
|
|
|
#ifndef YJIT_DEFAULT_CALL_THRESHOLD
|
|
|
|
# define YJIT_DEFAULT_CALL_THRESHOLD 10
|
|
|
|
#endif
|
|
|
|
|
2021-09-14 15:13:15 -04:00
|
|
|
#if YJIT_STATS
|
2021-08-24 06:32:07 -04:00
|
|
|
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;
|
2021-09-14 15:13:15 -04:00
|
|
|
#endif // if YJIT_STATS
|
2021-08-24 06:32:07 -04:00
|
|
|
|
|
|
|
|
|
|
|
#if YJIT_STATS
|
2021-03-31 18:27:34 -04:00
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
#define YJIT_DECLARE_COUNTERS(...) struct rb_yjit_runtime_counters { \
|
2021-03-02 18:27:50 -05:00
|
|
|
int64_t __VA_ARGS__; \
|
|
|
|
}; \
|
2021-03-06 18:46:56 -05:00
|
|
|
static char yjit_counter_names[] = #__VA_ARGS__;
|
2021-03-02 18:27:50 -05:00
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
YJIT_DECLARE_COUNTERS(
|
2021-03-02 18:27:50 -05:00
|
|
|
exec_instruction,
|
|
|
|
|
2021-05-04 12:35:51 -04:00
|
|
|
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,
|
2021-08-25 17:00:45 -04:00
|
|
|
send_cfunc_tracing,
|
2021-05-04 12:35:51 -04:00
|
|
|
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,
|
2021-03-02 18:27:50 -05:00
|
|
|
|
2021-08-25 17:00:45 -04:00
|
|
|
traced_cfunc_return,
|
|
|
|
|
2021-08-30 23:58:53 -04:00
|
|
|
invokesuper_me_changed,
|
|
|
|
invokesuper_block,
|
|
|
|
|
2021-03-03 17:31:20 -05:00
|
|
|
leave_se_interrupt,
|
2021-03-29 16:17:14 -04:00
|
|
|
leave_interp_return,
|
2021-07-15 14:09:08 -04:00
|
|
|
leave_start_pc_non_zero,
|
2021-03-03 17:31:20 -05:00
|
|
|
|
2021-03-12 12:22:19 -05:00
|
|
|
getivar_se_self_not_heap,
|
|
|
|
getivar_idx_out_of_range,
|
|
|
|
|
2021-04-21 16:01:03 -04:00
|
|
|
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 11:25:19 -05:00
|
|
|
oaref_argc_not_one,
|
|
|
|
oaref_arg_not_fixnum,
|
|
|
|
|
2021-09-21 18:16:23 -04:00
|
|
|
opt_getinlinecache_miss,
|
|
|
|
|
2021-04-07 15:51:50 -04:00
|
|
|
binding_allocations,
|
|
|
|
binding_set,
|
|
|
|
|
2021-06-28 13:06:03 -04:00
|
|
|
vm_insns_count,
|
|
|
|
compiled_iseq_count,
|
2021-09-15 13:59:50 -04:00
|
|
|
compiled_block_count,
|
|
|
|
invalidation_count,
|
|
|
|
constant_state_bumps,
|
2021-06-28 13:06:03 -04:00
|
|
|
|
2021-07-07 14:45:48 -04:00
|
|
|
expandarray_splat,
|
|
|
|
expandarray_postarg,
|
|
|
|
expandarray_not_array,
|
2021-07-14 13:46:18 -04:00
|
|
|
expandarray_rhs_too_small,
|
2021-07-07 14:45:48 -04:00
|
|
|
|
2021-03-02 18:27:50 -05:00
|
|
|
// Member with known name for iterating over counters
|
|
|
|
last_member
|
|
|
|
)
|
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
#undef YJIT_DECLARE_COUNTERS
|
2021-03-02 18:27:50 -05:00
|
|
|
|
2021-09-15 11:36:44 -04:00
|
|
|
RUBY_EXTERN struct rb_yjit_runtime_counters yjit_runtime_counters;
|
|
|
|
|
2021-08-24 06:32:07 -04:00
|
|
|
#endif // YJIT_STATS
|
2021-03-31 18:27:34 -04:00
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
RUBY_EXTERN struct rb_yjit_options rb_yjit_opts;
|
2021-01-26 15:21:47 -05:00
|
|
|
|
2021-03-24 18:07:26 -04:00
|
|
|
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-08-25 17:00:45 -04:00
|
|
|
void yjit_print_iseq(const rb_iseq_t *iseq);
|
2021-01-15 17:10:52 -05:00
|
|
|
|
2021-03-22 21:04:00 -04:00
|
|
|
void check_cfunc_dispatch(VALUE receiver, struct rb_callinfo *ci, void *callee, rb_callable_method_entry_t *compile_time_cme);
|
2021-02-25 15:10:38 -05:00
|
|
|
|
2021-03-09 14:01:16 -05:00
|
|
|
RBIMPL_ATTR_NODISCARD() bool assume_bop_not_redefined(block_t *block, int redefined_flag, enum ruby_basic_operators bop);
|
2021-03-17 19:07:20 -04:00
|
|
|
void assume_method_lookup_stable(VALUE receiver_klass, const rb_callable_method_entry_t *cme, block_t *block);
|
2021-02-25 15:10:38 -05:00
|
|
|
RBIMPL_ATTR_NODISCARD() bool assume_single_ractor_mode(block_t *block);
|
2021-03-24 18:07:26 -04:00
|
|
|
void assume_stable_global_constant_state(block_t *block);
|
2021-02-25 15:10:38 -05:00
|
|
|
|
2021-01-27 16:13:27 -05:00
|
|
|
// this function *must* return passed exit_pc
|
2021-03-06 18:46:56 -05:00
|
|
|
const VALUE *rb_yjit_count_side_exit_op(const VALUE *exit_pc);
|
2021-02-25 15:10:38 -05:00
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
void yjit_unlink_method_lookup_dependency(block_t *block);
|
|
|
|
void yjit_block_assumptions_free(block_t *block);
|
2020-12-08 16:54:41 -05:00
|
|
|
|
2021-09-21 10:59:55 -04:00
|
|
|
VALUE rb_yjit_code_page_alloc(void);
|
|
|
|
code_page_t *rb_yjit_code_page_unwrap(VALUE cp_obj);
|
|
|
|
void rb_yjit_get_cb(codeblock_t* cb, uint8_t* code_ptr);
|
|
|
|
void rb_yjit_get_ocb(codeblock_t* cb, uint8_t* code_ptr);
|
|
|
|
|
2021-06-23 21:19:10 -04:00
|
|
|
#endif // #ifndef YJIT_IFACE_H
|