未验证 提交 8c1512cf 编写于 作者: M Michal Strehovský 提交者: GitHub

Do not run validation on runtime determined types (#1357)

It doesn't seem like we validate anything for those and `IsRuntimeDeterminedSubtype` check is rather expensive.
上级 9b4eece6
......@@ -76,14 +76,11 @@ private static TypeDesc EnsureLoadableTypeUncached(TypeDesc type)
ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadGeneral, type);
}
if (!parameterType.IsRuntimeDeterminedSubtype)
LayoutInt elementSize = parameterType.GetElementSize();
if (!elementSize.IsIndeterminate && elementSize.AsInt >= ushort.MaxValue)
{
LayoutInt elementSize = parameterType.GetElementSize();
if (!elementSize.IsIndeterminate && elementSize.AsInt >= ushort.MaxValue)
{
// Element size over 64k can't be encoded in the GCDesc
ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadValueClassTooLarge, parameterType);
}
// Element size over 64k can't be encoded in the GCDesc
ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadValueClassTooLarge, parameterType);
}
if (((ArrayType)parameterizedType).Rank > 32)
......@@ -105,17 +102,19 @@ private static TypeDesc EnsureLoadableTypeUncached(TypeDesc type)
{
ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadGeneral, type);
}
#if READYTORUN
else if (type.IsGenericParameter)
{
return type;
}
#endif
else
{
// Validate classes, structs, enums, interfaces, and delegates
Debug.Assert(type.IsDefType);
// Don't validate generic definitons or runtime determined subtypes
if (type.IsGenericDefinition || type.IsRuntimeDeterminedSubtype)
// Don't validate generic definitons
if (type.IsGenericDefinition)
{
return type;
}
......
......@@ -46,22 +46,6 @@ public class GenericLookupSignature : Signature
_fieldArgument = fieldArgument;
_methodContext = methodContext;
_signatureContext = signatureContext;
// Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature
if (typeArgument != null)
{
signatureContext.Resolver.CompilerContext.EnsureLoadableType(typeArgument);
}
if (fieldArgument != null)
{
signatureContext.Resolver.CompilerContext.EnsureLoadableType(fieldArgument.OwningType);
}
if (methodArgument != null)
{
signatureContext.Resolver.CompilerContext.EnsureLoadableMethod(methodArgument.Method);
if (methodArgument.ConstrainedType != null)
signatureContext.Resolver.CompilerContext.EnsureLoadableType(methodArgument.ConstrainedType);
}
}
public override int ClassCode => 258608008;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册