Skip to content

Commit defc6bc

Browse files
committed
Cleanup write barriers for static fields
1 parent 0ef3ae3 commit defc6bc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mono/metadata/object.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,9 +2084,11 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
20842084
/* it's a pointer type: add check */
20852085
g_assert ((fklass->byval_arg.type == MONO_TYPE_PTR) || (fklass->byval_arg.type == MONO_TYPE_FNPTR));
20862086
*t = *(char *)data;
2087+
/* This is not needed by sgen, as it does not seem
2088+
+ to need write barriers for uncollectable objects (like the vtables storing static
2089+
+ fields), but it is needed for incremental boehm. */
2090+
mono_gc_wbarrier_generic_nostore(t);
20872091
}
2088-
// can probably be in else clause above:
2089-
mono_gc_wbarrier_generic_nostore(t);
20902092
continue;
20912093
}
20922094
}
@@ -3296,7 +3298,11 @@ mono_field_static_set_value (MonoVTable *vt, MonoClassField *field, void *value)
32963298
dest = (char*)mono_vtable_get_static_field_data (vt) + field->offset;
32973299
}
32983300
mono_copy_value (field->type, dest, value, FALSE);
3299-
mono_gc_wbarrier_generic_nostore(dest);
3301+
/* This is not needed by sgen, as it does not seem
3302+
to need write barriers for uncollectable objects (like the vtables storing static
3303+
+ fields), but it is needed for incremental boehm. */
3304+
if (field->offset == -1)
3305+
mono_gc_wbarrier_generic_nostore(dest);
33003306
}
33013307

33023308
/**
@@ -3334,7 +3340,6 @@ mono_field_get_addr (MonoObject *obj, MonoVTable *vt, MonoClassField *field)
33343340
src = (guint8 *)mono_get_special_static_data (GPOINTER_TO_UINT (addr));
33353341
} else {
33363342
src = (guint8*)mono_vtable_get_static_field_data (vt) + field->offset;
3337-
mono_gc_wbarrier_generic_nostore(src);
33383343
}
33393344
} else {
33403345
src = (guint8*)obj + field->offset;

0 commit comments

Comments
 (0)