зеркало из https://github.com/github/ruby.git
Use bindgen for old manual extern declarations (https://github.com/Shopify/ruby/pull/404)
We have a large extern block in cruby.rs leftover from the port. We can use bindgen for it now and reserve the manual declaration for just a handful of vm_insnhelper.c functions. Fixup a few minor discrepencies bindgen found between the C declaration and the manual declaration. Mostly missing `const` on the C side.
This commit is contained in:
Родитель
ff3f1d15d2
Коммит
2f9df46654
60
yjit.c
60
yjit.c
|
@ -472,61 +472,61 @@ rb_get_cikw_keywords_idx(const struct rb_callinfo_kwarg *cikw, int idx)
|
|||
}
|
||||
|
||||
rb_method_visibility_t
|
||||
rb_METHOD_ENTRY_VISI(rb_callable_method_entry_t *me)
|
||||
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(rb_callable_method_entry_t *cme)
|
||||
rb_get_cme_def_type(const rb_callable_method_entry_t *cme)
|
||||
{
|
||||
return cme->def->type;
|
||||
}
|
||||
|
||||
ID
|
||||
rb_get_cme_def_body_attr_id(rb_callable_method_entry_t *cme)
|
||||
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(rb_callable_method_entry_t *cme)
|
||||
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(rb_callable_method_entry_t *cme)
|
||||
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(rb_callable_method_entry_t *cme)
|
||||
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(rb_method_definition_t *def)
|
||||
rb_get_def_method_serial(const rb_method_definition_t *def)
|
||||
{
|
||||
return def->method_serial;
|
||||
}
|
||||
|
||||
ID
|
||||
rb_get_def_original_id(rb_method_definition_t *def)
|
||||
rb_get_def_original_id(const rb_method_definition_t *def)
|
||||
{
|
||||
return def->original_id;
|
||||
}
|
||||
|
||||
int
|
||||
rb_get_mct_argc(rb_method_cfunc_t *mct)
|
||||
rb_get_mct_argc(const rb_method_cfunc_t *mct)
|
||||
{
|
||||
return mct->argc;
|
||||
}
|
||||
|
||||
void *
|
||||
rb_get_mct_func(rb_method_cfunc_t *mct)
|
||||
rb_get_mct_func(const rb_method_cfunc_t *mct)
|
||||
{
|
||||
return (void*)mct->func; // this field is defined as type VALUE (*func)(ANYARGS)
|
||||
}
|
||||
|
@ -537,104 +537,104 @@ rb_get_def_iseq_ptr(rb_method_definition_t *def)
|
|||
return def_iseq_ptr(def);
|
||||
}
|
||||
|
||||
rb_iseq_t *
|
||||
rb_get_iseq_body_local_iseq(rb_iseq_t *iseq)
|
||||
const rb_iseq_t *
|
||||
rb_get_iseq_body_local_iseq(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->local_iseq;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
rb_get_iseq_body_local_table_size(rb_iseq_t *iseq)
|
||||
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(rb_iseq_t *iseq)
|
||||
rb_get_iseq_body_iseq_encoded(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->iseq_encoded;
|
||||
}
|
||||
|
||||
bool
|
||||
rb_get_iseq_body_builtin_inline_p(rb_iseq_t *iseq)
|
||||
rb_get_iseq_body_builtin_inline_p(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->builtin_inline_p;
|
||||
}
|
||||
|
||||
unsigned
|
||||
rb_get_iseq_body_stack_max(rb_iseq_t *iseq)
|
||||
rb_get_iseq_body_stack_max(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->stack_max;
|
||||
}
|
||||
|
||||
bool
|
||||
rb_get_iseq_flags_has_opt(rb_iseq_t *iseq)
|
||||
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(rb_iseq_t *iseq)
|
||||
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(rb_iseq_t *iseq)
|
||||
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(rb_iseq_t *iseq)
|
||||
rb_get_iseq_flags_has_kwrest(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->param.flags.has_kwrest;
|
||||
}
|
||||
|
||||
bool
|
||||
rb_get_iseq_flags_has_rest(rb_iseq_t *iseq)
|
||||
rb_get_iseq_flags_has_rest(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->param.flags.has_rest;
|
||||
}
|
||||
|
||||
bool
|
||||
rb_get_iseq_flags_has_block(rb_iseq_t *iseq)
|
||||
rb_get_iseq_flags_has_block(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->param.flags.has_block;
|
||||
}
|
||||
|
||||
bool
|
||||
rb_get_iseq_flags_has_accepts_no_kwarg(rb_iseq_t *iseq)
|
||||
rb_get_iseq_flags_has_accepts_no_kwarg(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->param.flags.accepts_no_kwarg;
|
||||
}
|
||||
|
||||
const rb_seq_param_keyword_struct *
|
||||
rb_get_iseq_body_param_keyword(rb_iseq_t *iseq)
|
||||
rb_get_iseq_body_param_keyword(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->param.keyword;
|
||||
}
|
||||
|
||||
unsigned
|
||||
rb_get_iseq_body_param_size(rb_iseq_t *iseq)
|
||||
rb_get_iseq_body_param_size(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->param.size;
|
||||
}
|
||||
|
||||
int
|
||||
rb_get_iseq_body_param_lead_num(rb_iseq_t *iseq)
|
||||
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(rb_iseq_t *iseq)
|
||||
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(rb_iseq_t *iseq)
|
||||
rb_get_iseq_body_param_opt_table(const rb_iseq_t *iseq)
|
||||
{
|
||||
return iseq->body->param.opt_table;
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ rb_yjit_str_simple_append(VALUE str1, VALUE str2)
|
|||
}
|
||||
|
||||
struct rb_control_frame_struct *
|
||||
rb_get_ec_cfp(rb_execution_context_t *ec)
|
||||
rb_get_ec_cfp(const rb_execution_context_t *ec)
|
||||
{
|
||||
return ec->cfp;
|
||||
}
|
||||
|
@ -803,7 +803,7 @@ rb_RSTRUCT_SET(VALUE st, int k, VALUE v)
|
|||
}
|
||||
|
||||
const struct rb_callinfo *
|
||||
rb_get_call_data_ci(struct rb_call_data *cd)
|
||||
rb_get_call_data_ci(const struct rb_call_data *cd)
|
||||
{
|
||||
return cd->ci;
|
||||
}
|
||||
|
|
|
@ -311,6 +311,62 @@ fn main() {
|
|||
// From include/ruby/debug.h
|
||||
.allowlist_function("rb_profile_frames")
|
||||
|
||||
// Functions used for code generation
|
||||
.allowlist_function("rb_insn_name")
|
||||
.allowlist_function("rb_insn_len")
|
||||
.allowlist_function("rb_yarv_class_of")
|
||||
.allowlist_function("rb_get_ec_cfp")
|
||||
.allowlist_function("rb_get_cfp_pc")
|
||||
.allowlist_function("rb_get_cfp_sp")
|
||||
.allowlist_function("rb_get_cfp_self")
|
||||
.allowlist_function("rb_get_cfp_ep")
|
||||
.allowlist_function("rb_get_cfp_ep_level")
|
||||
.allowlist_function("rb_get_cme_def_type")
|
||||
.allowlist_function("rb_get_cme_def_body_attr_id")
|
||||
.allowlist_function("rb_get_cme_def_body_optimized_type")
|
||||
.allowlist_function("rb_get_cme_def_body_optimized_index")
|
||||
.allowlist_function("rb_get_cme_def_body_cfunc")
|
||||
.allowlist_function("rb_get_def_method_serial")
|
||||
.allowlist_function("rb_get_def_original_id")
|
||||
.allowlist_function("rb_get_mct_argc")
|
||||
.allowlist_function("rb_get_mct_func")
|
||||
.allowlist_function("rb_get_def_iseq_ptr")
|
||||
.allowlist_function("rb_iseq_encoded_size")
|
||||
.allowlist_function("rb_get_iseq_body_local_iseq")
|
||||
.allowlist_function("rb_get_iseq_body_iseq_encoded")
|
||||
.allowlist_function("rb_get_iseq_body_stack_max")
|
||||
.allowlist_function("rb_get_iseq_flags_has_opt")
|
||||
.allowlist_function("rb_get_iseq_flags_has_kw")
|
||||
.allowlist_function("rb_get_iseq_flags_has_rest")
|
||||
.allowlist_function("rb_get_iseq_flags_has_post")
|
||||
.allowlist_function("rb_get_iseq_flags_has_kwrest")
|
||||
.allowlist_function("rb_get_iseq_flags_has_block")
|
||||
.allowlist_function("rb_get_iseq_flags_has_accepts_no_kwarg")
|
||||
.allowlist_function("rb_get_iseq_body_local_table_size")
|
||||
.allowlist_function("rb_get_iseq_body_param_keyword")
|
||||
.allowlist_function("rb_get_iseq_body_param_size")
|
||||
.allowlist_function("rb_get_iseq_body_param_lead_num")
|
||||
.allowlist_function("rb_get_iseq_body_param_opt_num")
|
||||
.allowlist_function("rb_get_iseq_body_param_opt_table")
|
||||
.allowlist_function("rb_get_cikw_keyword_len")
|
||||
.allowlist_function("rb_get_cikw_keywords_idx")
|
||||
.allowlist_function("rb_get_call_data_ci")
|
||||
.allowlist_function("rb_yarv_str_eql_internal")
|
||||
.allowlist_function("rb_yarv_ary_entry_internal")
|
||||
.allowlist_function("rb_yarv_fix_mod_fix")
|
||||
.allowlist_function("rb_FL_TEST")
|
||||
.allowlist_function("rb_FL_TEST_RAW")
|
||||
.allowlist_function("rb_RB_TYPE_P")
|
||||
.allowlist_function("rb_BASIC_OP_UNREDEFINED_P")
|
||||
.allowlist_function("rb_RSTRUCT_LEN")
|
||||
.allowlist_function("rb_RSTRUCT_SET")
|
||||
.allowlist_function("rb_vm_ci_argc")
|
||||
.allowlist_function("rb_vm_ci_mid")
|
||||
.allowlist_function("rb_vm_ci_flag")
|
||||
.allowlist_function("rb_vm_ci_kwarg")
|
||||
.allowlist_function("rb_METHOD_ENTRY_VISI")
|
||||
.allowlist_function("rb_RCLASS_ORIGIN")
|
||||
|
||||
// We define VALUE manually, don't import it
|
||||
.blocklist_type("VALUE")
|
||||
|
||||
|
|
|
@ -4058,7 +4058,7 @@ fn gen_send_cfunc(
|
|||
// cfunc comes from compile-time cme->def, which we assume to be stable.
|
||||
// Invalidation logic is in yjit_method_lookup_change()
|
||||
asm.comment("call C function");
|
||||
let ret = asm.ccall(unsafe { get_mct_func(cfunc) }, args);
|
||||
let ret = asm.ccall(unsafe { get_mct_func(cfunc) }.cast(), args);
|
||||
|
||||
// Record code position for TracePoint patching. See full_cfunc_return().
|
||||
record_global_inval_patch(asm, CodegenGlobals::get_outline_full_cfunc_return_pos());
|
||||
|
@ -4724,7 +4724,7 @@ fn gen_send_general(
|
|||
// see vm_call_method().
|
||||
|
||||
let ci = unsafe { get_call_data_ci(cd) }; // info about the call site
|
||||
let argc = unsafe { vm_ci_argc(ci) };
|
||||
let argc: i32 = unsafe { vm_ci_argc(ci) }.try_into().unwrap();
|
||||
let mid = unsafe { vm_ci_mid(ci) };
|
||||
let flags = unsafe { vm_ci_flag(ci) };
|
||||
|
||||
|
@ -5028,7 +5028,7 @@ fn gen_invokesuper(
|
|||
unsafe { rb_class_get_superclass(RCLASS_ORIGIN(current_defined_class)) };
|
||||
|
||||
let ci = unsafe { get_call_data_ci(cd) };
|
||||
let argc = unsafe { vm_ci_argc(ci) };
|
||||
let argc: i32 = unsafe { vm_ci_argc(ci) }.try_into().unwrap();
|
||||
|
||||
let ci_flags = unsafe { vm_ci_flag(ci) };
|
||||
|
||||
|
@ -5960,7 +5960,7 @@ pub struct CodegenGlobals {
|
|||
inline_frozen_bytes: usize,
|
||||
|
||||
// Methods for generating code for hardcoded (usually C) methods
|
||||
method_codegen_table: HashMap<u64, MethodGenFn>,
|
||||
method_codegen_table: HashMap<usize, MethodGenFn>,
|
||||
}
|
||||
|
||||
/// For implementing global code invalidation. A position in the inline
|
||||
|
@ -6179,7 +6179,7 @@ impl CodegenGlobals {
|
|||
CodegenGlobals::get_instance().outline_full_cfunc_return_pos
|
||||
}
|
||||
|
||||
pub fn look_up_codegen_method(method_serial: u64) -> Option<MethodGenFn> {
|
||||
pub fn look_up_codegen_method(method_serial: usize) -> Option<MethodGenFn> {
|
||||
let table = &CodegenGlobals::get_instance().method_codegen_table;
|
||||
|
||||
let option_ref = table.get(&method_serial);
|
||||
|
|
|
@ -106,161 +106,11 @@ pub use autogened::*;
|
|||
// TODO: For #defines that affect memory layout, we need to check for them
|
||||
// on build and fail if they're wrong. e.g. USE_FLONUM *must* be true.
|
||||
|
||||
// TODO:
|
||||
// Temporary, these external bindings will likely be auto-generated
|
||||
// and textually included in this file
|
||||
// These are functions we expose from vm_insnhelper.c, not in any header.
|
||||
// Parsing it would result in a lot of duplicate definitions.
|
||||
// Use bindgen for functions that are defined in headers or in yjit.c.
|
||||
#[cfg_attr(test, allow(unused))] // We don't link against C code when testing
|
||||
extern "C" {
|
||||
#[link_name = "rb_insn_name"]
|
||||
pub fn raw_insn_name(insn: VALUE) -> *const c_char;
|
||||
|
||||
#[link_name = "rb_insn_len"]
|
||||
pub fn raw_insn_len(v: VALUE) -> c_int;
|
||||
|
||||
#[link_name = "rb_yarv_class_of"]
|
||||
pub fn CLASS_OF(v: VALUE) -> VALUE;
|
||||
|
||||
#[link_name = "rb_get_ec_cfp"]
|
||||
pub fn get_ec_cfp(ec: EcPtr) -> CfpPtr;
|
||||
|
||||
#[link_name = "rb_get_cfp_pc"]
|
||||
pub fn get_cfp_pc(cfp: CfpPtr) -> *mut VALUE;
|
||||
|
||||
#[link_name = "rb_get_cfp_sp"]
|
||||
pub fn get_cfp_sp(cfp: CfpPtr) -> *mut VALUE;
|
||||
|
||||
#[link_name = "rb_get_cfp_self"]
|
||||
pub fn get_cfp_self(cfp: CfpPtr) -> VALUE;
|
||||
|
||||
#[link_name = "rb_get_cfp_ep"]
|
||||
pub fn get_cfp_ep(cfp: CfpPtr) -> *mut VALUE;
|
||||
|
||||
#[link_name = "rb_get_cfp_ep_level"]
|
||||
pub fn get_cfp_ep_level(cfp: CfpPtr, lv: u32) -> *const VALUE;
|
||||
|
||||
#[link_name = "rb_get_cme_def_type"]
|
||||
pub fn get_cme_def_type(cme: *const rb_callable_method_entry_t) -> rb_method_type_t;
|
||||
|
||||
#[link_name = "rb_get_cme_def_body_attr_id"]
|
||||
pub fn get_cme_def_body_attr_id(cme: *const rb_callable_method_entry_t) -> ID;
|
||||
|
||||
#[link_name = "rb_get_cme_def_body_optimized_type"]
|
||||
pub fn get_cme_def_body_optimized_type(
|
||||
cme: *const rb_callable_method_entry_t,
|
||||
) -> method_optimized_type;
|
||||
|
||||
#[link_name = "rb_get_cme_def_body_optimized_index"]
|
||||
pub fn get_cme_def_body_optimized_index(cme: *const rb_callable_method_entry_t) -> c_uint;
|
||||
|
||||
#[link_name = "rb_get_cme_def_body_cfunc"]
|
||||
pub fn get_cme_def_body_cfunc(cme: *const rb_callable_method_entry_t)
|
||||
-> *mut rb_method_cfunc_t;
|
||||
|
||||
#[link_name = "rb_get_def_method_serial"]
|
||||
/// While this returns a uintptr_t in C, we always use it as a Rust u64
|
||||
pub fn get_def_method_serial(def: *const rb_method_definition_t) -> u64;
|
||||
|
||||
#[link_name = "rb_get_def_original_id"]
|
||||
pub fn get_def_original_id(def: *const rb_method_definition_t) -> ID;
|
||||
|
||||
#[link_name = "rb_get_mct_argc"]
|
||||
pub fn get_mct_argc(mct: *const rb_method_cfunc_t) -> c_int;
|
||||
|
||||
#[link_name = "rb_get_mct_func"]
|
||||
pub fn get_mct_func(mct: *const rb_method_cfunc_t) -> *const u8;
|
||||
|
||||
#[link_name = "rb_get_def_iseq_ptr"]
|
||||
pub fn get_def_iseq_ptr(def: *const rb_method_definition_t) -> IseqPtr;
|
||||
|
||||
#[link_name = "rb_iseq_encoded_size"]
|
||||
pub fn get_iseq_encoded_size(iseq: IseqPtr) -> c_uint;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_local_iseq"]
|
||||
pub fn get_iseq_body_local_iseq(iseq: IseqPtr) -> IseqPtr;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_iseq_encoded"]
|
||||
pub fn get_iseq_body_iseq_encoded(iseq: IseqPtr) -> *mut VALUE;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_stack_max"]
|
||||
pub fn get_iseq_body_stack_max(iseq: IseqPtr) -> c_uint;
|
||||
|
||||
#[link_name = "rb_get_iseq_flags_has_opt"]
|
||||
pub fn get_iseq_flags_has_opt(iseq: IseqPtr) -> bool;
|
||||
|
||||
#[link_name = "rb_get_iseq_flags_has_kw"]
|
||||
pub fn get_iseq_flags_has_kw(iseq: IseqPtr) -> bool;
|
||||
|
||||
#[link_name = "rb_get_iseq_flags_has_rest"]
|
||||
pub fn get_iseq_flags_has_rest(iseq: IseqPtr) -> bool;
|
||||
|
||||
#[link_name = "rb_get_iseq_flags_has_post"]
|
||||
pub fn get_iseq_flags_has_post(iseq: IseqPtr) -> bool;
|
||||
|
||||
#[link_name = "rb_get_iseq_flags_has_kwrest"]
|
||||
pub fn get_iseq_flags_has_kwrest(iseq: IseqPtr) -> bool;
|
||||
|
||||
#[link_name = "rb_get_iseq_flags_has_block"]
|
||||
pub fn get_iseq_flags_has_block(iseq: IseqPtr) -> bool;
|
||||
|
||||
#[link_name = "rb_get_iseq_flags_has_accepts_no_kwarg"]
|
||||
pub fn get_iseq_flags_has_accepts_no_kwarg(iseq: IseqPtr) -> bool;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_local_table_size"]
|
||||
pub fn get_iseq_body_local_table_size(iseq: IseqPtr) -> c_uint;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_param_keyword"]
|
||||
pub fn get_iseq_body_param_keyword(iseq: IseqPtr) -> *const rb_seq_param_keyword_struct;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_param_size"]
|
||||
pub fn get_iseq_body_param_size(iseq: IseqPtr) -> c_uint;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_param_lead_num"]
|
||||
pub fn get_iseq_body_param_lead_num(iseq: IseqPtr) -> c_int;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_param_opt_num"]
|
||||
pub fn get_iseq_body_param_opt_num(iseq: IseqPtr) -> c_int;
|
||||
|
||||
#[link_name = "rb_get_iseq_body_param_opt_table"]
|
||||
pub fn get_iseq_body_param_opt_table(iseq: IseqPtr) -> *const VALUE;
|
||||
|
||||
#[link_name = "rb_get_cikw_keyword_len"]
|
||||
pub fn get_cikw_keyword_len(cikw: *const rb_callinfo_kwarg) -> c_int;
|
||||
|
||||
#[link_name = "rb_get_cikw_keywords_idx"]
|
||||
pub fn get_cikw_keywords_idx(cikw: *const rb_callinfo_kwarg, idx: c_int) -> VALUE;
|
||||
|
||||
#[link_name = "rb_get_call_data_ci"]
|
||||
pub fn get_call_data_ci(cd: *const rb_call_data) -> *const rb_callinfo;
|
||||
|
||||
#[link_name = "rb_yarv_str_eql_internal"]
|
||||
pub fn rb_str_eql_internal(str1: VALUE, str2: VALUE) -> VALUE;
|
||||
|
||||
#[link_name = "rb_yarv_ary_entry_internal"]
|
||||
pub fn rb_ary_entry_internal(ary: VALUE, offset: c_long) -> VALUE;
|
||||
|
||||
#[link_name = "rb_yarv_fix_mod_fix"]
|
||||
pub fn rb_fix_mod_fix(recv: VALUE, obj: VALUE) -> VALUE;
|
||||
|
||||
#[link_name = "rb_FL_TEST"]
|
||||
pub fn FL_TEST(obj: VALUE, flags: VALUE) -> VALUE;
|
||||
|
||||
#[link_name = "rb_FL_TEST_RAW"]
|
||||
pub fn FL_TEST_RAW(obj: VALUE, flags: VALUE) -> VALUE;
|
||||
|
||||
#[link_name = "rb_RB_TYPE_P"]
|
||||
pub fn RB_TYPE_P(obj: VALUE, t: ruby_value_type) -> bool;
|
||||
|
||||
#[link_name = "rb_BASIC_OP_UNREDEFINED_P"]
|
||||
pub fn BASIC_OP_UNREDEFINED_P(bop: ruby_basic_operators, klass: RedefinitionFlag) -> bool;
|
||||
|
||||
#[link_name = "rb_RSTRUCT_LEN"]
|
||||
pub fn RSTRUCT_LEN(st: VALUE) -> c_long;
|
||||
|
||||
#[link_name = "rb_RSTRUCT_SET"]
|
||||
pub fn RSTRUCT_SET(st: VALUE, k: c_int, v: VALUE);
|
||||
|
||||
// Ruby only defines these in vm_insnhelper.c, not in any header.
|
||||
// Parsing it would result in a lot of duplicate definitions.
|
||||
pub fn rb_vm_splat_array(flag: VALUE, ary: VALUE) -> VALUE;
|
||||
pub fn rb_vm_defined(
|
||||
ec: EcPtr,
|
||||
|
@ -283,28 +133,65 @@ extern "C" {
|
|||
ic: ICVARC,
|
||||
) -> VALUE;
|
||||
pub fn rb_vm_ic_hit_p(ic: IC, reg_ep: *const VALUE) -> bool;
|
||||
|
||||
#[link_name = "rb_vm_ci_argc"]
|
||||
pub fn vm_ci_argc(ci: *const rb_callinfo) -> c_int;
|
||||
|
||||
#[link_name = "rb_vm_ci_mid"]
|
||||
pub fn vm_ci_mid(ci: *const rb_callinfo) -> ID;
|
||||
|
||||
#[link_name = "rb_vm_ci_flag"]
|
||||
pub fn vm_ci_flag(ci: *const rb_callinfo) -> c_uint;
|
||||
|
||||
#[link_name = "rb_vm_ci_kwarg"]
|
||||
pub fn vm_ci_kwarg(ci: *const rb_callinfo) -> *const rb_callinfo_kwarg;
|
||||
|
||||
#[link_name = "rb_METHOD_ENTRY_VISI"]
|
||||
pub fn METHOD_ENTRY_VISI(me: *const rb_callable_method_entry_t) -> rb_method_visibility_t;
|
||||
|
||||
pub fn rb_str_bytesize(str: VALUE) -> VALUE;
|
||||
|
||||
#[link_name = "rb_RCLASS_ORIGIN"]
|
||||
pub fn RCLASS_ORIGIN(v: VALUE) -> VALUE;
|
||||
}
|
||||
|
||||
// Renames
|
||||
pub use rb_insn_name as raw_insn_name;
|
||||
pub use rb_insn_len as raw_insn_len;
|
||||
pub use rb_yarv_class_of as CLASS_OF;
|
||||
pub use rb_get_ec_cfp as get_ec_cfp;
|
||||
pub use rb_get_cfp_pc as get_cfp_pc;
|
||||
pub use rb_get_cfp_sp as get_cfp_sp;
|
||||
pub use rb_get_cfp_self as get_cfp_self;
|
||||
pub use rb_get_cfp_ep as get_cfp_ep;
|
||||
pub use rb_get_cfp_ep_level as get_cfp_ep_level;
|
||||
pub use rb_get_cme_def_type as get_cme_def_type;
|
||||
pub use rb_get_cme_def_body_attr_id as get_cme_def_body_attr_id;
|
||||
pub use rb_get_cme_def_body_optimized_type as get_cme_def_body_optimized_type;
|
||||
pub use rb_get_cme_def_body_optimized_index as get_cme_def_body_optimized_index;
|
||||
pub use rb_get_cme_def_body_cfunc as get_cme_def_body_cfunc;
|
||||
pub use rb_get_def_method_serial as get_def_method_serial;
|
||||
pub use rb_get_def_original_id as get_def_original_id;
|
||||
pub use rb_get_mct_argc as get_mct_argc;
|
||||
pub use rb_get_mct_func as get_mct_func;
|
||||
pub use rb_get_def_iseq_ptr as get_def_iseq_ptr;
|
||||
pub use rb_iseq_encoded_size as get_iseq_encoded_size;
|
||||
pub use rb_get_iseq_body_local_iseq as get_iseq_body_local_iseq;
|
||||
pub use rb_get_iseq_body_iseq_encoded as get_iseq_body_iseq_encoded;
|
||||
pub use rb_get_iseq_body_stack_max as get_iseq_body_stack_max;
|
||||
pub use rb_get_iseq_flags_has_opt as get_iseq_flags_has_opt;
|
||||
pub use rb_get_iseq_flags_has_kw as get_iseq_flags_has_kw;
|
||||
pub use rb_get_iseq_flags_has_rest as get_iseq_flags_has_rest;
|
||||
pub use rb_get_iseq_flags_has_post as get_iseq_flags_has_post;
|
||||
pub use rb_get_iseq_flags_has_kwrest as get_iseq_flags_has_kwrest;
|
||||
pub use rb_get_iseq_flags_has_block as get_iseq_flags_has_block;
|
||||
pub use rb_get_iseq_flags_has_accepts_no_kwarg as get_iseq_flags_has_accepts_no_kwarg;
|
||||
pub use rb_get_iseq_body_local_table_size as get_iseq_body_local_table_size;
|
||||
pub use rb_get_iseq_body_param_keyword as get_iseq_body_param_keyword;
|
||||
pub use rb_get_iseq_body_param_size as get_iseq_body_param_size;
|
||||
pub use rb_get_iseq_body_param_lead_num as get_iseq_body_param_lead_num;
|
||||
pub use rb_get_iseq_body_param_opt_num as get_iseq_body_param_opt_num;
|
||||
pub use rb_get_iseq_body_param_opt_table as get_iseq_body_param_opt_table;
|
||||
pub use rb_get_cikw_keyword_len as get_cikw_keyword_len;
|
||||
pub use rb_get_cikw_keywords_idx as get_cikw_keywords_idx;
|
||||
pub use rb_get_call_data_ci as get_call_data_ci;
|
||||
pub use rb_yarv_str_eql_internal as rb_str_eql_internal;
|
||||
pub use rb_yarv_ary_entry_internal as rb_ary_entry_internal;
|
||||
pub use rb_yarv_fix_mod_fix as rb_fix_mod_fix;
|
||||
pub use rb_FL_TEST as FL_TEST;
|
||||
pub use rb_FL_TEST_RAW as FL_TEST_RAW;
|
||||
pub use rb_RB_TYPE_P as RB_TYPE_P;
|
||||
pub use rb_BASIC_OP_UNREDEFINED_P as BASIC_OP_UNREDEFINED_P;
|
||||
pub use rb_RSTRUCT_LEN as RSTRUCT_LEN;
|
||||
pub use rb_RSTRUCT_SET as RSTRUCT_SET;
|
||||
pub use rb_vm_ci_argc as vm_ci_argc;
|
||||
pub use rb_vm_ci_mid as vm_ci_mid;
|
||||
pub use rb_vm_ci_flag as vm_ci_flag;
|
||||
pub use rb_vm_ci_kwarg as vm_ci_kwarg;
|
||||
pub use rb_METHOD_ENTRY_VISI as METHOD_ENTRY_VISI;
|
||||
pub use rb_RCLASS_ORIGIN as RCLASS_ORIGIN;
|
||||
|
||||
/// Helper so we can get a Rust string for insn_name()
|
||||
pub fn insn_name(opcode: usize) -> String {
|
||||
use std::ffi::CStr;
|
||||
|
|
|
@ -548,6 +548,20 @@ pub const VM_METHOD_TYPE_OPTIMIZED: rb_method_type_t = 9;
|
|||
pub const VM_METHOD_TYPE_MISSING: rb_method_type_t = 10;
|
||||
pub const VM_METHOD_TYPE_REFINED: rb_method_type_t = 11;
|
||||
pub type rb_method_type_t = u32;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct rb_method_cfunc_struct {
|
||||
pub func: ::std::option::Option<unsafe extern "C" fn() -> VALUE>,
|
||||
pub invoker: ::std::option::Option<
|
||||
unsafe extern "C" fn(
|
||||
recv: VALUE,
|
||||
argc: ::std::os::raw::c_int,
|
||||
argv: *const VALUE,
|
||||
func: ::std::option::Option<unsafe extern "C" fn() -> VALUE>,
|
||||
) -> VALUE,
|
||||
>,
|
||||
pub argc: ::std::os::raw::c_int,
|
||||
}
|
||||
pub const OPTIMIZED_METHOD_TYPE_SEND: method_optimized_type = 0;
|
||||
pub const OPTIMIZED_METHOD_TYPE_CALL: method_optimized_type = 1;
|
||||
pub const OPTIMIZED_METHOD_TYPE_BLOCK_CALL: method_optimized_type = 2;
|
||||
|
@ -1025,6 +1039,9 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn rb_full_cfunc_return(ec: *mut rb_execution_context_t, return_value: VALUE);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_iseq_encoded_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_iseq_get_yjit_payload(iseq: *const rb_iseq_t) -> *mut ::std::os::raw::c_void;
|
||||
}
|
||||
|
@ -1047,6 +1064,122 @@ extern "C" {
|
|||
pub fn rb_RSTRING_PTR(str_: VALUE) -> *mut ::std::os::raw::c_char;
|
||||
}
|
||||
pub type rb_seq_param_keyword_struct = rb_iseq_constant_body__bindgen_ty_1_rb_iseq_param_keyword;
|
||||
extern "C" {
|
||||
pub fn rb_insn_name(insn: VALUE) -> *const ::std::os::raw::c_char;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_insn_len(insn: VALUE) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_vm_ci_argc(ci: *const rb_callinfo) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_vm_ci_mid(ci: *const rb_callinfo) -> ID;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_vm_ci_flag(ci: *const rb_callinfo) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_vm_ci_kwarg(ci: *const rb_callinfo) -> *const rb_callinfo_kwarg;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cikw_keyword_len(cikw: *const rb_callinfo_kwarg) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cikw_keywords_idx(
|
||||
cikw: *const rb_callinfo_kwarg,
|
||||
idx: ::std::os::raw::c_int,
|
||||
) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_METHOD_ENTRY_VISI(me: *const rb_callable_method_entry_t) -> rb_method_visibility_t;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cme_def_type(cme: *const rb_callable_method_entry_t) -> rb_method_type_t;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cme_def_body_attr_id(cme: *const rb_callable_method_entry_t) -> ID;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cme_def_body_optimized_type(
|
||||
cme: *const rb_callable_method_entry_t,
|
||||
) -> method_optimized_type;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cme_def_body_optimized_index(
|
||||
cme: *const rb_callable_method_entry_t,
|
||||
) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cme_def_body_cfunc(
|
||||
cme: *const rb_callable_method_entry_t,
|
||||
) -> *mut rb_method_cfunc_t;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_def_method_serial(def: *const rb_method_definition_t) -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_def_original_id(def: *const rb_method_definition_t) -> ID;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_mct_argc(mct: *const rb_method_cfunc_t) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_mct_func(mct: *const rb_method_cfunc_t) -> *mut ::std::os::raw::c_void;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_def_iseq_ptr(def: *mut rb_method_definition_t) -> *const rb_iseq_t;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_local_iseq(iseq: *const rb_iseq_t) -> *const rb_iseq_t;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_local_table_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_iseq_encoded(iseq: *const rb_iseq_t) -> *mut VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_stack_max(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_flags_has_opt(iseq: *const rb_iseq_t) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_flags_has_kw(iseq: *const rb_iseq_t) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_flags_has_post(iseq: *const rb_iseq_t) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_flags_has_kwrest(iseq: *const rb_iseq_t) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_flags_has_rest(iseq: *const rb_iseq_t) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_flags_has_block(iseq: *const rb_iseq_t) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_flags_has_accepts_no_kwarg(iseq: *const rb_iseq_t) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_param_keyword(
|
||||
iseq: *const rb_iseq_t,
|
||||
) -> *const rb_seq_param_keyword_struct;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_param_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_param_lead_num(iseq: *const rb_iseq_t) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_param_opt_num(iseq: *const rb_iseq_t) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_iseq_body_param_opt_table(iseq: *const rb_iseq_t) -> *const VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_leaf_invokebuiltin_iseq_p(iseq: *const rb_iseq_t) -> bool;
|
||||
}
|
||||
|
@ -1056,6 +1189,15 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn rb_yjit_str_simple_append(str1: VALUE, str2: VALUE) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_ec_cfp(ec: *const rb_execution_context_t) -> *mut rb_control_frame_struct;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cfp_pc(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cfp_sp(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_set_cfp_pc(cfp: *mut rb_control_frame_struct, pc: *const VALUE);
|
||||
}
|
||||
|
@ -1065,9 +1207,54 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn rb_cfp_get_iseq(cfp: *mut rb_control_frame_struct) -> *mut rb_iseq_t;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cfp_self(cfp: *mut rb_control_frame_struct) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cfp_ep(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_cfp_ep_level(cfp: *mut rb_control_frame_struct, lv: u32) -> *const VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_yarv_class_of(obj: VALUE) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_yarv_str_eql_internal(str1: VALUE, str2: VALUE) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_yarv_ary_entry_internal(ary: VALUE, offset: ::std::os::raw::c_long) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_yarv_fix_mod_fix(recv: VALUE, obj: VALUE) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_yjit_dump_iseq_loc(iseq: *const rb_iseq_t, insn_idx: u32);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_FL_TEST(obj: VALUE, flags: VALUE) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_FL_TEST_RAW(obj: VALUE, flags: VALUE) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_RB_TYPE_P(obj: VALUE, t: ruby_value_type) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_RSTRUCT_LEN(st: VALUE) -> ::std::os::raw::c_long;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_RSTRUCT_SET(st: VALUE, k: ::std::os::raw::c_int, v: VALUE);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_get_call_data_ci(cd: *const rb_call_data) -> *const rb_callinfo;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_BASIC_OP_UNREDEFINED_P(bop: ruby_basic_operators, klass: u32) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_RCLASS_ORIGIN(c: VALUE) -> VALUE;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn rb_ENCODING_GET(obj: VALUE) -> ::std::os::raw::c_int;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче