Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,8 @@ protected void OutputGenericInstantiationDetails(NodeFactory factory, ref Object
&& factory.MetadataManager.IsTypeInstantiationReflectionVisible(_type))
{
compositionNode = _type.Instantiation.Length > 1
? factory.ConstructedGenericComposition(_type.Instantiation)
: factory.MaximallyConstructableType(_type.Instantiation[0]);
? factory.MetadataEnabledGenericComposition(_type.Instantiation)
: factory.MaximallyMetadataEnabledType(_type.Instantiation[0]);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ namespace ILCompiler.DependencyAnalysis
public class GenericCompositionNode : ObjectNode, ISymbolDefinitionNode
{
private readonly Instantiation _details;
private readonly bool _constructed;
private readonly bool _metadataEnabled;

internal GenericCompositionNode(Instantiation details, bool constructed)
internal GenericCompositionNode(Instantiation details, bool metadataEnabled)
{
_details = details;
_constructed = constructed;
_metadataEnabled = metadataEnabled;
}

public override bool ShouldSkipEmittingObjectNode(NodeFactory factory) => !_constructed && factory.ConstructedGenericComposition(_details).Marked;
public override bool ShouldSkipEmittingObjectNode(NodeFactory factory) => !_metadataEnabled && factory.MetadataEnabledGenericComposition(_details).Marked;

public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
{
Expand Down Expand Up @@ -66,7 +66,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)

foreach (var typeArg in _details)
{
IEETypeNode node = _constructed ? factory.MaximallyConstructableType(typeArg) : factory.NecessaryTypeSymbol(typeArg);
IEETypeNode node = _metadataEnabled ? factory.MaximallyMetadataEnabledType(typeArg) : factory.NecessaryTypeSymbol(typeArg);

if (useRelativePointers)
builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_RELPTR32);
Expand All @@ -87,7 +87,7 @@ public override int CompareToImpl(ISortableNode other, CompilerComparer comparer
if (compare != 0)
return compare;

compare = _constructed.CompareTo(otherComposition._constructed);
compare = _metadataEnabled.CompareTo(otherComposition._metadataEnabled);
if (compare != 0)
return compare;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly)
if (factory.Target.SupportsRelativePointers)
{
builder.EmitReloc(factory.MaximallyConstructableType(targetMethod.OwningType), RelocType.IMAGE_REL_BASED_RELPTR32);
builder.EmitReloc(factory.ConstructedGenericComposition(targetMethod.Instantiation), RelocType.IMAGE_REL_BASED_RELPTR32);
builder.EmitReloc(factory.MetadataEnabledGenericComposition(targetMethod.Instantiation), RelocType.IMAGE_REL_BASED_RELPTR32);
builder.EmitInt(flagsAndToken);
}
else
{
builder.EmitPointerReloc(factory.MaximallyConstructableType(targetMethod.OwningType));
builder.EmitPointerReloc(factory.ConstructedGenericComposition(targetMethod.Instantiation));
builder.EmitPointerReloc(factory.MetadataEnabledGenericComposition(targetMethod.Instantiation));
builder.EmitNaturalInt(flagsAndToken);
}

Expand Down Expand Up @@ -93,7 +93,7 @@ public static IEnumerable<DependencyListEntry> GetCellDependencies(NodeFactory f
factory.MetadataManager.GetNativeLayoutMetadataDependencies(ref result, factory, GetMethodForMetadata(targetMethod, out _));

result.Add(factory.MaximallyConstructableType(targetMethod.OwningType), "Owning type of GVM decl");
result.Add(factory.ConstructedGenericComposition(targetMethod.Instantiation), "GVM instantiation info");
result.Add(factory.MetadataEnabledGenericComposition(targetMethod.Instantiation), "GVM instantiation info");

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,12 @@ private void CreateNodeCaches()

_genericCompositions = new NodeCache<Instantiation, GenericCompositionNode>((Instantiation details) =>
{
return new GenericCompositionNode(details, constructed: false);
return new GenericCompositionNode(details, metadataEnabled: false);
});

_constructedGenericCompositions = new NodeCache<Instantiation, GenericCompositionNode>((Instantiation details) =>
_metadataEnabledGenericCompositions = new NodeCache<Instantiation, GenericCompositionNode>((Instantiation details) =>
{
return new GenericCompositionNode(details, constructed: true);
return new GenericCompositionNode(details, metadataEnabled: true);
});

_genericVariances = new NodeCache<GenericVarianceDetails, GenericVarianceNode>((GenericVarianceDetails details) =>
Expand Down Expand Up @@ -817,6 +817,14 @@ public IEETypeNode MaximallyConstructableType(TypeDesc type)
return NecessaryTypeSymbol(type);
}

public IEETypeNode MaximallyMetadataEnabledType(TypeDesc type)
{
if (type.IsCanonicalDefinitionType(CanonicalFormKind.Any))
return NecessaryTypeSymbol(type);
else
return MetadataTypeSymbol(type);
Comment thread
MichalStrehovsky marked this conversation as resolved.
}

private NodeCache<TypeDesc, IEETypeNode> _importedTypeSymbols;

private IEETypeNode ImportedEETypeSymbol(TypeDesc type)
Expand Down Expand Up @@ -966,11 +974,11 @@ internal ISymbolNode GenericComposition(Instantiation details)
return _genericCompositions.GetOrAdd(details);
}

private NodeCache<Instantiation, GenericCompositionNode> _constructedGenericCompositions;
private NodeCache<Instantiation, GenericCompositionNode> _metadataEnabledGenericCompositions;

internal ISymbolNode ConstructedGenericComposition(Instantiation details)
internal ISymbolNode MetadataEnabledGenericComposition(Instantiation details)
{
return _constructedGenericCompositions.GetOrAdd(details);
return _metadataEnabledGenericCompositions.GetOrAdd(details);
}

private NodeCache<GenericVarianceDetails, GenericVarianceNode> _genericVariances;
Expand Down
Loading