diff options
author | Jean Boussier <[email protected]> | 2025-05-27 11:51:29 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-05-27 12:45:24 +0200 |
commit | e535f8248b1ad9f18cfc8134dd7e8056d97a6244 (patch) | |
tree | 98be43b7ffc1bea7eef31c0e05136a9e3e20884a | |
parent | cc48fcdff22689cdca04181105582150b01904a1 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13448
-rw-r--r-- | ext/objspace/objspace_dump.c | 8 | ||||
-rw-r--r-- | shape.c | 9 | ||||
-rw-r--r-- | shape.h | 5 | ||||
-rw-r--r-- | yjit/bindgen/src/main.rs | 1 | ||||
-rw-r--r-- | yjit/src/cruby_bindings.inc.rs | 1 | ||||
-rw-r--r-- | zjit/bindgen/src/main.rs | 1 | ||||
-rw-r--r-- | zjit/src/cruby_bindings.inc.rs | 1 |
7 files changed, 11 insertions, 15 deletions
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index 814b939995..3ddaac5cfb 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -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); } @@ -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; } } @@ -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 diff --git a/yjit/bindgen/src/main.rs b/yjit/bindgen/src/main.rs index ba2e1cc34a..5c662a834f 100644 --- a/yjit/bindgen/src/main.rs +++ b/yjit/bindgen/src/main.rs @@ -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") diff --git a/yjit/src/cruby_bindings.inc.rs b/yjit/src/cruby_bindings.inc.rs index 0afe9184a3..2b4da036d3 100644 --- a/yjit/src/cruby_bindings.inc.rs +++ b/yjit/src/cruby_bindings.inc.rs @@ -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); diff --git a/zjit/bindgen/src/main.rs b/zjit/bindgen/src/main.rs index 8162f9a9ed..41297e2032 100644 --- a/zjit/bindgen/src/main.rs +++ b/zjit/bindgen/src/main.rs @@ -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") diff --git a/zjit/src/cruby_bindings.inc.rs b/zjit/src/cruby_bindings.inc.rs index 10dc406aca..083a90ceaf 100644 --- a/zjit/src/cruby_bindings.inc.rs +++ b/zjit/src/cruby_bindings.inc.rs @@ -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); |