Skip to content

Commit 041450a

Browse files
committed
rb_ivar_delete: also re-embed T_IMEMO/fields
Right now JITs don't generate any code to access ivar on types other than T_OBJECT, but they might soon, so we must ensure two IMEMO/fields can't have the same `shape_id` but diffent embed/heap status.
1 parent fa3c23e commit 041450a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

variable.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,12 +1614,12 @@ rb_ivar_delete(VALUE obj, ID id, VALUE undef)
16141614
MEMMOVE(&fields[removed_index], &fields[removed_index + 1], VALUE, trailing_fields);
16151615
RBASIC_SET_SHAPE_ID(fields_obj, next_shape_id);
16161616

1617-
if (type == T_OBJECT && FL_TEST_RAW(obj, ROBJECT_HEAP) && rb_obj_embedded_size(new_fields_count) <= rb_gc_obj_slot_size(obj)) {
1617+
if (FL_TEST_RAW(fields_obj, OBJ_FIELD_HEAP) && rb_obj_embedded_size(new_fields_count) <= rb_gc_obj_slot_size(fields_obj)) {
16181618
// Re-embed objects when instances become small enough
16191619
// This is necessary because YJIT assumes that objects with the same shape
16201620
// have the same embeddedness for efficiency (avoid extra checks)
1621-
FL_UNSET_RAW(obj, ROBJECT_HEAP);
1622-
MEMCPY(ROBJECT_FIELDS(obj), fields, VALUE, new_fields_count);
1621+
FL_UNSET_RAW(fields_obj, ROBJECT_HEAP);
1622+
MEMCPY(rb_imemo_fields_ptr(fields_obj), fields, VALUE, new_fields_count);
16231623
xfree(fields);
16241624
}
16251625
}

0 commit comments

Comments
 (0)