8000 shape.h: make RSHAPE static inline by casperisfine · Pull Request #13596 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

shape.h: make RSHAPE static inline #13596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump 8000 to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get rid of rb_shape_lookup
  • Loading branch information
byroot committed Jun 12, 2025
commit 51554588a7dadc0dc69a9bc789404806145b4f2c
6 changes: 0 additions & 6 deletions shape.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions yjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion yjit/bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) };

Expand All @@ -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))
Expand Down
12 changes: 0 additions & 12 deletions yjit/src/cruby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 1 addition & 22 deletions yjit/src/cruby_bindings.inc.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion zjit/bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 0 additions & 12 deletions zjit/src/cruby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 0 additions & 21 deletions zjit/src/cruby_bindings.inc.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
0