mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
ZJIT: Avoid binding to rb_iseq_constant_body
Its definition changes depending on e.g. whether there is YJIT in the build.
This commit is contained in:
parent
8132b3d1d8
commit
109ddd291e
Notes:
git
2025-12-05 20:50:32 +00:00
4
zjit.c
4
zjit.c
@ -31,6 +31,10 @@
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
enum zjit_struct_offsets {
|
||||
ISEQ_BODY_OFFSET_PARAM = offsetof(struct rb_iseq_constant_body, param)
|
||||
};
|
||||
|
||||
#define PTR2NUM(x) (rb_int2inum((intptr_t)(void *)(x)))
|
||||
|
||||
// For a given raw_sample (frame), set the hash with the caller's
|
||||
|
||||
@ -301,6 +301,7 @@ fn main() {
|
||||
.allowlist_function("rb_zjit_defined_ivar")
|
||||
.allowlist_function("rb_zjit_insn_leaf")
|
||||
.allowlist_type("jit_bindgen_constants")
|
||||
.allowlist_type("zjit_struct_offsets")
|
||||
.allowlist_function("rb_assert_holding_vm_lock")
|
||||
.allowlist_function("rb_jit_shape_too_complex_p")
|
||||
.allowlist_function("rb_jit_multi_ractor_p")
|
||||
@ -428,6 +429,7 @@ fn main() {
|
||||
// We define these manually, don't import them
|
||||
.blocklist_type("VALUE")
|
||||
.blocklist_type("ID")
|
||||
.blocklist_type("rb_iseq_constant_body")
|
||||
|
||||
// Avoid binding to stuff we don't use
|
||||
.blocklist_item("rb_thread_struct.*")
|
||||
|
||||
@ -231,6 +231,16 @@ pub fn insn_len(opcode: usize) -> u32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// We avoid using bindgen for `rb_iseq_constant_body` since its definition changes depending
|
||||
/// on build configuration while we need one bindgen file that works for all configurations.
|
||||
/// Use an opaque type for it instead.
|
||||
/// See: <https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs>
|
||||
#[repr(C)]
|
||||
pub struct rb_iseq_constant_body {
|
||||
_data: [u8; 0],
|
||||
_marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
|
||||
}
|
||||
|
||||
/// An object handle similar to VALUE in the C code. Our methods assume
|
||||
/// that this is a handle. Sometimes the C code briefly uses VALUE as
|
||||
/// an unsigned integer type and don't necessarily store valid handles but
|
||||
@ -683,7 +693,8 @@ pub trait IseqAccess {
|
||||
impl IseqAccess for IseqPtr {
|
||||
/// Get a description of the ISEQ's signature. Analogous to `ISEQ_BODY(iseq)->param` in C.
|
||||
unsafe fn params<'a>(self) -> &'a IseqParameters {
|
||||
unsafe { &(*(*self).body).param }
|
||||
use crate::cast::IntoUsize;
|
||||
unsafe { &*((*self).body.byte_add(ISEQ_BODY_OFFSET_PARAM.to_usize()) as *const IseqParameters) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
zjit/src/cruby_bindings.inc.rs
generated
36
zjit/src/cruby_bindings.inc.rs
generated
@ -595,40 +595,6 @@ pub type rb_jit_func_t = ::std::option::Option<
|
||||
) -> VALUE,
|
||||
>;
|
||||
#[repr(C)]
|
||||
pub struct rb_iseq_constant_body {
|
||||
pub type_: rb_iseq_type,
|
||||
pub iseq_size: ::std::os::raw::c_uint,
|
||||
pub iseq_encoded: *mut VALUE,
|
||||
pub param: rb_iseq_constant_body_rb_iseq_parameters,
|
||||
pub location: rb_iseq_location_t,
|
||||
pub insns_info: rb_iseq_constant_body_iseq_insn_info,
|
||||
pub local_table: *const ID,
|
||||
pub lvar_states: *mut rb_iseq_constant_body_lvar_state,
|
||||
pub catch_table: *mut iseq_catch_table,
|
||||
pub parent_iseq: *const rb_iseq_struct,
|
||||
pub local_iseq: *mut rb_iseq_struct,
|
||||
pub is_entries: *mut iseq_inline_storage_entry,
|
||||
pub call_data: *mut rb_call_data,
|
||||
pub variable: rb_iseq_constant_body__bindgen_ty_1,
|
||||
pub local_table_size: ::std::os::raw::c_uint,
|
||||
pub ic_size: ::std::os::raw::c_uint,
|
||||
pub ise_size: ::std::os::raw::c_uint,
|
||||
pub ivc_size: ::std::os::raw::c_uint,
|
||||
pub icvarc_size: ::std::os::raw::c_uint,
|
||||
pub ci_size: ::std::os::raw::c_uint,
|
||||
pub stack_max: ::std::os::raw::c_uint,
|
||||
pub builtin_attrs: ::std::os::raw::c_uint,
|
||||
pub prism: bool,
|
||||
pub mark_bits: rb_iseq_constant_body__bindgen_ty_2,
|
||||
pub outer_variables: *mut rb_id_table,
|
||||
pub mandatory_only_iseq: *const rb_iseq_t,
|
||||
pub jit_entry: rb_jit_func_t,
|
||||
pub jit_entry_calls: ::std::os::raw::c_ulong,
|
||||
pub jit_exception: rb_jit_func_t,
|
||||
pub jit_exception_calls: ::std::os::raw::c_ulong,
|
||||
pub zjit_payload: *mut ::std::os::raw::c_void,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct rb_iseq_constant_body_rb_iseq_parameters {
|
||||
pub flags: rb_iseq_constant_body_rb_iseq_parameters__bindgen_ty_1,
|
||||
@ -1866,6 +1832,8 @@ pub const DEFINED_REF: defined_type = 15;
|
||||
pub const DEFINED_FUNC: defined_type = 16;
|
||||
pub const DEFINED_CONST_FROM: defined_type = 17;
|
||||
pub type defined_type = u32;
|
||||
pub const ISEQ_BODY_OFFSET_PARAM: zjit_struct_offsets = 16;
|
||||
pub type zjit_struct_offsets = u32;
|
||||
pub const ROBJECT_OFFSET_AS_HEAP_FIELDS: jit_bindgen_constants = 16;
|
||||
pub const ROBJECT_OFFSET_AS_ARY: jit_bindgen_constants = 16;
|
||||
pub const RUBY_OFFSET_RSTRING_LEN: jit_bindgen_constants = 16;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user