Skip to content

Commit 858d2df

Browse files
committed
Get rid of SHAPE_T_OBJECT
Now the `heap_index` is stored as flags inside `shape_id_t`. This saves having to rebuild the entire tree when moving from one slot size to the other.
1 parent ee3bf2a commit 858d2df

9 files changed

Lines changed: 135 additions & 158 deletions

File tree

ext/objspace/objspace_dump.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,6 @@ shape_id_i(shape_id_t shape_id, void *data)
817817
dump_append(dc, ",\"edge_name\":");
818818
dump_append_id(dc, shape->edge_name);
819819

820-
break;
821-
case SHAPE_T_OBJECT:
822-
dump_append(dc, ", \"shape_type\":\"T_OBJECT\"");
823820
break;
824821
case SHAPE_OBJ_ID:
825822
dump_append(dc, ", \"shape_type\":\"OBJ_ID\"");

gc.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -379,19 +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_obj_shape_id(obj);
383-
if (rb_shape_too_complex_p(orig_shape_id)) {
384-
return (uint32_t)orig_shape_id;
385-
}
386-
387-
shape_id_t initial_shape_id = rb_shape_root(heap_id);
388-
shape_id_t new_shape_id = rb_shape_traverse_from_new_root(initial_shape_id, orig_shape_id);
389-
390-
if (new_shape_id == INVALID_SHAPE_ID) {
391-
return 0;
392-
}
393-
394-
return (uint32_t)new_shape_id;
382+
return (uint32_t)rb_shape_transition_heap(obj, heap_id);
395383
}
396384

397385
void rb_vm_update_references(void *ptr);
@@ -1923,6 +1911,7 @@ object_id0(VALUE obj)
19231911
// rb_shape_object_id_shape may lock if the current shape has
19241912
// multiple children.
19251913
shape_id_t object_id_shape_id = rb_shape_transition_object_id(obj);
1914+
RUBY_ASSERT(rb_shape_has_object_id(object_id_shape_id));
19261915

19271916
id = generate_next_object_id();
19281917
rb_obj_field_set(obj, object_id_shape_id, id);

object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
339339
shape_id_t dest_shape_id = src_shape_id;
340340
shape_id_t initial_shape_id = RBASIC_SHAPE_ID(dest);
341341

342-
RUBY_ASSERT(RSHAPE(initial_shape_id)->type == SHAPE_T_OBJECT);
342+
RUBY_ASSERT(RSHAPE(initial_shape_id)->type == SHAPE_ROOT);
343343

344344
dest_shape_id = rb_shape_rebuild(initial_shape_id, src_shape_id);
345345
if (UNLIKELY(rb_shape_too_complex_p(dest_shape_id))) {
@@ -363,7 +363,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
363363
}
364364

365365
rb_shape_copy_fields(dest, dest_buf, dest_shape_id, obj, src_buf, src_shape_id);
366-
rb_obj_set_shape_id(dest, dest_shape_id);
366+
RBASIC_SET_SHAPE_ID(dest, dest_shape_id);
367367
}
368368

369369
static void

0 commit comments

Comments
 (0)