Get rid of rb_shape_lookup
This commit is contained in:
parent
0292b702c4
commit
e070d93573
Notes:
git
2025-06-12 15:08:39 +00:00
6
shape.c
6
shape.c
@ -380,12 +380,6 @@ rb_shape_each_shape_id(each_shape_callback callback, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
RUBY_FUNC_EXPORTED rb_shape_t *
|
||||
rb_shape_lookup(shape_id_t shape_id)
|
||||
{
|
||||
return RSHAPE(shape_id);
|
||||
}
|
||||
|
||||
RUBY_FUNC_EXPORTED shape_id_t
|
||||
rb_obj_shape_id(VALUE obj)
|
||||
{
|
||||
|
1
shape.h
1
shape.h
@ -163,7 +163,6 @@ RSHAPE(shape_id_t shape_id)
|
||||
|
||||
int32_t rb_shape_id_offset(void);
|
||||
|
||||
RUBY_FUNC_EXPORTED rb_shape_t *rb_shape_lookup(shape_id_t shape_id);
|
||||
RUBY_FUNC_EXPORTED shape_id_t rb_obj_shape_id(VALUE obj);
|
||||
shape_id_t rb_shape_get_next_iv_shape(shape_id_t shape_id, ID id);
|
||||
bool rb_shape_get_iv_index(shape_id_t shape_id, ID id, attr_index_t *value);
|
||||
|
6
yjit.c
6
yjit.c
@ -799,6 +799,12 @@ rb_yjit_shape_capacity(shape_id_t shape_id)
|
||||
return RSHAPE_CAPACITY(shape_id);
|
||||
}
|
||||
|
||||
attr_index_t
|
||||
rb_yjit_shape_index(shape_id_t shape_id)
|
||||
{
|
||||
return RSHAPE_INDEX(shape_id);
|
||||
}
|
||||
|
||||
// Assert that we have the VM lock. Relevant mostly for multi ractor situations.
|
||||
// The GC takes the lock before calling us, and this asserts that it indeed happens.
|
||||
void
|
||||
|
@ -95,13 +95,13 @@ fn main() {
|
||||
|
||||
// From shape.h
|
||||
.allowlist_function("rb_obj_shape_id")
|
||||
.allowlist_function("rb_shape_lookup")
|
||||
.allowlist_function("rb_shape_id_offset")
|
||||
.allowlist_function("rb_shape_get_iv_index")
|
||||
.allowlist_function("rb_shape_transition_add_ivar_no_warnings")
|
||||
.allowlist_function("rb_yjit_shape_obj_too_complex_p")
|
||||
.allowlist_function("rb_yjit_shape_too_complex_p")
|
||||
.allowlist_function("rb_yjit_shape_capacity")
|
||||
.allowlist_function("rb_yjit_shape_index")
|
||||
.allowlist_var("SHAPE_ID_NUM_BITS")
|
||||
|
||||
// From ruby/internal/intern/object.h
|
||||
|
@ -3128,8 +3128,6 @@ fn gen_set_ivar(
|
||||
if new_shape_too_complex {
|
||||
Some((next_shape_id, None, 0_usize))
|
||||
} else {
|
||||
let current_shape = unsafe { rb_shape_lookup(current_shape_id) };
|
||||
|
||||
let current_capacity = unsafe { rb_yjit_shape_capacity(current_shape_id) };
|
||||
let next_capacity = unsafe { rb_yjit_shape_capacity(next_shape_id) };
|
||||
|
||||
@ -3138,7 +3136,7 @@ fn gen_set_ivar(
|
||||
let needs_extension = next_capacity != current_capacity;
|
||||
|
||||
// We can write to the object, but we need to transition the shape
|
||||
let ivar_index = unsafe { (*current_shape).next_field_index } as usize;
|
||||
let ivar_index = unsafe { rb_yjit_shape_index(next_shape_id) } as usize;
|
||||
|
||||
let needs_extension = if needs_extension {
|
||||
Some((current_capacity, next_capacity))
|
||||
|
@ -448,18 +448,6 @@ impl VALUE {
|
||||
unsafe { rb_obj_shape_id(self) }
|
||||
}
|
||||
|
||||
pub fn shape_of(self) -> *mut rb_shape {
|
||||
unsafe {
|
||||
let shape = rb_shape_lookup(self.shape_id_of());
|
||||
|
||||
if shape.is_null() {
|
||||
panic!("Shape should not be null");
|
||||
} else {
|
||||
shape
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn embedded_p(self) -> bool {
|
||||
unsafe {
|
||||
FL_TEST_RAW(self, VALUE(ROBJECT_EMBED as usize)) != VALUE(0)
|
||||
|
23
yjit/src/cruby_bindings.inc.rs
generated
23
yjit/src/cruby_bindings.inc.rs
generated
@ -688,27 +688,6 @@ pub const VM_ENV_FLAG_ISOLATED: vm_frame_env_flags = 16;
|
||||
pub type vm_frame_env_flags = u32;
|
||||
pub type attr_index_t = u16;
|
||||
pub type shape_id_t = u32;
|
||||
pub type redblack_id_t = u32;
|
||||
pub type redblack_node_t = redblack_node;
|
||||
#[repr(C)]
|
||||
pub struct rb_shape {
|
||||
pub edges: VALUE,
|
||||
pub edge_name: ID,
|
||||
pub ancestor_index: *mut redblack_node_t,
|
||||
pub parent_id: shape_id_t,
|
||||
pub next_field_index: attr_index_t,
|
||||
pub capacity: attr_index_t,
|
||||
pub type_: u8,
|
||||
}
|
||||
pub type rb_shape_t = rb_shape;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct redblack_node {
|
||||
pub key: ID,
|
||||
pub value: *mut rb_shape_t,
|
||||
pub l: redblack_id_t,
|
||||
pub r: redblack_id_t,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct rb_cvar_class_tbl_entry {
|
||||
pub index: u32,
|
||||
@ -1133,7 +1112,6 @@ extern "C" {
|
||||
pub fn rb_obj_info(obj: VALUE) -> *const ::std::os::raw::c_char;
|
||||
pub fn rb_ec_stack_check(ec: *mut rb_execution_context_struct) -> ::std::os::raw::c_int;
|
||||
pub fn rb_shape_id_offset() -> i32;
|
||||
pub fn rb_shape_lookup(shape_id: shape_id_t) -> *mut rb_shape_t;
|
||||
pub fn rb_obj_shape_id(obj: VALUE) -> shape_id_t;
|
||||
pub fn rb_shape_get_iv_index(shape_id: shape_id_t, id: ID, value: *mut attr_index_t) -> bool;
|
||||
pub fn rb_shape_transition_add_ivar_no_warnings(obj: VALUE, id: ID) -> shape_id_t;
|
||||
@ -1265,6 +1243,7 @@ extern "C" {
|
||||
pub fn rb_yjit_shape_too_complex_p(shape_id: shape_id_t) -> bool;
|
||||
pub fn rb_yjit_shape_obj_too_complex_p(obj: VALUE) -> bool;
|
||||
pub fn rb_yjit_shape_capacity(shape_id: shape_id_t) -> attr_index_t;
|
||||
pub fn rb_yjit_shape_index(shape_id: shape_id_t) -> attr_index_t;
|
||||
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;
|
||||
|
@ -108,7 +108,6 @@ fn main() {
|
||||
|
||||
// From shape.h
|
||||
.allowlist_function("rb_obj_shape_id")
|
||||
.allowlist_function("rb_shape_lookup")
|
||||
.allowlist_function("rb_shape_id_offset")
|
||||
.allowlist_function("rb_shape_get_iv_index")
|
||||
.allowlist_function("rb_shape_transition_add_ivar_no_warnings")
|
||||
|
@ -485,18 +485,6 @@ impl VALUE {
|
||||
unsafe { rb_obj_shape_id(self) }
|
||||
}
|
||||
|
||||
pub fn shape_of(self) -> *mut rb_shape {
|
||||
unsafe {
|
||||
let shape = rb_shape_lookup(self.shape_id_of());
|
||||
|
||||
if shape.is_null() {
|
||||
panic!("Shape should not be null");
|
||||
} else {
|
||||
shape
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn embedded_p(self) -> bool {
|
||||
unsafe {
|
||||
FL_TEST_RAW(self, VALUE(ROBJECT_EMBED as usize)) != VALUE(0)
|
||||
|
21
zjit/src/cruby_bindings.inc.rs
generated
21
zjit/src/cruby_bindings.inc.rs
generated
@ -396,26 +396,6 @@ pub const VM_ENV_FLAG_ISOLATED: vm_frame_env_flags = 16;
|
||||
pub type vm_frame_env_flags = u32;
|
||||
pub type attr_index_t = u16;
|
||||
pub type shape_id_t = u32;
|
||||
pub type redblack_id_t = u32;
|
||||
pub type redblack_node_t = redblack_node;
|
||||
#[repr(C)]
|
||||
pub struct rb_shape {
|
||||
pub edges: VALUE,
|
||||
pub edge_name: ID,
|
||||
pub ancestor_index: *mut redblack_node_t,
|
||||
pub parent_id: shape_id_t,
|
||||
pub next_field_index: attr_index_t,
|
||||
pub capacity: attr_index_t,
|
||||
pub type_: u8,
|
||||
}
|
||||
pub type rb_shape_t = rb_shape;
|
||||
#[repr(C)]
|
||||
pub struct redblack_node {
|
||||
pub key: ID,
|
||||
pub value: *mut rb_shape_t,
|
||||
pub l: redblack_id_t,
|
||||
pub r: redblack_id_t,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct rb_cvar_class_tbl_entry {
|
||||
pub index: u32,
|
||||
@ -866,7 +846,6 @@ unsafe extern "C" {
|
||||
pub fn rb_obj_info(obj: VALUE) -> *const ::std::os::raw::c_char;
|
||||
pub fn rb_ec_stack_check(ec: *mut rb_execution_context_struct) -> ::std::os::raw::c_int;
|
||||
pub fn rb_shape_id_offset() -> i32;
|
||||
pub fn rb_shape_lookup(shape_id: shape_id_t) -> *mut rb_shape_t;
|
||||
pub fn rb_obj_shape_id(obj: VALUE) -> shape_id_t;
|
||||
pub fn rb_shape_get_iv_index(shape_id: shape_id_t, id: ID, value: *mut attr_index_t) -> bool;
|
||||
pub fn rb_shape_transition_add_ivar_no_warnings(obj: VALUE, id: ID) -> shape_id_t;
|
||||
|
Loading…
x
Reference in New Issue
Block a user