Skip to content
Merged
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 @@ -142,10 +142,7 @@ public virtual ISymbolNode GetFieldRvaData(FieldDesc field)
else
{
// Use the typical field definition in case this is an instantiated generic type
field = field.GetTypicalFieldDefinition();
int fieldTypePack = (field.FieldType as MetadataType)?.GetClassLayout().PackingSize ?? 1;
return NodeFactory.ReadOnlyDataBlob(NameMangler.GetMangledFieldName(field),
((EcmaField)field).GetFieldRvaData(), Math.Max(NodeFactory.Target.PointerSize, fieldTypePack));
return NodeFactory.FieldRvaData((EcmaField)field.GetTypicalFieldDefinition());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

using Internal.Text;
using Internal.TypeSystem;
using Internal.TypeSystem.Ecma;

using Debug = System.Diagnostics.Debug;

namespace ILCompiler.DependencyAnalysis
{
public class FieldRvaDataNode : ObjectNode, ISymbolDefinitionNode
{
private readonly EcmaField _field;

public FieldRvaDataNode(EcmaField field)
{
Debug.Assert(field.HasRva);
_field = field;
}

public override ObjectNodeSection Section => ObjectNodeSection.ReadOnlyDataSection;
public override bool StaticDependenciesAreComputed => true;

public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
{
sb.Append(nameMangler.GetMangledFieldName(_field));
}
public int Offset => 0;
public override bool IsShareable => true;

public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
int fieldTypePack = (_field.FieldType as MetadataType)?.GetClassLayout().PackingSize ?? 1;
byte[] data = relocsOnly ? Array.Empty<byte>() : _field.GetFieldRvaData();
return new ObjectData(
data,
Array.Empty<Relocation>(),
Math.Max(factory.Target.PointerSize, fieldTypePack),
new ISymbolDefinitionNode[] { this });
}

protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler);

#if !SUPPORT_JIT
public override int ClassCode => -456126;

public override int CompareToImpl(ISortableNode other, CompilerComparer comparer)
{
return comparer.Compare(_field, ((FieldRvaDataNode)other)._field);
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ private void CreateNodeCaches()
return new BlobNode(key.Name, ObjectNodeSection.ReadOnlyDataSection, key.Data, key.Alignment);
});

_fieldRvaDataBlobs = new NodeCache<Internal.TypeSystem.Ecma.EcmaField, FieldRvaDataNode>(key =>
{
return new FieldRvaDataNode(key);
});

_uninitializedWritableDataBlobs = new NodeCache<UninitializedWritableDataBlobKey, BlobNode>(key =>
{
return new BlobNode(key.Name, ObjectNodeSection.BssSection, new byte[key.Size], key.Alignment);
Expand Down Expand Up @@ -708,6 +713,14 @@ public BlobNode ReadOnlyDataBlob(Utf8String name, byte[] blobData, int alignment
{
return _readOnlyDataBlobs.GetOrAdd(new ReadOnlyDataBlobKey(name, blobData, alignment));
}

private NodeCache<Internal.TypeSystem.Ecma.EcmaField, FieldRvaDataNode> _fieldRvaDataBlobs;

public ISymbolNode FieldRvaData(Internal.TypeSystem.Ecma.EcmaField field)
{
return _fieldRvaDataBlobs.GetOrAdd(field);
}

private NodeCache<TypeDesc, SealedVTableNode> _sealedVtableNodes;

internal SealedVTableNode SealedVTable(TypeDesc type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
<Compile Include="Compiler\DependencyAnalysis\DynamicDependencyAttributeAlgorithm.cs" />
<Compile Include="Compiler\DependencyAnalysis\DynamicInvokeTemplateNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\ExternSymbolsImportedNodeProvider.cs" />
<Compile Include="Compiler\DependencyAnalysis\FieldRvaDataNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\IndirectionExtensions.cs" />
<Compile Include="Compiler\DependencyAnalysis\InterfaceDispatchCellSectionNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\MethodExceptionHandlingInfoNode.cs" />
Expand Down