Skip to content

Commit

Permalink
AOT the cctor of generic classes which are referenced by SFLDA patche…
Browse files Browse the repository at this point in the history
…s and superclasses of generic instances. Fixes mono#2155
  • Loading branch information
vargaz committed Dec 5, 2011
1 parent abc05b7 commit 83e5c48
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mono/mini/aot-compiler.c
Expand Up @@ -2920,6 +2920,10 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth)
add_method (acfg, method);
}

/* Add superclasses */
if (klass->parent)
add_generic_class_with_depth (acfg, klass->parent, depth);

/*
* For ICollection<T>, add instances of the helper methods
* in Array, since a T[] could be cast to ICollection<T>.
Expand Down Expand Up @@ -4907,6 +4911,14 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
add_generic_class_with_depth (acfg, klass, depth + 5);
break;
}
case MONO_PATCH_INFO_SFLDA: {
MonoClass *klass = patch_info->data.field->parent;

/* The .cctor needs to run at runtime. */
if (klass->generic_class && !mono_generic_context_is_sharable (&klass->generic_class->context, FALSE) && mono_class_get_cctor (klass))
add_extra_method_with_depth (acfg, mono_class_get_cctor (klass), depth + 1);
break;
}
default:
break;
}
Expand Down

0 comments on commit 83e5c48

Please sign in to comment.