[opt] 优化 AOTReference计算,如果泛型的所有泛型参数都是class约束,则不加入到需要补充元数据的集合
parent
2b42376505
commit
a531a213c2
|
@ -191,11 +191,29 @@ namespace HybridCLR.Editor.AOT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsNotShareableAOTGenericType(TypeDef typeDef)
|
||||||
|
{
|
||||||
|
if (!IsAotType(typeDef))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return typeDef.GenericParameters.Any(c => !c.HasReferenceTypeConstraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsNotShareableAOTGenericMethod(MethodDef method)
|
||||||
|
{
|
||||||
|
if (!IsAotGenericMethod(method))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return method.GenericParameters.Concat(method.DeclaringType.GenericParameters).Any(c => !c.HasReferenceTypeConstraint);
|
||||||
|
}
|
||||||
|
|
||||||
private void FilterAOTGenericTypeAndMethods()
|
private void FilterAOTGenericTypeAndMethods()
|
||||||
{
|
{
|
||||||
ConstraintContext cc = this.ConstraintContext;
|
ConstraintContext cc = this.ConstraintContext;
|
||||||
AotGenericTypes.AddRange(_genericTypes.Where(type => IsAotType(type.Type)).Select(gc => cc.ApplyConstraints(gc)));
|
AotGenericTypes.AddRange(_genericTypes.Where(type => IsNotShareableAOTGenericType(type.Type)).Select(gc => cc.ApplyConstraints(gc)));
|
||||||
AotGenericMethods.AddRange(_genericMethods.Where(method => IsAotGenericMethod(method.Method)).Select(gm => cc.ApplyConstraints(gm)));
|
AotGenericMethods.AddRange(_genericMethods.Where(method => IsNotShareableAOTGenericMethod(method.Method)).Select(gm => cc.ApplyConstraints(gm)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
|
Loading…
Reference in New Issue