summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.mk236
-rw-r--r--configure.ac7
-rw-r--r--jit.c423
-rw-r--r--template/Makefile.in1
-rw-r--r--yjit.c403
-rw-r--r--yjit/bindgen/src/main.rs1
-rw-r--r--yjit/src/cruby_bindings.inc.rs133
-rw-r--r--zjit.c408
-rw-r--r--zjit/bindgen/src/main.rs1
-rw-r--r--zjit/src/cruby_bindings.inc.rs96
10 files changed, 782 insertions, 927 deletions
@@ -189,6 +189,7 @@ COMMONOBJS = array.$(OBJEXT) \
$(YJIT_LIBOBJ) \
$(ZJIT_OBJ) \
$(ZJIT_LIBOBJ) \
$(COROUTINE_OBJ) \
$(DTRACE_OBJ) \
$(BUILTIN_ENCOBJS) \
@@ -9156,6 +9157,241 @@ iseq.$(OBJEXT): {$(VPATH)}vm_debug.h
iseq.$(OBJEXT): {$(VPATH)}vm_opts.h
iseq.$(OBJEXT): {$(VPATH)}vm_sync.h
iseq.$(OBJEXT): {$(VPATH)}yjit.h
load.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
load.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
load.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -3967,6 +3967,7 @@ AS_CASE(["${YJIT_SUPPORT}"],
LDFLAGS="$LDFLAGS -lpthread -lc++abi"
])
YJIT_OBJ='yjit.$(OBJEXT)'
AS_IF([test x"$YJIT_SUPPORT" != "xyes" ], [
AC_DEFINE_UNQUOTED(YJIT_SUPPORT, [$YJIT_SUPPORT])
])
@@ -4008,6 +4009,7 @@ AS_CASE(["${ZJIT_SUPPORT}"],
LDFLAGS="$LDFLAGS -lpthread -lc++abi"
])
ZJIT_OBJ='zjit.$(OBJEXT)'
AS_IF([test x"$ZJIT_SUPPORT" != "xyes" ], [
AC_DEFINE_UNQUOTED(ZJIT_SUPPORT, [$ZJIT_SUPPORT])
])
@@ -4025,8 +4027,9 @@ AC_SUBST(ZJIT_CARGO_BUILD_ARGS)dnl for selecting Rust build profiles
AC_SUBST(YJIT_LIBS)dnl for optionally building the Rust parts of YJIT
AC_SUBST(YJIT_OBJ)dnl for optionally building the C parts of YJIT
AC_SUBST(ZJIT_SUPPORT)dnl what flavor of ZJIT the Ruby build includes
-AC_SUBST(ZJIT_LIBS)dnl for optionally building the Rust parts of YJIT
-AC_SUBST(ZJIT_OBJ)dnl for optionally building the C parts of YJIT
}
[begin]_group "build section" && {
@@ -0,0 +1,423 @@
@@ -102,6 +102,7 @@ USE_RUBYGEMS = @USE_RUBYGEMS@
USE_RUBYGEMS_ = $(USE_RUBYGEMS:yes=)
CPPFLAGS = @CPPFLAGS@ $(USE_RUBYGEMS_:no=-DDISABLE_RUBYGEMS=1)
TOP_BUILD_DIR=@abs_top_builddir@
YJIT_SUPPORT=@YJIT_SUPPORT@
YJIT_LIBS=@YJIT_LIBS@
YJIT_OBJ=@YJIT_OBJ@
@@ -396,12 +396,6 @@ rb_full_cfunc_return(rb_execution_context_t *ec, VALUE return_value)
ec->cfp->sp++;
}
-unsigned int
-rb_iseq_encoded_size(const rb_iseq_t *iseq)
-{
- return iseq->body->iseq_size;
-}
-
// TODO(alan): consider using an opaque pointer for the payload rather than a void pointer
void *
rb_iseq_get_yjit_payload(const rb_iseq_t *iseq)
@@ -437,40 +431,6 @@ rb_iseq_reset_jit_func(const rb_iseq_t *iseq)
iseq->body->jit_exception_calls = 0;
}
-// Get the PC for a given index in an iseq
-VALUE *
-rb_iseq_pc_at_idx(const rb_iseq_t *iseq, uint32_t insn_idx)
-{
- RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(iseq, imemo_iseq));
- RUBY_ASSERT_ALWAYS(insn_idx < iseq->body->iseq_size);
- VALUE *encoded = iseq->body->iseq_encoded;
- VALUE *pc = &encoded[insn_idx];
- return pc;
-}
-
-// Get the opcode given a program counter. Can return trace opcode variants.
-int
-rb_iseq_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc)
-{
- // YJIT should only use iseqs after AST to bytecode compilation
- RUBY_ASSERT_ALWAYS(FL_TEST_RAW((VALUE)iseq, ISEQ_TRANSLATED));
-
- const VALUE at_pc = *pc;
- return rb_vm_insn_addr2opcode((const void *)at_pc);
-}
-
-unsigned long
-rb_RSTRING_LEN(VALUE str)
-{
- return RSTRING_LEN(str);
-}
-
-char *
-rb_RSTRING_PTR(VALUE str)
-{
- return RSTRING_PTR(str);
-}
-
rb_proc_t *
rb_yjit_get_proc_ptr(VALUE procv)
{
@@ -484,121 +444,8 @@ rb_yjit_get_proc_ptr(VALUE procv)
// Bindgen's temp/anon name isn't guaranteed stable.
typedef struct rb_iseq_param_keyword rb_seq_param_keyword_struct;
-const char *
-rb_insn_name(VALUE insn)
-{
- return insn_name(insn);
-}
-
-unsigned int
-rb_vm_ci_argc(const struct rb_callinfo *ci)
-{
- return vm_ci_argc(ci);
-}
-
-ID
-rb_vm_ci_mid(const struct rb_callinfo *ci)
-{
- return vm_ci_mid(ci);
-}
-
-unsigned int
-rb_vm_ci_flag(const struct rb_callinfo *ci)
-{
- return vm_ci_flag(ci);
-}
-
-const struct rb_callinfo_kwarg *
-rb_vm_ci_kwarg(const struct rb_callinfo *ci)
-{
- return vm_ci_kwarg(ci);
-}
-
-int
-rb_get_cikw_keyword_len(const struct rb_callinfo_kwarg *cikw)
-{
- return cikw->keyword_len;
-}
-
-VALUE
-rb_get_cikw_keywords_idx(const struct rb_callinfo_kwarg *cikw, int idx)
-{
- return cikw->keywords[idx];
-}
-
-rb_method_visibility_t
-rb_METHOD_ENTRY_VISI(const rb_callable_method_entry_t *me)
-{
- return METHOD_ENTRY_VISI(me);
-}
-
-rb_method_type_t
-rb_get_cme_def_type(const rb_callable_method_entry_t *cme)
-{
- if (UNDEFINED_METHOD_ENTRY_P(cme)) {
- return VM_METHOD_TYPE_UNDEF;
- }
- else {
- return cme->def->type;
- }
-}
-
-ID
-rb_get_cme_def_body_attr_id(const rb_callable_method_entry_t *cme)
-{
- return cme->def->body.attr.id;
-}
-
ID rb_get_symbol_id(VALUE namep);
-enum method_optimized_type
-rb_get_cme_def_body_optimized_type(const rb_callable_method_entry_t *cme)
-{
- return cme->def->body.optimized.type;
-}
-
-unsigned int
-rb_get_cme_def_body_optimized_index(const rb_callable_method_entry_t *cme)
-{
- return cme->def->body.optimized.index;
-}
-
-rb_method_cfunc_t *
-rb_get_cme_def_body_cfunc(const rb_callable_method_entry_t *cme)
-{
- return UNALIGNED_MEMBER_PTR(cme->def, body.cfunc);
-}
-
-uintptr_t
-rb_get_def_method_serial(const rb_method_definition_t *def)
-{
- return def->method_serial;
-}
-
-ID
-rb_get_def_original_id(const rb_method_definition_t *def)
-{
- return def->original_id;
-}
-
-int
-rb_get_mct_argc(const rb_method_cfunc_t *mct)
-{
- return mct->argc;
-}
-
-void *
-rb_get_mct_func(const rb_method_cfunc_t *mct)
-{
- return (void*)(uintptr_t)mct->func; // this field is defined as type VALUE (*func)(ANYARGS)
-}
-
-const rb_iseq_t *
-rb_get_def_iseq_ptr(rb_method_definition_t *def)
-{
- return def_iseq_ptr(def);
-}
-
VALUE
rb_get_def_bmethod_proc(rb_method_definition_t *def)
{
@@ -607,143 +454,11 @@ rb_get_def_bmethod_proc(rb_method_definition_t *def)
}
const rb_iseq_t *
-rb_get_iseq_body_local_iseq(const rb_iseq_t *iseq)
-{
- return iseq->body->local_iseq;
-}
-
-const rb_iseq_t *
rb_get_iseq_body_parent_iseq(const rb_iseq_t *iseq)
{
return iseq->body->parent_iseq;
}
-unsigned int
-rb_get_iseq_body_local_table_size(const rb_iseq_t *iseq)
-{
- return iseq->body->local_table_size;
-}
-
-VALUE *
-rb_get_iseq_body_iseq_encoded(const rb_iseq_t *iseq)
-{
- return iseq->body->iseq_encoded;
-}
-
-unsigned
-rb_get_iseq_body_stack_max(const rb_iseq_t *iseq)
-{
- return iseq->body->stack_max;
-}
-
-enum rb_iseq_type
-rb_get_iseq_body_type(const rb_iseq_t *iseq)
-{
- return iseq->body->type;
-}
-
-bool
-rb_get_iseq_flags_has_lead(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_lead;
-}
-
-bool
-rb_get_iseq_flags_has_opt(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_opt;
-}
-
-bool
-rb_get_iseq_flags_has_kw(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_kw;
-}
-
-bool
-rb_get_iseq_flags_has_post(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_post;
-}
-
-bool
-rb_get_iseq_flags_has_kwrest(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_kwrest;
-}
-
-bool
-rb_get_iseq_flags_anon_kwrest(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.anon_kwrest;
-}
-
-bool
-rb_get_iseq_flags_has_rest(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_rest;
-}
-
-bool
-rb_get_iseq_flags_ruby2_keywords(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.ruby2_keywords;
-}
-
-bool
-rb_get_iseq_flags_has_block(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_block;
-}
-
-bool
-rb_get_iseq_flags_ambiguous_param0(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.ambiguous_param0;
-}
-
-bool
-rb_get_iseq_flags_accepts_no_kwarg(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.accepts_no_kwarg;
-}
-
-bool
-rb_get_iseq_flags_forwardable(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.forwardable;
-}
-
-const rb_seq_param_keyword_struct *
-rb_get_iseq_body_param_keyword(const rb_iseq_t *iseq)
-{
- return iseq->body->param.keyword;
-}
-
-unsigned
-rb_get_iseq_body_param_size(const rb_iseq_t *iseq)
-{
- return iseq->body->param.size;
-}
-
-int
-rb_get_iseq_body_param_lead_num(const rb_iseq_t *iseq)
-{
- return iseq->body->param.lead_num;
-}
-
-int
-rb_get_iseq_body_param_opt_num(const rb_iseq_t *iseq)
-{
- return iseq->body->param.opt_num;
-}
-
-const VALUE *
-rb_get_iseq_body_param_opt_table(const rb_iseq_t *iseq)
-{
- return iseq->body->param.opt_table;
-}
-
VALUE
rb_optimized_call(VALUE *recv, rb_execution_context_t *ec, int argc, VALUE *argv, int kw_splat, VALUE block_handler)
{
@@ -789,30 +504,6 @@ rb_yjit_str_simple_append(VALUE str1, VALUE str2)
return rb_str_cat(str1, RSTRING_PTR(str2), RSTRING_LEN(str2));
}
-struct rb_control_frame_struct *
-rb_get_ec_cfp(const rb_execution_context_t *ec)
-{
- return ec->cfp;
-}
-
-const rb_iseq_t *
-rb_get_cfp_iseq(struct rb_control_frame_struct *cfp)
-{
- return cfp->iseq;
-}
-
-VALUE *
-rb_get_cfp_pc(struct rb_control_frame_struct *cfp)
-{
- return (VALUE*)cfp->pc;
-}
-
-VALUE *
-rb_get_cfp_sp(struct rb_control_frame_struct *cfp)
-{
- return cfp->sp;
-}
-
void
rb_set_cfp_pc(struct rb_control_frame_struct *cfp, const VALUE *pc)
{
@@ -825,37 +516,8 @@ rb_set_cfp_sp(struct rb_control_frame_struct *cfp, VALUE *sp)
cfp->sp = sp;
}
-VALUE
-rb_get_cfp_self(struct rb_control_frame_struct *cfp)
-{
- return cfp->self;
-}
-
-VALUE *
-rb_get_cfp_ep(struct rb_control_frame_struct *cfp)
-{
- return (VALUE*)cfp->ep;
-}
-
-const VALUE *
-rb_get_cfp_ep_level(struct rb_control_frame_struct *cfp, uint32_t lv)
-{
- uint32_t i;
- const VALUE *ep = (VALUE*)cfp->ep;
- for (i = 0; i < lv; i++) {
- ep = VM_ENV_PREV_EP(ep);
- }
- return ep;
-}
-
extern VALUE *rb_vm_base_ptr(struct rb_control_frame_struct *cfp);
-VALUE
-rb_yarv_class_of(VALUE obj)
-{
- return rb_class_of(obj);
-}
-
// YJIT needs this function to never allocate and never raise
VALUE
rb_yarv_str_eql_internal(VALUE str1, VALUE str2)
@@ -989,33 +651,6 @@ rb_yjit_iseq_inspect(const rb_iseq_t *iseq)
return buf;
}
-// The FL_TEST() macro
-VALUE
-rb_FL_TEST(VALUE obj, VALUE flags)
-{
- return RB_FL_TEST(obj, flags);
-}
-
-// The FL_TEST_RAW() macro, normally an internal implementation detail
-VALUE
-rb_FL_TEST_RAW(VALUE obj, VALUE flags)
-{
- return FL_TEST_RAW(obj, flags);
-}
-
-// The RB_TYPE_P macro
-bool
-rb_RB_TYPE_P(VALUE obj, enum ruby_value_type t)
-{
- return RB_TYPE_P(obj, t);
-}
-
-long
-rb_RSTRUCT_LEN(VALUE st)
-{
- return RSTRUCT_LEN(st);
-}
-
// There are RSTRUCT_SETs in ruby/internal/core/rstruct.h and internal/struct.h
// with different types (int vs long) for k. Here we use the one from ruby/internal/core/rstruct.h,
// which takes an int.
@@ -1025,24 +660,6 @@ rb_RSTRUCT_SET(VALUE st, int k, VALUE v)
RSTRUCT_SET(st, k, v);
}
-const struct rb_callinfo *
-rb_get_call_data_ci(const struct rb_call_data *cd)
-{
- return cd->ci;
-}
-
-bool
-rb_BASIC_OP_UNREDEFINED_P(enum ruby_basic_operators bop, uint32_t klass)
-{
- return BASIC_OP_UNREDEFINED_P(bop, klass);
-}
-
-VALUE
-rb_RCLASS_ORIGIN(VALUE c)
-{
- return RCLASS_ORIGIN(c);
-}
-
// Return the string encoding index
int
rb_ENCODING_GET(VALUE obj)
@@ -1056,32 +673,12 @@ rb_yjit_multi_ractor_p(void)
return rb_multi_ractor_p();
}
-// For debug builds
-void
-rb_assert_iseq_handle(VALUE handle)
-{
- RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(handle, imemo_iseq));
-}
-
-int
-rb_IMEMO_TYPE_P(VALUE imemo, enum imemo_type imemo_type)
-{
- return IMEMO_TYPE_P(imemo, imemo_type);
-}
-
bool
rb_yjit_constcache_shareable(const struct iseq_inline_constant_cache_entry *ice)
{
return (ice->flags & IMEMO_CONST_CACHE_SHAREABLE) != 0;
}
-void
-rb_assert_cme_handle(VALUE handle)
-{
- RUBY_ASSERT_ALWAYS(!rb_objspace_garbage_object_p(handle));
- RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(handle, imemo_ment));
-}
-
// Used for passing a callback and other data over rb_objspace_each_objects
struct iseq_callback_data {
rb_iseq_callback callback;
@@ -47,6 +47,7 @@ fn main() {
// Our C file for glue code
.header(src_root.join("yjit.c").to_str().unwrap())
// Don't want to copy over C comment
.generate_comments(false)
@@ -979,6 +979,7 @@ pub type robject_offsets = u32;
pub const RUBY_OFFSET_RSTRING_LEN: rstring_offsets = 16;
pub type rstring_offsets = u32;
pub type rb_seq_param_keyword_struct = rb_iseq_constant_body__bindgen_ty_1_rb_iseq_param_keyword;
extern "C" {
pub fn ruby_xfree(ptr: *mut ::std::os::raw::c_void);
pub fn rb_class_attached_object(klass: VALUE) -> VALUE;
@@ -1163,15 +1164,78 @@ extern "C" {
pub fn rb_yjit_reserve_addr_space(mem_size: u32) -> *mut u8;
pub fn rb_c_method_tracing_currently_enabled(ec: *const rb_execution_context_t) -> bool;
pub fn rb_full_cfunc_return(ec: *mut rb_execution_context_t, return_value: VALUE);
- pub fn rb_iseq_encoded_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
pub fn rb_iseq_get_yjit_payload(iseq: *const rb_iseq_t) -> *mut ::std::os::raw::c_void;
pub fn rb_iseq_set_yjit_payload(iseq: *const rb_iseq_t, payload: *mut ::std::os::raw::c_void);
pub fn rb_iseq_reset_jit_func(iseq: *const rb_iseq_t);
pub fn rb_iseq_pc_at_idx(iseq: *const rb_iseq_t, insn_idx: u32) -> *mut VALUE;
pub fn rb_iseq_opcode_at_pc(iseq: *const rb_iseq_t, pc: *const VALUE) -> ::std::os::raw::c_int;
pub fn rb_RSTRING_LEN(str_: VALUE) -> ::std::os::raw::c_ulong;
pub fn rb_RSTRING_PTR(str_: VALUE) -> *mut ::std::os::raw::c_char;
- pub fn rb_yjit_get_proc_ptr(procv: VALUE) -> *mut rb_proc_t;
pub fn rb_insn_name(insn: VALUE) -> *const ::std::os::raw::c_char;
pub fn rb_vm_ci_argc(ci: *const rb_callinfo) -> ::std::os::raw::c_uint;
pub fn rb_vm_ci_mid(ci: *const rb_callinfo) -> ID;
@@ -1185,7 +1249,6 @@ extern "C" {
pub fn rb_METHOD_ENTRY_VISI(me: *const rb_callable_method_entry_t) -> rb_method_visibility_t;
pub fn rb_get_cme_def_type(cme: *const rb_callable_method_entry_t) -> rb_method_type_t;
pub fn rb_get_cme_def_body_attr_id(cme: *const rb_callable_method_entry_t) -> ID;
- pub fn rb_get_symbol_id(namep: VALUE) -> ID;
pub fn rb_get_cme_def_body_optimized_type(
cme: *const rb_callable_method_entry_t,
) -> method_optimized_type;
@@ -1200,9 +1263,7 @@ extern "C" {
pub fn rb_get_mct_argc(mct: *const rb_method_cfunc_t) -> ::std::os::raw::c_int;
pub fn rb_get_mct_func(mct: *const rb_method_cfunc_t) -> *mut ::std::os::raw::c_void;
pub fn rb_get_def_iseq_ptr(def: *mut rb_method_definition_t) -> *const rb_iseq_t;
- pub fn rb_get_def_bmethod_proc(def: *mut rb_method_definition_t) -> VALUE;
pub fn rb_get_iseq_body_local_iseq(iseq: *const rb_iseq_t) -> *const rb_iseq_t;
- pub fn rb_get_iseq_body_parent_iseq(iseq: *const rb_iseq_t) -> *const rb_iseq_t;
pub fn rb_get_iseq_body_local_table_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
pub fn rb_get_iseq_body_iseq_encoded(iseq: *const rb_iseq_t) -> *mut VALUE;
pub fn rb_get_iseq_body_stack_max(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
@@ -1221,87 +1282,27 @@ extern "C" {
pub fn rb_get_iseq_flags_forwardable(iseq: *const rb_iseq_t) -> bool;
pub fn rb_get_iseq_body_param_keyword(
iseq: *const rb_iseq_t,
- ) -> *const rb_seq_param_keyword_struct;
pub fn rb_get_iseq_body_param_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
pub fn rb_get_iseq_body_param_lead_num(iseq: *const rb_iseq_t) -> ::std::os::raw::c_int;
pub fn rb_get_iseq_body_param_opt_num(iseq: *const rb_iseq_t) -> ::std::os::raw::c_int;
pub fn rb_get_iseq_body_param_opt_table(iseq: *const rb_iseq_t) -> *const VALUE;
- pub fn rb_optimized_call(
- recv: *mut VALUE,
- ec: *mut rb_execution_context_t,
- argc: ::std::os::raw::c_int,
- argv: *mut VALUE,
- kw_splat: ::std::os::raw::c_int,
- block_handler: VALUE,
- ) -> VALUE;
- pub fn rb_yjit_iseq_builtin_attrs(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
- pub fn rb_yjit_builtin_function(iseq: *const rb_iseq_t) -> *const rb_builtin_function;
- pub fn rb_yjit_str_simple_append(str1: VALUE, str2: VALUE) -> VALUE;
pub fn rb_get_ec_cfp(ec: *const rb_execution_context_t) -> *mut rb_control_frame_struct;
pub fn rb_get_cfp_iseq(cfp: *mut rb_control_frame_struct) -> *const rb_iseq_t;
pub fn rb_get_cfp_pc(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
pub fn rb_get_cfp_sp(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
- pub fn rb_set_cfp_pc(cfp: *mut rb_control_frame_struct, pc: *const VALUE);
- pub fn rb_set_cfp_sp(cfp: *mut rb_control_frame_struct, sp: *mut VALUE);
pub fn rb_get_cfp_self(cfp: *mut rb_control_frame_struct) -> VALUE;
pub fn rb_get_cfp_ep(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
pub fn rb_get_cfp_ep_level(cfp: *mut rb_control_frame_struct, lv: u32) -> *const VALUE;
- pub fn rb_vm_base_ptr(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
pub fn rb_yarv_class_of(obj: VALUE) -> VALUE;
- pub fn rb_yarv_str_eql_internal(str1: VALUE, str2: VALUE) -> VALUE;
- pub fn rb_str_neq_internal(str1: VALUE, str2: VALUE) -> VALUE;
- pub fn rb_yarv_ary_entry_internal(ary: VALUE, offset: ::std::os::raw::c_long) -> VALUE;
- pub fn rb_ary_unshift_m(argc: ::std::os::raw::c_int, argv: *mut VALUE, ary: VALUE) -> VALUE;
- pub fn rb_yjit_rb_ary_subseq_length(ary: VALUE, beg: ::std::os::raw::c_long) -> VALUE;
- pub fn rb_yjit_fix_div_fix(recv: VALUE, obj: VALUE) -> VALUE;
- pub fn rb_yjit_fix_mod_fix(recv: VALUE, obj: VALUE) -> VALUE;
- pub fn rb_yjit_ruby2_keywords_splat_p(obj: VALUE) -> usize;
- pub fn rb_yjit_splat_varg_checks(
- sp: *mut VALUE,
- splat_array: VALUE,
- cfp: *mut rb_control_frame_t,
- ) -> VALUE;
- pub fn rb_yjit_splat_varg_cfunc(stack_splat_array: *mut VALUE) -> ::std::os::raw::c_int;
- pub fn rb_yjit_dump_iseq_loc(iseq: *const rb_iseq_t, insn_idx: u32);
- pub fn rb_yjit_iseq_inspect(iseq: *const rb_iseq_t) -> *mut ::std::os::raw::c_char;
pub fn rb_FL_TEST(obj: VALUE, flags: VALUE) -> VALUE;
pub fn rb_FL_TEST_RAW(obj: VALUE, flags: VALUE) -> VALUE;
pub fn rb_RB_TYPE_P(obj: VALUE, t: ruby_value_type) -> bool;
pub fn rb_RSTRUCT_LEN(st: VALUE) -> ::std::os::raw::c_long;
- pub fn rb_RSTRUCT_SET(st: VALUE, k: ::std::os::raw::c_int, v: VALUE);
pub fn rb_get_call_data_ci(cd: *const rb_call_data) -> *const rb_callinfo;
pub fn rb_BASIC_OP_UNREDEFINED_P(bop: ruby_basic_operators, klass: u32) -> bool;
pub fn rb_RCLASS_ORIGIN(c: VALUE) -> VALUE;
- pub fn rb_ENCODING_GET(obj: VALUE) -> ::std::os::raw::c_int;
- pub fn rb_yjit_multi_ractor_p() -> bool;
pub fn rb_assert_iseq_handle(handle: VALUE);
pub fn rb_IMEMO_TYPE_P(imemo: VALUE, imemo_type: imemo_type) -> ::std::os::raw::c_int;
- pub fn rb_yjit_constcache_shareable(ice: *const iseq_inline_constant_cache_entry) -> bool;
pub fn rb_assert_cme_handle(handle: VALUE);
- pub fn rb_yjit_for_each_iseq(callback: rb_iseq_callback, data: *mut ::std::os::raw::c_void);
- pub fn rb_yjit_obj_written(
- old: VALUE,
- young: VALUE,
- file: *const ::std::os::raw::c_char,
- line: ::std::os::raw::c_int,
- );
- pub fn rb_yjit_vm_lock_then_barrier(
- recursive_lock_level: *mut ::std::os::raw::c_uint,
- file: *const ::std::os::raw::c_char,
- line: ::std::os::raw::c_int,
- );
- pub fn rb_yjit_vm_unlock(
- recursive_lock_level: *mut ::std::os::raw::c_uint,
- file: *const ::std::os::raw::c_char,
- line: ::std::os::raw::c_int,
- );
- pub fn rb_object_shape_count() -> VALUE;
- pub fn rb_yjit_assert_holding_vm_lock();
- pub fn rb_yjit_sendish_sp_pops(ci: *const rb_callinfo) -> usize;
- pub fn rb_yjit_invokeblock_sp_pops(ci: *const rb_callinfo) -> usize;
- pub fn rb_yjit_set_exception_return(
- cfp: *mut rb_control_frame_t,
- leave_exit: *mut ::std::os::raw::c_void,
- leave_exception: *mut ::std::os::raw::c_void,
- );
}
@@ -156,18 +156,6 @@ rb_zjit_reserve_addr_space(uint32_t mem_size)
#endif
}
-unsigned long
-rb_RSTRING_LEN(VALUE str)
-{
- return RSTRING_LEN(str);
-}
-
-char *
-rb_RSTRING_PTR(VALUE str)
-{
- return RSTRING_PTR(str);
-}
-
void rb_zjit_profile_disable(const rb_iseq_t *iseq);
void
@@ -189,374 +177,20 @@ rb_zjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit
RB_VM_LOCK_LEAVE();
}
-unsigned int
-rb_iseq_encoded_size(const rb_iseq_t *iseq)
-{
- return iseq->body->iseq_size;
-}
-
-// Get the opcode given a program counter. Can return trace opcode variants.
-int
-rb_iseq_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc)
-{
- // ZJIT should only use iseqs after AST to bytecode compilation
- RUBY_ASSERT_ALWAYS(FL_TEST_RAW((VALUE)iseq, ISEQ_TRANSLATED));
-
- const VALUE at_pc = *pc;
- return rb_vm_insn_addr2opcode((const void *)at_pc);
-}
-
-// Get the PC for a given index in an iseq
-VALUE *
-rb_iseq_pc_at_idx(const rb_iseq_t *iseq, uint32_t insn_idx)
-{
- RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(iseq, imemo_iseq));
- RUBY_ASSERT_ALWAYS(insn_idx < iseq->body->iseq_size);
- VALUE *encoded = iseq->body->iseq_encoded;
- VALUE *pc = &encoded[insn_idx];
- return pc;
-}
-
-const char *
-rb_insn_name(VALUE insn)
-{
- return insn_name(insn);
-}
-
-struct rb_control_frame_struct *
-rb_get_ec_cfp(const rb_execution_context_t *ec)
-{
- return ec->cfp;
-}
-
-const rb_iseq_t *
-rb_get_cfp_iseq(struct rb_control_frame_struct *cfp)
-{
- return cfp->iseq;
-}
-
-VALUE *
-rb_get_cfp_pc(struct rb_control_frame_struct *cfp)
-{
- return (VALUE*)cfp->pc;
-}
-
-VALUE *
-rb_get_cfp_sp(struct rb_control_frame_struct *cfp)
-{
- return cfp->sp;
-}
-
-VALUE
-rb_get_cfp_self(struct rb_control_frame_struct *cfp)
-{
- return cfp->self;
-}
-
-VALUE *
-rb_get_cfp_ep(struct rb_control_frame_struct *cfp)
-{
- return (VALUE*)cfp->ep;
-}
-
-const VALUE *
-rb_get_cfp_ep_level(struct rb_control_frame_struct *cfp, uint32_t lv)
-{
- uint32_t i;
- const VALUE *ep = (VALUE*)cfp->ep;
- for (i = 0; i < lv; i++) {
- ep = VM_ENV_PREV_EP(ep);
- }
- return ep;
-}
-
extern VALUE *rb_vm_base_ptr(struct rb_control_frame_struct *cfp);
-rb_method_type_t
-rb_get_cme_def_type(const rb_callable_method_entry_t *cme)
-{
- if (UNDEFINED_METHOD_ENTRY_P(cme)) {
- return VM_METHOD_TYPE_UNDEF;
- }
- else {
- return cme->def->type;
- }
-}
-
-ID
-rb_get_cme_def_body_attr_id(const rb_callable_method_entry_t *cme)
-{
- return cme->def->body.attr.id;
-}
-
-enum method_optimized_type
-rb_get_cme_def_body_optimized_type(const rb_callable_method_entry_t *cme)
-{
- return cme->def->body.optimized.type;
-}
-
-unsigned int
-rb_get_cme_def_body_optimized_index(const rb_callable_method_entry_t *cme)
-{
- return cme->def->body.optimized.index;
-}
-
-rb_method_cfunc_t *
-rb_get_cme_def_body_cfunc(const rb_callable_method_entry_t *cme)
-{
- return UNALIGNED_MEMBER_PTR(cme->def, body.cfunc);
-}
-
-uintptr_t
-rb_get_def_method_serial(const rb_method_definition_t *def)
-{
- return def->method_serial;
-}
-
-ID
-rb_get_def_original_id(const rb_method_definition_t *def)
-{
- return def->original_id;
-}
-
-int
-rb_get_mct_argc(const rb_method_cfunc_t *mct)
-{
- return mct->argc;
-}
-
-void *
-rb_get_mct_func(const rb_method_cfunc_t *mct)
-{
- return (void*)(uintptr_t)mct->func; // this field is defined as type VALUE (*func)(ANYARGS)
-}
-
-const rb_iseq_t *
-rb_get_def_iseq_ptr(rb_method_definition_t *def)
-{
- return def_iseq_ptr(def);
-}
-
-const rb_iseq_t *
-rb_get_iseq_body_local_iseq(const rb_iseq_t *iseq)
-{
- return iseq->body->local_iseq;
-}
-
-VALUE *
-rb_get_iseq_body_iseq_encoded(const rb_iseq_t *iseq)
-{
- return iseq->body->iseq_encoded;
-}
-
-unsigned
-rb_get_iseq_body_stack_max(const rb_iseq_t *iseq)
-{
- return iseq->body->stack_max;
-}
-
-enum rb_iseq_type
-rb_get_iseq_body_type(const rb_iseq_t *iseq)
-{
- return iseq->body->type;
-}
-
-bool
-rb_get_iseq_flags_has_lead(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_lead;
-}
-
-bool
-rb_get_iseq_flags_has_opt(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_opt;
-}
-
-bool
-rb_get_iseq_flags_has_kw(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_kw;
-}
-
-bool
-rb_get_iseq_flags_has_post(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_post;
-}
-
-bool
-rb_get_iseq_flags_has_kwrest(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_kwrest;
-}
-
-bool
-rb_get_iseq_flags_anon_kwrest(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.anon_kwrest;
-}
-
-bool
-rb_get_iseq_flags_has_rest(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_rest;
-}
-
-bool
-rb_get_iseq_flags_ruby2_keywords(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.ruby2_keywords;
-}
-
-bool
-rb_get_iseq_flags_has_block(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.has_block;
-}
-
-bool
-rb_get_iseq_flags_ambiguous_param0(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.ambiguous_param0;
-}
-
-bool
-rb_get_iseq_flags_accepts_no_kwarg(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.accepts_no_kwarg;
-}
-
-bool
-rb_get_iseq_flags_forwardable(const rb_iseq_t *iseq)
-{
- return iseq->body->param.flags.forwardable;
-}
-
-// This is defined only as a named struct inside rb_iseq_constant_body.
-// By giving it a separate typedef, we make it nameable by rust-bindgen.
-// Bindgen's temp/anon name isn't guaranteed stable.
-typedef struct rb_iseq_param_keyword rb_iseq_param_keyword_struct;
-
-const rb_iseq_param_keyword_struct *
-rb_get_iseq_body_param_keyword(const rb_iseq_t *iseq)
-{
- return iseq->body->param.keyword;
-}
-
-unsigned
-rb_get_iseq_body_param_size(const rb_iseq_t *iseq)
-{
- return iseq->body->param.size;
-}
-
-int
-rb_get_iseq_body_param_lead_num(const rb_iseq_t *iseq)
-{
- return iseq->body->param.lead_num;
-}
-
-int
-rb_get_iseq_body_param_opt_num(const rb_iseq_t *iseq)
-{
- return iseq->body->param.opt_num;
-}
-
-const VALUE *
-rb_get_iseq_body_param_opt_table(const rb_iseq_t *iseq)
-{
- return iseq->body->param.opt_table;
-}
-
-unsigned int
-rb_get_iseq_body_local_table_size(const rb_iseq_t *iseq)
-{
- return iseq->body->local_table_size;
-}
-
-int
-rb_get_cikw_keyword_len(const struct rb_callinfo_kwarg *cikw)
-{
- return cikw->keyword_len;
-}
-
-VALUE
-rb_get_cikw_keywords_idx(const struct rb_callinfo_kwarg *cikw, int idx)
-{
- return cikw->keywords[idx];
-}
-
-const struct rb_callinfo *
-rb_get_call_data_ci(const struct rb_call_data *cd)
-{
- return cd->ci;
-}
-
-// The FL_TEST() macro
-VALUE
-rb_FL_TEST(VALUE obj, VALUE flags)
-{
- return RB_FL_TEST(obj, flags);
-}
-
-// The FL_TEST_RAW() macro, normally an internal implementation detail
-VALUE
-rb_FL_TEST_RAW(VALUE obj, VALUE flags)
-{
- return FL_TEST_RAW(obj, flags);
-}
-
-// The RB_TYPE_P macro
-bool
-rb_RB_TYPE_P(VALUE obj, enum ruby_value_type t)
-{
- return RB_TYPE_P(obj, t);
-}
-
-long
-rb_RSTRUCT_LEN(VALUE st)
-{
- return RSTRUCT_LEN(st);
-}
-
-bool
-rb_BASIC_OP_UNREDEFINED_P(enum ruby_basic_operators bop, uint32_t klass)
-{
- return BASIC_OP_UNREDEFINED_P(bop, klass);
-}
-
bool
rb_zjit_multi_ractor_p(void)
{
return rb_multi_ractor_p();
}
-// For debug builds
-void
-rb_assert_iseq_handle(VALUE handle)
-{
- RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(handle, imemo_iseq));
-}
-
bool
rb_zjit_constcache_shareable(const struct iseq_inline_constant_cache_entry *ice)
{
return (ice->flags & IMEMO_CONST_CACHE_SHAREABLE) != 0;
}
-void
-rb_assert_cme_handle(VALUE handle)
-{
- RUBY_ASSERT_ALWAYS(!rb_objspace_garbage_object_p(handle));
- RUBY_ASSERT_ALWAYS(IMEMO_TYPE_P(handle, imemo_ment));
-}
-
-int
-rb_IMEMO_TYPE_P(VALUE imemo, enum imemo_type imemo_type)
-{
- return IMEMO_TYPE_P(imemo, imemo_type);
-}
-
// Release the VM lock. The lock level must point to the same integer used to
// acquire the lock.
void
@@ -614,42 +248,6 @@ rb_zjit_icache_invalidate(void *start, void *end)
#endif
}
-unsigned int
-rb_vm_ci_argc(const struct rb_callinfo *ci)
-{
- return vm_ci_argc(ci);
-}
-
-ID
-rb_vm_ci_mid(const struct rb_callinfo *ci)
-{
- return vm_ci_mid(ci);
-}
-
-unsigned int
-rb_vm_ci_flag(const struct rb_callinfo *ci)
-{
- return vm_ci_flag(ci);
-}
-
-const struct rb_callinfo_kwarg *
-rb_vm_ci_kwarg(const struct rb_callinfo *ci)
-{
- return vm_ci_kwarg(ci);
-}
-
-rb_method_visibility_t
-rb_METHOD_ENTRY_VISI(const rb_callable_method_entry_t *me)
-{
- return METHOD_ENTRY_VISI(me);
-}
-
-VALUE
-rb_yarv_class_of(VALUE obj)
-{
- return rb_class_of(obj);
-}
-
// Acquire the VM lock and then signal all other Ruby threads (ractors) to
// contend for the VM lock, putting them to sleep. ZJIT uses this to evict
// threads running inside generated code so among other things, it can
@@ -661,12 +259,6 @@ rb_zjit_vm_lock_then_barrier(unsigned int *recursive_lock_level, const char *fil
rb_vm_barrier();
}
-VALUE
-rb_RCLASS_ORIGIN(VALUE c)
-{
- return RCLASS_ORIGIN(c);
-}
-
// Convert a given ISEQ's instructions to zjit_* instructions
void
rb_zjit_profile_enable(const rb_iseq_t *iseq)
@@ -51,6 +51,7 @@ fn main() {
// Our C file for glue code
.header(src_root.join(c_file).to_str().unwrap())
// Don't want to copy over C comment
.generate_comments(false)
@@ -929,21 +929,46 @@ unsafe extern "C" {
pub fn rb_jit_cont_each_iseq(callback: rb_iseq_callback, data: *mut ::std::os::raw::c_void);
pub fn rb_zjit_get_page_size() -> u32;
pub fn rb_zjit_reserve_addr_space(mem_size: u32) -> *mut u8;
- pub fn rb_RSTRING_LEN(str_: VALUE) -> ::std::os::raw::c_ulong;
- pub fn rb_RSTRING_PTR(str_: VALUE) -> *mut ::std::os::raw::c_char;
pub fn rb_zjit_profile_disable(iseq: *const rb_iseq_t);
pub fn rb_iseq_encoded_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
- pub fn rb_iseq_opcode_at_pc(iseq: *const rb_iseq_t, pc: *const VALUE) -> ::std::os::raw::c_int;
pub fn rb_iseq_pc_at_idx(iseq: *const rb_iseq_t, insn_idx: u32) -> *mut VALUE;
pub fn rb_insn_name(insn: VALUE) -> *const ::std::os::raw::c_char;
- pub fn rb_get_ec_cfp(ec: *const rb_execution_context_t) -> *mut rb_control_frame_struct;
- pub fn rb_get_cfp_iseq(cfp: *mut rb_control_frame_struct) -> *const rb_iseq_t;
- pub fn rb_get_cfp_pc(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
- pub fn rb_get_cfp_sp(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
- pub fn rb_get_cfp_self(cfp: *mut rb_control_frame_struct) -> VALUE;
- pub fn rb_get_cfp_ep(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
- pub fn rb_get_cfp_ep_level(cfp: *mut rb_control_frame_struct, lv: u32) -> *const VALUE;
- pub fn rb_vm_base_ptr(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
pub fn rb_get_cme_def_type(cme: *const rb_callable_method_entry_t) -> rb_method_type_t;
pub fn rb_get_cme_def_body_attr_id(cme: *const rb_callable_method_entry_t) -> ID;
pub fn rb_get_cme_def_body_optimized_type(
@@ -961,6 +986,7 @@ unsafe extern "C" {
pub fn rb_get_mct_func(mct: *const rb_method_cfunc_t) -> *mut ::std::os::raw::c_void;
pub fn rb_get_def_iseq_ptr(def: *mut rb_method_definition_t) -> *const rb_iseq_t;
pub fn rb_get_iseq_body_local_iseq(iseq: *const rb_iseq_t) -> *const rb_iseq_t;
pub fn rb_get_iseq_body_iseq_encoded(iseq: *const rb_iseq_t) -> *mut VALUE;
pub fn rb_get_iseq_body_stack_max(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
pub fn rb_get_iseq_body_type(iseq: *const rb_iseq_t) -> rb_iseq_type;
@@ -983,48 +1009,22 @@ unsafe extern "C" {
pub fn rb_get_iseq_body_param_lead_num(iseq: *const rb_iseq_t) -> ::std::os::raw::c_int;
pub fn rb_get_iseq_body_param_opt_num(iseq: *const rb_iseq_t) -> ::std::os::raw::c_int;
pub fn rb_get_iseq_body_param_opt_table(iseq: *const rb_iseq_t) -> *const VALUE;
- pub fn rb_get_iseq_body_local_table_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
- pub fn rb_get_cikw_keyword_len(cikw: *const rb_callinfo_kwarg) -> ::std::os::raw::c_int;
- pub fn rb_get_cikw_keywords_idx(
- cikw: *const rb_callinfo_kwarg,
- idx: ::std::os::raw::c_int,
- ) -> VALUE;
- pub fn rb_get_call_data_ci(cd: *const rb_call_data) -> *const rb_callinfo;
pub fn rb_FL_TEST(obj: VALUE, flags: VALUE) -> VALUE;
pub fn rb_FL_TEST_RAW(obj: VALUE, flags: VALUE) -> VALUE;
pub fn rb_RB_TYPE_P(obj: VALUE, t: ruby_value_type) -> bool;
pub fn rb_RSTRUCT_LEN(st: VALUE) -> ::std::os::raw::c_long;
pub fn rb_BASIC_OP_UNREDEFINED_P(bop: ruby_basic_operators, klass: u32) -> bool;
- pub fn rb_zjit_multi_ractor_p() -> bool;
pub fn rb_assert_iseq_handle(handle: VALUE);
- pub fn rb_zjit_constcache_shareable(ice: *const iseq_inline_constant_cache_entry) -> bool;
- pub fn rb_assert_cme_handle(handle: VALUE);
pub fn rb_IMEMO_TYPE_P(imemo: VALUE, imemo_type: imemo_type) -> ::std::os::raw::c_int;
- pub fn rb_zjit_vm_unlock(
- recursive_lock_level: *mut ::std::os::raw::c_uint,
- file: *const ::std::os::raw::c_char,
- line: ::std::os::raw::c_int,
- );
- pub fn rb_zjit_mark_writable(mem_block: *mut ::std::os::raw::c_void, mem_size: u32) -> bool;
- pub fn rb_zjit_mark_executable(mem_block: *mut ::std::os::raw::c_void, mem_size: u32);
- pub fn rb_zjit_mark_unused(mem_block: *mut ::std::os::raw::c_void, mem_size: u32) -> bool;
- pub fn rb_zjit_icache_invalidate(
- start: *mut ::std::os::raw::c_void,
- end: *mut ::std::os::raw::c_void,
- );
- pub fn rb_vm_ci_argc(ci: *const rb_callinfo) -> ::std::os::raw::c_uint;
- pub fn rb_vm_ci_mid(ci: *const rb_callinfo) -> ID;
- pub fn rb_vm_ci_flag(ci: *const rb_callinfo) -> ::std::os::raw::c_uint;
- pub fn rb_vm_ci_kwarg(ci: *const rb_callinfo) -> *const rb_callinfo_kwarg;
- pub fn rb_METHOD_ENTRY_VISI(me: *const rb_callable_method_entry_t) -> rb_method_visibility_t;
- pub fn rb_yarv_class_of(obj: VALUE) -> VALUE;
- pub fn rb_zjit_vm_lock_then_barrier(
- recursive_lock_level: *mut ::std::os::raw::c_uint,
- file: *const ::std::os::raw::c_char,
- line: ::std::os::raw::c_int,
- );
- pub fn rb_RCLASS_ORIGIN(c: VALUE) -> VALUE;
- pub fn rb_iseq_get_zjit_payload(iseq: *const rb_iseq_t) -> *mut ::std::os::raw::c_void;
- pub fn rb_iseq_set_zjit_payload(iseq: *const rb_iseq_t, payload: *mut ::std::os::raw::c_void);
- pub fn rb_zjit_print_exception();
}