Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into Ractor-Local-GC-v…
Browse files Browse the repository at this point in the history
…ersion-2
  • Loading branch information
rm155 committed Mar 27, 2024
2 parents 814f4b8 + c50b642 commit c9fa9f1
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12524,17 +12524,26 @@ static int
update_obj_id_mapping(rb_objspace_t *objspace, RVALUE *dest, RVALUE *src, st_data_t *srcid, st_data_t *id)
{
rb_native_mutex_lock(&objspace->obj_id_lock);
int id_found = st_lookup(objspace->obj_to_id_tbl, *srcid, id);
if (id_found) {
if (FL_TEST((VALUE)src, FL_SEEN_OBJ_ID)) {
/* If the source object's object_id has been seen, we need to update
* the object to object id mapping. */
st_data_t srcid = (st_data_t)src, id;

gc_report(4, objspace, "Moving object with seen id: %p -> %p\n", (void *)src, (void *)dest);
/* Resizing the st table could cause a malloc */
DURING_GC_COULD_MALLOC_REGION_START();
{
st_delete(objspace->obj_to_id_tbl, srcid, 0);
st_insert(objspace->obj_to_id_tbl, (st_data_t)dest, *id);
if (!st_delete(objspace->obj_to_id_tbl, &srcid, &id)) {
rb_bug("gc_move: object ID seen, but not in mapping table: %s", obj_info((VALUE)src));
}

st_insert(objspace->obj_to_id_tbl, (st_data_t)dest, id);
}
DURING_GC_COULD_MALLOC_REGION_END();
}
else {
GC_ASSERT(!st_lookup(objspace->obj_to_id_tbl, (st_data_t)src, NULL));
}
rb_native_mutex_unlock(&objspace->obj_id_lock);
return id_found;
}
Expand Down Expand Up @@ -12578,10 +12587,6 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, s
DURING_GC_COULD_MALLOC_REGION_END();
}

st_data_t srcid = (st_data_t)src, id;

/* If the source object's object_id has been seen, we need to update
* the object to object id mapping. */
update_obj_id_mapping(objspace, dest, src, &srcid, &id);

#if VM_CHECK_MODE > 0
Expand Down

0 comments on commit c9fa9f1

Please sign in to comment.