Skip to content

Commit 5782561

Browse files
committed
Rename rb_shape_get_shape_id -> RB_OBJ_SHAPE_ID
And `rb_shape_get_shape` -> `RB_OBJ_SHAPE`.
1 parent a007575 commit 5782561

File tree

14 files changed

+46
-46
lines changed

14 files changed

+46
-46
lines changed

ext/objspace/objspace_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ dump_object(VALUE obj, struct dump_config *dc)
414414
dump_append(dc, obj_type(obj));
415415
dump_append(dc, "\"");
416416

417-
size_t shape_id = rb_shape_get_shape_id(obj);
417+
size_t shape_id = RB_OBJ_SHAPE_ID(obj);
418418
dump_append(dc, ", \"shape_id\":");
419419
dump_append_sizet(dc, shape_id);
420420

gc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ rb_gc_shutdown_call_finalizer_p(VALUE obj)
367367
uint32_t
368368
rb_gc_get_shape(VALUE obj)
369369
{
370-
return (uint32_t)rb_shape_get_shape_id(obj);
370+
return (uint32_t)RB_OBJ_SHAPE_ID(obj);
371371
}
372372

373373
void
@@ -379,7 +379,7 @@ rb_gc_set_shape(VALUE obj, uint32_t shape_id)
379379
uint32_t
380380
rb_gc_rebuild_shape(VALUE obj, size_t heap_id)
381381
{
382-
shape_id_t orig_shape_id = rb_shape_get_shape_id(obj);
382+
shape_id_t orig_shape_id = RB_OBJ_SHAPE_ID(obj);
383383
if (rb_shape_id_too_complex_p(orig_shape_id)) {
384384
return (uint32_t)orig_shape_id;
385385
}
@@ -1815,7 +1815,7 @@ static VALUE
18151815
object_id(VALUE obj)
18161816
{
18171817
VALUE id = Qfalse;
1818-
rb_shape_t *shape = rb_shape_get_shape(obj);
1818+
rb_shape_t *shape = RB_OBJ_SHAPE(obj);
18191819
unsigned int lock_lev;
18201820

18211821
// We could avoid locking if the object isn't shareable

marshal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,18 +713,18 @@ has_ivars(VALUE obj, VALUE encname, VALUE *ivobj)
713713
static void
714714
w_ivar_each(VALUE obj, st_index_t num, struct dump_call_arg *arg)
715715
{
716-
shape_id_t shape_id = rb_shape_get_shape_id(arg->obj);
716+
shape_id_t shape_id = RB_OBJ_SHAPE_ID(arg->obj);
717717
struct w_ivar_arg ivarg = {arg, num};
718718
if (!num) return;
719719
rb_ivar_foreach(obj, w_obj_each, (st_data_t)&ivarg);
720720

721-
shape_id_t actual_shape_id = rb_shape_get_shape_id(arg->obj);
721+
shape_id_t actual_shape_id = RB_OBJ_SHAPE_ID(arg->obj);
722722
if (shape_id != actual_shape_id) {
723723
// If the shape tree got _shorter_ then we probably removed an IV
724724
// If the shape tree got longer, then we probably added an IV.
725725
// The exception message might not be accurate when someone adds and
726726
// removes the same number of IVs, but they will still get an exception
727-
if (rb_shape_depth(shape_id) > rb_shape_depth(rb_shape_get_shape_id(arg->obj))) {
727+
if (rb_shape_depth(shape_id) > rb_shape_depth(RB_OBJ_SHAPE_ID(arg->obj))) {
728728
rb_raise(rb_eRuntimeError, "instance variable removed from %"PRIsVALUE" instance",
729729
CLASS_OF(arg->obj));
730730
}

object.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ rb_class_allocate_instance(VALUE klass)
132132
T_OBJECT | ROBJECT_EMBED | (RGENGC_WB_PROTECTED_OBJECT ? FL_WB_PROTECTED : 0), size, 0);
133133
VALUE obj = (VALUE)o;
134134

135-
RUBY_ASSERT(rb_shape_get_shape(obj)->type == SHAPE_ROOT);
135+
RUBY_ASSERT(RB_OBJ_SHAPE(obj)->type == SHAPE_ROOT);
136136

137137
// Set the shape to the specific T_OBJECT shape.
138138
ROBJECT_SET_SHAPE_ID(obj, (shape_id_t)(rb_gc_heap_id_for_size(size) + FIRST_T_OBJECT_SHAPE_ID));
@@ -335,7 +335,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
335335
return;
336336
}
337337

338-
rb_shape_t *src_shape = rb_shape_get_shape(obj);
338+
rb_shape_t *src_shape = RB_OBJ_SHAPE(obj);
339339

340340
if (rb_shape_too_complex_p(src_shape)) {
341341
// obj is TOO_COMPLEX so we can copy its iv_hash
@@ -350,7 +350,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
350350
}
351351

352352
rb_shape_t *shape_to_set_on_dest = src_shape;
353-
rb_shape_t *initial_shape = rb_shape_get_shape(dest);
353+
rb_shape_t *initial_shape = RB_OBJ_SHAPE(dest);
354354

355355
if (initial_shape->heap_index != src_shape->heap_index || !rb_shape_canonical_p(src_shape)) {
356356
RUBY_ASSERT(initial_shape->type == SHAPE_T_OBJECT);

shape.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ shape_id_t rb_generic_shape_id(VALUE obj);
358358
#endif
359359

360360
RUBY_FUNC_EXPORTED shape_id_t
361-
rb_shape_get_shape_id(VALUE obj)
361+
RB_OBJ_SHAPE_ID(VALUE obj)
362362
{
363363
if (RB_SPECIAL_CONST_P(obj)) {
364364
return SPECIAL_CONST_SHAPE_ID;
@@ -395,9 +395,9 @@ rb_shape_depth(shape_id_t shape_id)
395395
}
396396

397397
rb_shape_t *
398-
rb_shape_get_shape(VALUE obj)
398+
RB_OBJ_SHAPE(VALUE obj)
399399
{
400-
return RSHAPE(rb_shape_get_shape_id(obj));
400+
return RSHAPE(RB_OBJ_SHAPE_ID(obj));
401401
}
402402

403403
static rb_shape_t *
@@ -647,7 +647,7 @@ remove_shape_recursive(rb_shape_t *shape, ID id, rb_shape_t **removed_shape)
647647
bool
648648
rb_shape_transition_remove_ivar(VALUE obj, ID id, VALUE *removed)
649649
{
650-
rb_shape_t *shape = rb_shape_get_shape(obj);
650+
rb_shape_t *shape = RB_OBJ_SHAPE(obj);
651651

652652
if (UNLIKELY(rb_shape_too_complex_p(shape))) {
653653
return false;
@@ -707,7 +707,7 @@ rb_shape_transition_frozen(VALUE obj)
707707
{
708708
RUBY_ASSERT(RB_OBJ_FROZEN(obj));
709709

710-
shape_id_t shape_id = rb_shape_get_shape_id(obj);
710+
shape_id_t shape_id = RB_OBJ_SHAPE_ID(obj);
711711
if (shape_id == ROOT_SHAPE_ID) {
712712
return SPECIAL_CONST_SHAPE_ID;
713713
}
@@ -747,7 +747,7 @@ shape_transition_too_complex(rb_shape_t *original_shape)
747747
shape_id_t
748748
rb_shape_transition_complex(VALUE obj)
749749
{
750-
rb_shape_t *original_shape = rb_shape_get_shape(obj);
750+
rb_shape_t *original_shape = RB_OBJ_SHAPE(obj);
751751
return rb_shape_id(shape_transition_too_complex(original_shape));
752752
}
753753

@@ -760,7 +760,7 @@ rb_shape_has_object_id(rb_shape_t *shape)
760760
rb_shape_t *
761761
rb_shape_object_id_shape(VALUE obj)
762762
{
763-
rb_shape_t* shape = rb_shape_get_shape(obj);
763+
rb_shape_t* shape = RB_OBJ_SHAPE(obj);
764764
RUBY_ASSERT(shape);
765765

766766
if (shape->flags & SHAPE_FL_HAS_OBJECT_ID) {
@@ -850,13 +850,13 @@ shape_get_next(rb_shape_t *shape, VALUE obj, ID id, bool emit_warnings)
850850
shape_id_t
851851
rb_shape_transition_add_ivar(VALUE obj, ID id)
852852
{
853-
return rb_shape_id(shape_get_next(rb_shape_get_shape(obj), obj, id, true));
853+
return rb_shape_id(shape_get_next(RB_OBJ_SHAPE(obj), obj, id, true));
854854
}
855855

856856
shape_id_t
857857
rb_shape_transition_add_ivar_no_warnings(VALUE obj, ID id)
858858
{
859-
return rb_shape_id(shape_get_next(rb_shape_get_shape(obj), obj, id, false));
859+
return rb_shape_id(shape_get_next(RB_OBJ_SHAPE(obj), obj, id, false));
860860
}
861861

862862
// Same as rb_shape_get_iv_index, but uses a provided valid shape id and index
@@ -1104,7 +1104,7 @@ rb_shape_rebuild_shape(rb_shape_t *initial_shape, rb_shape_t *dest_shape)
11041104
RUBY_FUNC_EXPORTED bool
11051105
rb_shape_obj_too_complex_p(VALUE obj)
11061106
{
1107-
return rb_shape_too_complex_p(rb_shape_get_shape(obj));
1107+
return rb_shape_too_complex_p(RB_OBJ_SHAPE(obj));
11081108
}
11091109

11101110
bool
@@ -1267,7 +1267,7 @@ rb_shape_parent(VALUE self)
12671267
static VALUE
12681268
rb_shape_debug_shape(VALUE self, VALUE obj)
12691269
{
1270-
return rb_shape_t_to_rb_cShape(rb_shape_get_shape(obj));
1270+
return rb_shape_t_to_rb_cShape(RB_OBJ_SHAPE(obj));
12711271
}
12721272

12731273
static VALUE

shape.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ int32_t rb_shape_id_offset(void);
154154
rb_shape_t *rb_shape_get_parent(rb_shape_t *shape);
155155

156156
RUBY_FUNC_EXPORTED rb_shape_t *RSHAPE(shape_id_t shape_id);
157-
RUBY_FUNC_EXPORTED shape_id_t rb_shape_get_shape_id(VALUE obj);
157+
RUBY_FUNC_EXPORTED shape_id_t RB_OBJ_SHAPE_ID(VALUE obj);
158158
shape_id_t rb_shape_get_next_iv_shape(shape_id_t shape_id, ID id);
159159
bool rb_shape_get_iv_index(rb_shape_t *shape, ID id, attr_index_t *value);
160160
bool rb_shape_get_iv_index_with_hint(shape_id_t shape_id, ID id, attr_index_t *value, shape_id_t *shape_id_hint);
@@ -163,7 +163,7 @@ bool rb_shape_too_complex_p(rb_shape_t *shape);
163163
bool rb_shape_id_too_complex_p(shape_id_t shape_id);
164164

165165
void rb_shape_set_shape(VALUE obj, rb_shape_t *shape);
166-
rb_shape_t *rb_shape_get_shape(VALUE obj);
166+
rb_shape_t *RB_OBJ_SHAPE(VALUE obj);
167167
bool rb_shape_frozen_shape_p(rb_shape_t *shape);
168168
shape_id_t rb_shape_transition_frozen(VALUE obj);
169169
shape_id_t rb_shape_transition_complex(VALUE obj);
@@ -227,7 +227,7 @@ ROBJECT_FIELDS_COUNT(VALUE obj)
227227
static inline uint32_t
228228
RBASIC_FIELDS_COUNT(VALUE obj)
229229
{
230-
return RSHAPE(rb_shape_get_shape_id(obj))->next_field_index;
230+
return RSHAPE(RB_OBJ_SHAPE_ID(obj))->next_field_index;
231231
}
232232

233233
shape_id_t rb_shape_traverse_from_new_root(shape_id_t initial_shape_id, shape_id_t orig_shape_id);
@@ -237,7 +237,7 @@ bool rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id);
237237
static inline bool
238238
rb_shape_obj_has_id(VALUE obj)
239239
{
240-
return rb_shape_has_object_id(rb_shape_get_shape(obj));
240+
return rb_shape_has_object_id(RB_OBJ_SHAPE(obj));
241241
}
242242

243243
// For ext/objspace

variable.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,8 @@ rb_obj_init_too_complex(VALUE obj, st_table *table)
15701570
{
15711571
// This method is meant to be called on newly allocated object.
15721572
RUBY_ASSERT(!rb_shape_obj_too_complex_p(obj));
1573-
RUBY_ASSERT(rb_shape_canonical_p(rb_shape_get_shape(obj)));
1574-
RUBY_ASSERT(rb_shape_get_shape(obj)->next_field_index == 0);
1573+
RUBY_ASSERT(rb_shape_canonical_p(RB_OBJ_SHAPE(obj)));
1574+
RUBY_ASSERT(RB_OBJ_SHAPE(obj)->next_field_index == 0);
15751575

15761576
obj_transition_too_complex(obj, table);
15771577
}
@@ -1584,7 +1584,7 @@ rb_evict_fields_to_hash(VALUE obj)
15841584

15851585
RUBY_ASSERT(!rb_shape_obj_too_complex_p(obj));
15861586

1587-
rb_shape_t *shape = rb_shape_get_shape(obj);
1587+
rb_shape_t *shape = RB_OBJ_SHAPE(obj);
15881588
st_table *table = st_init_numtable_with_size(shape->next_field_index);
15891589
rb_obj_copy_fields_to_hash_table(obj, table);
15901590
obj_transition_too_complex(obj, table);
@@ -1624,7 +1624,7 @@ general_ivar_set(VALUE obj, ID id, VALUE val, void *data,
16241624
.existing = true
16251625
};
16261626

1627-
rb_shape_t *current_shape = rb_shape_get_shape(obj);
1627+
rb_shape_t *current_shape = RB_OBJ_SHAPE(obj);
16281628

16291629
if (UNLIKELY(rb_shape_too_complex_p(current_shape))) {
16301630
goto too_complex;
@@ -1681,7 +1681,7 @@ general_field_set(VALUE obj, rb_shape_t *target_shape, VALUE val, void *data,
16811681
void (*transition_too_complex_func)(VALUE, void *),
16821682
st_table *(*too_complex_table_func)(VALUE, void *))
16831683
{
1684-
rb_shape_t *current_shape = rb_shape_get_shape(obj);
1684+
rb_shape_t *current_shape = RB_OBJ_SHAPE(obj);
16851685

16861686
if (UNLIKELY(rb_shape_too_complex_p(target_shape))) {
16871687
if (UNLIKELY(!rb_shape_too_complex_p(current_shape))) {
@@ -1964,7 +1964,7 @@ rb_vm_set_ivar_id(VALUE obj, ID id, VALUE val)
19641964
bool
19651965
rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id)
19661966
{
1967-
if (rb_shape_get_shape_id(obj) == shape_id) {
1967+
if (RB_OBJ_SHAPE_ID(obj) == shape_id) {
19681968
return false;
19691969
}
19701970

@@ -2119,7 +2119,7 @@ rb_ivar_defined(VALUE obj, ID id)
21192119
return Qtrue;
21202120
}
21212121
else {
2122-
return RBOOL(rb_shape_get_iv_index(rb_shape_get_shape(obj), id, &index));
2122+
return RBOOL(rb_shape_get_iv_index(RB_OBJ_SHAPE(obj), id, &index));
21232123
}
21242124
}
21252125

@@ -2206,7 +2206,7 @@ obj_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, b
22062206
.ivar_only = ivar_only,
22072207
};
22082208

2209-
rb_shape_t *shape = rb_shape_get_shape(obj);
2209+
rb_shape_t *shape = RB_OBJ_SHAPE(obj);
22102210
if (rb_shape_too_complex_p(shape)) {
22112211
rb_st_foreach(ROBJECT_FIELDS_HASH(obj), each_hash_iv, (st_data_t)&itr_data);
22122212
}
@@ -2218,7 +2218,7 @@ obj_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, b
22182218
static void
22192219
gen_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, bool ivar_only)
22202220
{
2221-
rb_shape_t *shape = rb_shape_get_shape(obj);
2221+
rb_shape_t *shape = RB_OBJ_SHAPE(obj);
22222222
struct gen_fields_tbl *fields_tbl;
22232223
if (!rb_gen_fields_tbl_get(obj, 0, &fields_tbl)) return;
22242224

@@ -2243,7 +2243,7 @@ class_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg,
22432243
{
22442244
RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
22452245

2246-
rb_shape_t *shape = rb_shape_get_shape(obj);
2246+
rb_shape_t *shape = RB_OBJ_SHAPE(obj);
22472247
struct iv_itr_data itr_data = {
22482248
.obj = obj,
22492249
.arg = arg,
@@ -2276,7 +2276,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
22762276
goto clear;
22772277
}
22782278

2279-
rb_shape_t *src_shape = rb_shape_get_shape(obj);
2279+
rb_shape_t *src_shape = RB_OBJ_SHAPE(obj);
22802280

22812281
if (rb_gen_fields_tbl_get(obj, 0, &obj_fields_tbl)) {
22822282
if (gen_fields_tbl_count(obj, obj_fields_tbl) == 0)
@@ -2297,7 +2297,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
22972297
}
22982298

22992299
rb_shape_t *shape_to_set_on_dest = src_shape;
2300-
rb_shape_t *initial_shape = rb_shape_get_shape(dest);
2300+
rb_shape_t *initial_shape = RB_OBJ_SHAPE(dest);
23012301

23022302
if (!rb_shape_canonical_p(src_shape)) {
23032303
RUBY_ASSERT(initial_shape->type == SHAPE_ROOT);
@@ -4586,7 +4586,7 @@ rb_fields_tbl_copy(VALUE dst, VALUE src)
45864586
RUBY_ASSERT(rb_type(dst) == rb_type(src));
45874587
RUBY_ASSERT(RB_TYPE_P(dst, T_CLASS) || RB_TYPE_P(dst, T_MODULE));
45884588

4589-
RUBY_ASSERT(rb_shape_get_shape(dst)->type == SHAPE_ROOT);
4589+
RUBY_ASSERT(RB_OBJ_SHAPE(dst)->type == SHAPE_ROOT);
45904590
RUBY_ASSERT(!RCLASS_FIELDS(dst));
45914591

45924592
rb_ivar_foreach(src, tbl_copy_i, dst);

yjit/bindgen/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn main() {
9494
.allowlist_function("rb_bug")
9595

9696
// From shape.h
97-
.allowlist_function("rb_shape_get_shape_id")
97+
.allowlist_function("RB_OBJ_SHAPE_ID")
9898
.allowlist_function("RSHAPE")
9999
.allowlist_function("rb_shape_id_offset")
100100
.allowlist_function("rb_shape_get_iv_index")

yjit/src/codegen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,7 +2909,7 @@ fn gen_get_ivar(
29092909
// Compile time self is embedded and the ivar index lands within the object
29102910
let embed_test_result = unsafe { FL_TEST_RAW(comptime_receiver, VALUE(ROBJECT_EMBED.as_usize())) != VALUE(0) };
29112911

2912-
let expected_shape = unsafe { rb_shape_get_shape_id(comptime_receiver) };
2912+
let expected_shape = unsafe { RB_OBJ_SHAPE_ID(comptime_receiver) };
29132913
let shape_id_offset = unsafe { rb_shape_id_offset() };
29142914
let shape_opnd = Opnd::mem(SHAPE_ID_NUM_BITS as u8, recv, shape_id_offset);
29152915

@@ -3187,7 +3187,7 @@ fn gen_set_ivar(
31873187
// Upgrade type
31883188
guard_object_is_heap(asm, recv, recv_opnd, Counter::setivar_not_heap);
31893189

3190-
let expected_shape = unsafe { rb_shape_get_shape_id(comptime_receiver) };
3190+
let expected_shape = unsafe { RB_OBJ_SHAPE_ID(comptime_receiver) };
31913191
let shape_id_offset = unsafe { rb_shape_id_offset() };
31923192
let shape_opnd = Opnd::mem(SHAPE_ID_NUM_BITS as u8, recv, shape_id_offset);
31933193

yjit/src/cruby.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl VALUE {
445445
}
446446

447447
pub fn shape_id_of(self) -> u32 {
448-
unsafe { rb_shape_get_shape_id(self) }
448+
unsafe { RB_OBJ_SHAPE_ID(self) }
449449
}
450450

451451
pub fn shape_of(self) -> *mut rb_shape {

0 commit comments

Comments
 (0)