8000 Get rid of SHAPE_T_OBJECT by casperisfine · Pull Request #13556 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

Get rid of SHAPE_T_OBJECT #13556

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 9 commits into from
Jun 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ext/objspace/objspace_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,6 @@ shape_id_i(shape_id_t shape_id, void *data)
dump_append(dc, ",\"edge_name\":");
dump_append_id(dc, shape->edge_name);

break;
case SHAPE_T_OBJECT:
dump_append(dc, ", \"shape_type\":\"T_OBJECT\"");
break;
case SHAPE_OBJ_ID:
dump_append(dc, ", \"shape_type\":\"OBJ_ID\"");
Expand Down
14 changes: 2 additions & 12 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,19 +381,9 @@ rb_gc_set_shape(VALUE obj, uint32_t shape_id)
uint32_t
rb_gc_rebuild_shape(VALUE obj, size_t heap_id)
{
shape_id_t orig_shape_id = rb_obj_shape_id(obj);
if (rb_shape_too_complex_p(orig_shape_id)) {
return (uint32_t)orig_shape_id;
}

shape_id_t initial_shape_id = rb_shape_root(heap_id);
shape_id_t new_shape_id = rb_shape_traverse_from_new_root(initial_shape_id, orig_shape_id);

if (new_shape_id == INVALID_SHAPE_ID) {
return 0;
}
RUBY_ASSERT(RB_TYPE_P(obj, T_OBJECT));

return (uint32_t)new_shape_id;
return (uint32_t)rb_shape_transition_heap(obj, heap_id);
}

void rb_vm_update_references(void *ptr);
Expand Down
2 changes: 1 addition & 1 deletion internal/variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int rb_gen_fields_tbl_get(VALUE obj, ID id, struct gen_fields_tbl **fields_tbl);
void rb_obj_copy_ivs_to_hash_table(VALUE obj, st_table *table);
void rb_obj_init_too_complex(VALUE obj, st_table *table);
void rb_evict_ivars_to_hash(VALUE obj);
void rb_evict_fields_to_hash(VALUE obj);
shape_id_t rb_evict_fields_to_hash(VALUE obj);
VALUE rb_obj_field_get(VALUE obj, shape_id_t target_shape_id);
void rb_ivar_set_internal(VALUE obj, ID id, VALUE val);
void rb_obj_field_set(VALUE obj, shape_id_t target_shape_id, VALUE val);
Expand Down
16 changes: 7 additions & 9 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,15 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
shape_id_t dest_shape_id = src_shape_id;
shape_id_t initial_shape_id = RBASIC_SHAPE_ID(dest);

if (RSHAPE(initial_shape_id)->heap_index != RSHAPE(src_shape_id)->heap_index || !rb_shape_canonical_p(src_shape_id)) {
RUBY_ASSERT(RSHAPE(initial_shape_id)->type == SHAPE_T_OBJECT);
RUBY_ASSERT(RSHAPE(initial_shape_id)->type == SHAPE_ROOT);

dest_shape_id = rb_shape_rebuild(initial_shape_id, src_shape_id);
if (UNLIKELY(rb_shape_too_complex_p(dest_shape_id))) {
st_table *table = rb_st_init_numtable_with_size(src_num_ivs);
rb_obj_copy_ivs_to_hash_table(obj, table);
rb_obj_init_too_complex(dest, table);
dest_shape_id = rb_shape_rebuild(initial_shape_id, src_shape_id);
if (UNLIKELY(rb_shape_too_complex_p(dest_shape_id))) {
st_table *table = rb_st_init_numtable_with_size(src_num_ivs);
rb_obj_copy_ivs_to_hash_table(obj, table);
rb_obj_init_too_complex(dest, table);

return;
}
return;
}

VALUE *src_buf = ROBJECT_FIELDS(obj);
Expand Down
Loading
Loading
0