提交 6d15bc46 编写于 作者: Z Zoltan Varga 提交者: Mantas Puida

Detect inifinite generic recursion differently in the AOT compiler.

上级 4209a36a
......@@ -2307,6 +2307,34 @@ add_generic_class (MonoAotCompile *acfg, MonoClass *klass)
add_generic_class_with_depth (acfg, klass, 0);
}
static gboolean
check_type_depth (MonoType *t, int depth)
{
int i;
if (depth > 8)
return TRUE;
switch (t->type) {
case MONO_TYPE_GENERICINST: {
MonoGenericClass *gklass = t->data.generic_class;
MonoGenericInst *ginst = gklass->context.class_inst;
if (ginst) {
for (i = 0; i < ginst->type_argc; ++i) {
if (check_type_depth (ginst->type_argv [i], depth + 1))
return TRUE;
}
}
break;
}
default:
break;
}
return FALSE;
}
/*
* add_generic_class:
*
......@@ -2332,6 +2360,9 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth)
if (!klass->generic_class && !klass->rank)
return;
if (check_type_depth (&klass->byval_arg, 0))
return;
iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
if (mono_method_is_generic_sharable_impl (method, FALSE))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册