未验证 提交 df8e7e89 编写于 作者: A Aleksey Kliger (λgeek) 提交者: GitHub

[hot_reload] Check for added fields earlier in compute_class_bitmap (#89121)

Added fields don't contribute to the class bitmap, and they also might not have their type resolved yet - move the "is from update" check before we need to access the field's type

Fixes #86172

* Add regression test

* [hot_reload] Check for added fields earlier in compute_class_bitmap and in mono_class_create_runtime_vtable
上级 74d69fda
......@@ -19,4 +19,11 @@ public class AddStaticField
}
}
public class AddStaticField2
{
public static int Test()
{
return -1;
}
}
}
......@@ -22,4 +22,13 @@ public class AddStaticField
}
}
public class AddStaticField2
{
private static int A {get; set;}
public static int Test()
{
A = 11;
return A + A;
}
}
}
......@@ -302,6 +302,9 @@ public static void TestAddStaticField()
string result = x.GetField;
Assert.Equal("4567", result);
int aa = System.Reflection.Metadata.ApplyUpdate.Test.AddStaticField2.Test();
Assert.Equal(22, aa);
});
}
......
......@@ -834,6 +834,11 @@ compute_class_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int
while ((field = mono_class_get_fields_internal (p, &iter))) {
MonoType *type;
/* metadata-update: added fields aren't stored in the object, don't
* contribute to the GC descriptor. */
if (m_field_is_from_update (field))
continue;
if (static_fields) {
if (!(field->type->attrs & (FIELD_ATTRIBUTE_STATIC | FIELD_ATTRIBUTE_HAS_FIELD_RVA)))
continue;
......@@ -847,11 +852,6 @@ compute_class_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int
if (m_type_is_byref (field->type))
break;
/* metadadta-update: added fields aren't stored in the object, don't
* contribute to the GC descriptor. */
if (m_field_is_from_update (field))
continue;
int field_offset = m_field_get_offset (field);
if (static_fields && (field->offset == -1 || field->offset == -2))
......@@ -2211,13 +2211,13 @@ mono_class_create_runtime_vtable (MonoClass *klass, MonoError *error)
iter = NULL;
while ((field = mono_class_get_fields_internal (klass, &iter))) {
/* metadata-update: added fields are stored external to the object, and don't contribute to the bitmap */
if (m_field_is_from_update (field))
continue;
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
if (mono_field_is_deleted (field))
continue;
/* metadata-update: added fields are stored external to the object, and don't contribute to the bitmap */
if (m_field_is_from_update (field))
continue;
if (!(field->type->attrs & FIELD_ATTRIBUTE_LITERAL)) {
gint32 special_static = m_class_has_no_special_static_fields (klass) ? SPECIAL_STATIC_NONE : field_is_special_static (klass, field);
if (special_static != SPECIAL_STATIC_NONE) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册