DEBUG (9, fprintf (gc_debug_file, " (to %p, %s size: %lu)\n", destination, ((MonoObject*)obj)->vtable->klass->name, (unsigned long)objsize));
binary_protocol_copy (obj, destination, vt, objsize);
- *(MonoVTable**)destination = vt;
if (objsize <= sizeof (gpointer) * 8) {
mword *dest = (mword*)destination;
goto *copy_labels [objsize / sizeof (gpointer)];
return;
}
+ *(MonoVTable**)destination = vt;
+
if (SGEN_CAS_PTR ((void*)obj, (void*)((mword)destination | SGEN_FORWARDED_BIT), vt) == vt) {
par_copy_object_no_checks (destination, vt, obj, objsize, has_references ? queue : NULL);
obj = destination;
return obj;
}
+ *(MonoVTable**)destination = vt;
par_copy_object_no_checks (destination, vt, obj, objsize, has_references ? queue : NULL);
/* set the forwarding pointer */
return;
}
+ /*
+ * We do this before the CAS because we want to make
+ * sure that if another thread sees the destination
+ * pointer the VTable is already in place. Not doing
+ * this can crash binary protocols.
+ */
+ *(MonoVTable**)destination = vt;
+
if (SGEN_CAS_PTR (obj, (void*)((mword)destination | SGEN_FORWARDED_BIT), vt) == vt) {
gboolean was_marked;