Get rid of rb_shape_id(rb_shape_t *)
We should avoid conversions from `rb_shape_t *` into `shape_id_t` outside of `shape.c` as the short term goal is to have `shape_id_t` contain tags.
This commit is contained in:
parent
cc48fcdff2
commit
e535f8248b
Notes:
git
2025-05-27 10:45:38 +00:00
@ -784,15 +784,15 @@ objspace_dump(VALUE os, VALUE obj, VALUE output)
|
||||
}
|
||||
|
||||
static void
|
||||
shape_i(rb_shape_t *shape, void *data)
|
||||
shape_id_i(shape_id_t shape_id, void *data)
|
||||
{
|
||||
struct dump_config *dc = (struct dump_config *)data;
|
||||
|
||||
shape_id_t shape_id = rb_shape_id(shape);
|
||||
if (shape_id < dc->shapes_since) {
|
||||
return;
|
||||
}
|
||||
|
||||
rb_shape_t *shape = RSHAPE(shape_id);
|
||||
dump_append(dc, "{\"address\":");
|
||||
dump_append_ref(dc, (VALUE)shape);
|
||||
|
||||
@ -855,7 +855,7 @@ objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
|
||||
}
|
||||
|
||||
if (RTEST(shapes)) {
|
||||
rb_shape_each_shape(shape_i, &dc);
|
||||
rb_shape_each_shape_id(shape_id_i, &dc);
|
||||
}
|
||||
|
||||
/* dump all objects */
|
||||
@ -872,7 +872,7 @@ objspace_dump_shapes(VALUE os, VALUE output, VALUE shapes)
|
||||
dump_output(&dc, output, Qfalse, Qnil, shapes);
|
||||
|
||||
if (RTEST(shapes)) {
|
||||
rb_shape_each_shape(shape_i, &dc);
|
||||
rb_shape_each_shape_id(shape_id_i, &dc);
|
||||
}
|
||||
return dump_result(&dc);
|
||||
}
|
||||
|
9
shape.c
9
shape.c
@ -319,7 +319,7 @@ rb_shape_get_root_shape(void)
|
||||
return GET_SHAPE_TREE()->root_shape;
|
||||
}
|
||||
|
||||
shape_id_t
|
||||
static inline shape_id_t
|
||||
rb_shape_id(rb_shape_t *shape)
|
||||
{
|
||||
if (shape == NULL) {
|
||||
@ -329,12 +329,13 @@ rb_shape_id(rb_shape_t *shape)
|
||||
}
|
||||
|
||||
void
|
||||
rb_shape_each_shape(each_shape_callback callback, void *data)
|
||||
rb_shape_each_shape_id(each_shape_callback callback, void *data)
|
||||
{
|
||||
rb_shape_t *cursor = rb_shape_get_root_shape();
|
||||
rb_shape_t *start = rb_shape_get_root_shape();
|
||||
rb_shape_t *cursor = start;
|
||||
rb_shape_t *end = RSHAPE(GET_SHAPE_TREE()->next_shape_id);
|
||||
while (cursor < end) {
|
||||
callback(cursor, data);
|
||||
callback((shape_id_t)(cursor - start), data);
|
||||
cursor += 1;
|
||||
}
|
||||
}
|
||||
|
5
shape.h
5
shape.h
@ -219,12 +219,11 @@ rb_shape_obj_has_id(VALUE obj)
|
||||
|
||||
// For ext/objspace
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
typedef void each_shape_callback(rb_shape_t *shape, void *data);
|
||||
void rb_shape_each_shape(each_shape_callback callback, void *data);
|
||||
typedef void each_shape_callback(shape_id_t shape_id, void *data);
|
||||
void rb_shape_each_shape_id(each_shape_callback callback, void *data);
|
||||
size_t rb_shape_memsize(shape_id_t shape);
|
||||
size_t rb_shape_edges_count(shape_id_t shape_id);
|
||||
size_t rb_shape_depth(shape_id_t shape_id);
|
||||
shape_id_t rb_shape_id(rb_shape_t *shape);
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
#endif
|
||||
|
@ -99,7 +99,6 @@ fn main() {
|
||||
.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_shape_id")
|
||||
.allowlist_function("rb_shape_obj_too_complex_p")
|
||||
.allowlist_function("rb_shape_too_complex_p")
|
||||
.allowlist_var("SHAPE_ID_NUM_BITS")
|
||||
|
1
yjit/src/cruby_bindings.inc.rs
generated
1
yjit/src/cruby_bindings.inc.rs
generated
@ -1146,7 +1146,6 @@ extern "C" {
|
||||
pub fn rb_shape_obj_too_complex_p(obj: VALUE) -> bool;
|
||||
pub fn rb_shape_too_complex_p(shape: *mut rb_shape_t) -> bool;
|
||||
pub fn rb_shape_transition_add_ivar_no_warnings(obj: VALUE, id: ID) -> shape_id_t;
|
||||
pub fn rb_shape_id(shape: *mut rb_shape_t) -> shape_id_t;
|
||||
pub fn rb_gvar_get(arg1: ID) -> VALUE;
|
||||
pub fn rb_gvar_set(arg1: ID, arg2: VALUE) -> VALUE;
|
||||
pub fn rb_ensure_iv_list_size(obj: VALUE, len: u32, newsize: u32);
|
||||
|
@ -112,7 +112,6 @@ fn main() {
|
||||
.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_shape_id")
|
||||
.allowlist_function("rb_shape_obj_too_complex_p")
|
||||
.allowlist_var("SHAPE_ID_NUM_BITS")
|
||||
|
||||
|
1
zjit/src/cruby_bindings.inc.rs
generated
1
zjit/src/cruby_bindings.inc.rs
generated
@ -875,7 +875,6 @@ unsafe extern "C" {
|
||||
pub fn rb_shape_get_iv_index(shape: *mut rb_shape_t, id: ID, value: *mut attr_index_t) -> bool;
|
||||
pub fn rb_shape_obj_too_complex_p(obj: VALUE) -> bool;
|
||||
pub fn rb_shape_transition_add_ivar_no_warnings(obj: VALUE, id: ID) -> shape_id_t;
|
||||
pub fn rb_shape_id(shape: *mut rb_shape_t) -> shape_id_t;
|
||||
pub fn rb_gvar_get(arg1: ID) -> VALUE;
|
||||
pub fn rb_gvar_set(arg1: ID, arg2: VALUE) -> VALUE;
|
||||
pub fn rb_ensure_iv_list_size(obj: VALUE, len: u32, newsize: u32);
|
||||
|
Loading…
x
Reference in New Issue
Block a user