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-03-12 12:25:58 -05:00
|
|
|
#include "ruby/ruby.h"
|
2021-03-31 18:27:34 -04:00
|
|
|
#include "ruby/assert.h" // for RUBY_DEBUG
|
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-03-31 18:27:34 -04:00
|
|
|
#if RUBY_DEBUG
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
oswb_callsite_not_simple,
|
|
|
|
oswb_kw_splat,
|
|
|
|
oswb_ic_empty,
|
|
|
|
oswb_invalid_cme,
|
|
|
|
oswb_ivar_set_method,
|
|
|
|
oswb_ivar_get_method,
|
|
|
|
oswb_zsuper_method,
|
|
|
|
oswb_alias_method,
|
|
|
|
oswb_undef_method,
|
|
|
|
oswb_optimized_method,
|
|
|
|
oswb_missing_method,
|
|
|
|
oswb_bmethod,
|
|
|
|
oswb_refined_method,
|
|
|
|
oswb_unknown_method_type,
|
|
|
|
oswb_cfunc_ruby_array_varg,
|
|
|
|
oswb_cfunc_argc_mismatch,
|
|
|
|
oswb_cfunc_toomany_args,
|
|
|
|
oswb_iseq_tailcall,
|
|
|
|
oswb_iseq_argc_mismatch,
|
|
|
|
oswb_iseq_not_simple,
|
|
|
|
oswb_not_implemented_method,
|
|
|
|
oswb_se_receiver_not_heap,
|
|
|
|
oswb_se_cf_overflow,
|
|
|
|
oswb_se_cc_klass_differ,
|
2021-03-03 16:29:54 -05:00
|
|
|
oswb_se_protected_check_failed,
|
2021-03-02 18:27:50 -05:00
|
|
|
|
2021-03-03 17:31:20 -05:00
|
|
|
leave_se_finish_frame,
|
|
|
|
leave_se_interrupt,
|
2021-03-29 16:17:14 -04:00
|
|
|
leave_interp_return,
|
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,
|
|
|
|
getivar_undef,
|
|
|
|
|
2021-03-11 11:25:19 -05:00
|
|
|
oaref_argc_not_one,
|
|
|
|
oaref_arg_not_fixnum,
|
|
|
|
|
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-03-31 18:27:34 -04:00
|
|
|
#endif // if RUBY_DEBUG
|
|
|
|
|
2021-03-06 18:46:56 -05:00
|
|
|
RUBY_EXTERN struct rb_yjit_options rb_yjit_opts;
|
2021-02-16 11:15:29 -05:00
|
|
|
RUBY_EXTERN int64_t rb_compiled_iseq_count;
|
2021-03-06 18:46:56 -05:00
|
|
|
RUBY_EXTERN struct rb_yjit_runtime_counters yjit_runtime_counters;
|
2021-01-26 15:21:47 -05:00
|
|
|
|
2020-12-08 17:19:28 -05:00
|
|
|
void cb_write_pre_call_bytes(codeblock_t* cb);
|
|
|
|
void cb_write_post_call_bytes(codeblock_t* cb);
|
2021-01-15 17:10:52 -05:00
|
|
|
|
2021-03-02 12:03:11 -05:00
|
|
|
VALUE *iseq_pc_at_idx(const rb_iseq_t *iseq, uint32_t insn_idx);
|
2020-12-08 16:54:41 -05:00
|
|
|
void map_addr2insn(void *code_ptr, int insn);
|
|
|
|
int opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc);
|
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-01-15 17:10:52 -05:00
|
|
|
bool cfunc_needs_frame(const rb_method_cfunc_t *cfunc);
|
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);
|
|
|
|
RBIMPL_ATTR_NODISCARD() bool assume_stable_global_constant_state(block_t *block);
|
|
|
|
|
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-03-06 18:46:56 -05:00
|
|
|
#endif // #ifndef YJIT_IFACE_
|