Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -344,7 +344,7 @@ public ISymbolNode ComputeConstantLookup(ReadyToRunHelperId lookupKind, object t
case ReadyToRunHelperId.ObjectAllocator:
{
var type = (TypeDesc)targetOfLookup;
return NodeFactory.ExternSymbol(JitHelper.GetNewObjectHelperForType(type));
return NodeFactory.ExternFunctionSymbol(JitHelper.GetNewObjectHelperForType(type));
}

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ILCompiler.DependencyAnalysis
/// Represents a symbol that is defined externally but modelled as a type in the
/// DependencyAnalysis infrastructure during compilation.
/// </summary>
public sealed class ExternEETypeSymbolNode : ExternSymbolNode, IEETypeNode
public sealed class ExternEETypeSymbolNode : ExternDataSymbolNode, IEETypeNode
{
private TypeDesc _type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ILCompiler.DependencyAnalysis
/// Represents a symbol that is defined externally but modelled as a method
/// in the DependencyAnalysis infrastructure during compilation
/// </summary>
public sealed class ExternMethodSymbolNode : ExternSymbolNode, IMethodNode
public sealed class ExternMethodSymbolNode : ExternFunctionSymbolNode, IMethodNode
{
private MethodDesc _method;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ namespace ILCompiler.DependencyAnalysis
{
/// <summary>
/// Represents a symbol that is defined externally and statically linked to the output obj file.
/// When making a new node, do not derived from this class directly, derive from one of its subclasses
/// (ExternFunctionSymbolNode / ExternDataSymbolNode) instead.
/// </summary>
public class ExternSymbolNode : SortableDependencyNode, ISortableSymbolNode
public abstract class ExternSymbolNode : SortableDependencyNode, ISortableSymbolNode
{
private readonly Utf8String _name;
private readonly bool _isIndirection;

public ExternSymbolNode(Utf8String name, bool isIndirection = false)
protected ExternSymbolNode(Utf8String name, bool isIndirection = false)
{
_name = name;
_isIndirection = isIndirection;
Expand All @@ -29,6 +31,7 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
{
sb.Append(_name);
}

public int Offset => 0;
public virtual bool RepresentsIndirectionCell => _isIndirection;

Expand All @@ -42,8 +45,6 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
public override IEnumerable<CombinedDependencyListEntry> SearchDynamicDependencies(List<DependencyNodeCore<NodeFactory>> markedNodes, int firstNode, NodeFactory factory) => null;

#if !SUPPORT_JIT
public override int ClassCode => 1092559304;

public override int CompareToImpl(ISortableNode other, CompilerComparer comparer)
{
return _name.CompareTo(((ExternSymbolNode)other)._name);
Expand All @@ -56,11 +57,26 @@ public override string ToString()
}
}

public class AddressTakenExternSymbolNode : ExternSymbolNode
/// <summary>
/// Represents a function symbol that is defined externally and statically linked to the output obj file.
/// </summary>
public class ExternFunctionSymbolNode(Utf8String name, bool isIndirection = false) : ExternSymbolNode(name, isIndirection)
{
public AddressTakenExternSymbolNode(Utf8String name)
: base(name) { }
public override int ClassCode => 1452455506;
}

public class AddressTakenExternFunctionSymbolNode(Utf8String name) : ExternFunctionSymbolNode(name)
{
public override int ClassCode => -45645737;
}

/// <summary>
/// Represents a data symbol that is defined externally and statically linked to the output obj file.
/// </summary>
public class ExternDataSymbolNode(Utf8String name) : ExternSymbolNode(name)
{
public override int ClassCode => 1428609964;

protected override string GetName(NodeFactory factory) => $"ExternDataSymbolNode {ToString()}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public override IEETypeNode ImportedEETypeNode(NodeFactory factory, TypeDesc typ

public override ISortableSymbolNode ImportedGCStaticNode(NodeFactory factory, MetadataType type)
{
return new ExternSymbolNode(GCStaticsNode.GetMangledName(type, factory.NameMangler));
return new ExternDataSymbolNode(GCStaticsNode.GetMangledName(type, factory.NameMangler));
}

public override ISortableSymbolNode ImportedNonGCStaticNode(NodeFactory factory, MetadataType type)
{
return new ExternSymbolNode(NonGCStaticsNode.GetMangledName(type, factory.NameMangler));
return new ExternDataSymbolNode(NonGCStaticsNode.GetMangledName(type, factory.NameMangler));
}

public override ISortableSymbolNode ImportedMethodDictionaryNode(NodeFactory factory, MethodDesc method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ public ObjectAllocatorGenericLookupResult(TypeDesc type)
public override ISymbolNode GetTarget(NodeFactory factory, GenericLookupResultContext dictionary)
{
TypeDesc instantiatedType = _type.GetNonRuntimeDeterminedTypeFromRuntimeDeterminedSubtypeViaSubstitution(dictionary.TypeInstantiation, dictionary.MethodInstantiation);
return factory.ExternSymbol(JitHelper.GetNewObjectHelperForType(instantiatedType));
return factory.ExternFunctionSymbol(JitHelper.GetNewObjectHelperForType(instantiatedType));
}

public override void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public NodeFactory(
{
_target = context.Target;

InitialInterfaceDispatchStub = new AddressTakenExternSymbolNode("RhpInitialDynamicInterfaceDispatch");
InitialInterfaceDispatchStub = new AddressTakenExternFunctionSymbolNode("RhpInitialDynamicInterfaceDispatch");

_context = context;
_compilationModuleGroup = compilationModuleGroup;
Expand Down Expand Up @@ -263,13 +263,17 @@ private void CreateNodeCaches()
return new FieldRvaDataNode(key);
});

_externSymbols = new NodeCache<string, ExternSymbolNode>((string name) =>
_externFunctionSymbols = new NodeCache<string, ExternFunctionSymbolNode>((string name) =>
{
return new ExternSymbolNode(name);
return new ExternFunctionSymbolNode(name);
});
_externIndirectSymbols = new NodeCache<string, ExternSymbolNode>((string name) =>
_externIndirectFunctionSymbols = new NodeCache<string, ExternFunctionSymbolNode>((string name) =>
{
return new ExternSymbolNode(name, isIndirection: true);
return new ExternFunctionSymbolNode(name, isIndirection: true);
});
_externDataSymbols = new NodeCache<string, ExternDataSymbolNode>((string name) =>
{
return new ExternDataSymbolNode(name);
});

_pInvokeModuleFixups = new NodeCache<PInvokeModuleData, PInvokeModuleFixupNode>((PInvokeModuleData moduleData) =>
Expand Down Expand Up @@ -793,7 +797,7 @@ public ISortableSymbolNode TypeThreadStaticIndex(MetadataType type)
}
else
{
return ExternSymbol(NameMangler.NodeMangler.ThreadStaticsIndex(type));
return ExternDataSymbol(NameMangler.NodeMangler.ThreadStaticsIndex(type));
}
}

Expand Down Expand Up @@ -903,24 +907,31 @@ internal ISymbolNode GenericVariance(GenericVarianceDetails details)
return _genericVariances.GetOrAdd(details);
}

private NodeCache<string, ExternSymbolNode> _externSymbols;
private NodeCache<string, ExternFunctionSymbolNode> _externFunctionSymbols;

public ISortableSymbolNode ExternSymbol(string name)
public ISortableSymbolNode ExternFunctionSymbol(string name)
{
return _externSymbols.GetOrAdd(name);
return _externFunctionSymbols.GetOrAdd(name);
}

public ISortableSymbolNode ExternVariable(string name)
private NodeCache<string, ExternFunctionSymbolNode> _externIndirectFunctionSymbols;

public ISortableSymbolNode ExternIndirectFunctionSymbol(string name)
{
string mangledName = NameMangler.NodeMangler.ExternVariable(name);
return _externSymbols.GetOrAdd(mangledName);
return _externIndirectFunctionSymbols.GetOrAdd(name);
}

private NodeCache<string, ExternSymbolNode> _externIndirectSymbols;
private NodeCache<string, ExternDataSymbolNode> _externDataSymbols;

public ISortableSymbolNode ExternIndirectSymbol(string name)
public ISortableSymbolNode ExternDataSymbol(string name)
{
string mangledName = NameMangler.NodeMangler.ExternVariable(name);
return _externDataSymbols.GetOrAdd(mangledName);
}

public ISortableSymbolNode ExternVariable(string name)
{
return _externIndirectSymbols.GetOrAdd(name);
return _externDataSymbols.GetOrAdd(name);
}

private NodeCache<PInvokeModuleData, PInvokeModuleFixupNode> _pInvokeModuleFixups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ILCompiler.DependencyAnalysis
/// <summary>
/// Represents a method that is imported from the runtime library.
/// </summary>
public class RuntimeImportMethodNode : ExternSymbolNode, IMethodNode, ISymbolDefinitionNode
public class RuntimeImportMethodNode : ExternFunctionSymbolNode, IMethodNode, ISymbolDefinitionNode
{
private MethodDesc _method;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected override void EmitCode(NodeFactory factory, ref ARMEmitter encoder, bo
if (targetMethod.OwningType.IsInterface)
{
encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod));
encoder.EmitJMP(factory.ExternSymbol("RhpResolveInterfaceMethod"));
encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod"));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected override void EmitCode(NodeFactory factory, ref ARM64Emitter encoder,
if (targetMethod.OwningType.IsInterface)
{
encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod));
encoder.EmitJMP(factory.ExternSymbol("RhpResolveInterfaceMethod"));
encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod"));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected override void EmitCode(NodeFactory factory, ref LoongArch64Emitter enc
if (targetMethod.OwningType.IsInterface)
{
encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod));
encoder.EmitJMP(factory.ExternSymbol("RhpResolveInterfaceMethod"));
encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod"));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected override void EmitCode(NodeFactory factory, ref RiscV64Emitter encoder
if (targetMethod.OwningType.IsInterface)
{
encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod));
encoder.EmitJMP(factory.ExternSymbol("RhpResolveInterfaceMethod"));
encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod"));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected override void EmitCode(NodeFactory factory, ref X64Emitter encoder, bo
if (targetMethod.OwningType.IsInterface)
{
encoder.EmitLEAQ(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod));
encoder.EmitJMP(factory.ExternSymbol("RhpResolveInterfaceMethod"));
encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod"));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected override void EmitCode(NodeFactory factory, ref X86Emitter encoder, bo
if (targetMethod.OwningType.IsInterface)
{
encoder.EmitMOV(encoder.TargetRegister.Arg1, factory.InterfaceDispatchCell(targetMethod));
encoder.EmitJMP(factory.ExternSymbol("RhpResolveInterfaceMethod"));
encoder.EmitJMP(factory.ExternFunctionSymbol("RhpResolveInterfaceMethod"));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected override Helper CreateValueFromKey(ReadyToRunHelper key)

ISymbolNode entryPoint;
if (mangledName != null)
entryPoint = _compilation.NodeFactory.ExternSymbol(mangledName);
entryPoint = _compilation.NodeFactory.ExternFunctionSymbol(mangledName);
else
entryPoint = _compilation.NodeFactory.MethodEntrypoint(methodDesc);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private void EmitObject(string objectFilePath, IReadOnlyCollection<DependencyNod
relocTarget.Offset);

if (_options.HasFlag(ObjectWritingOptions.ControlFlowGuard) &&
relocTarget is IMethodNode or AssemblyStubNode or AddressTakenExternSymbolNode)
relocTarget is IMethodNode or AssemblyStubNode or AddressTakenExternFunctionSymbolNode)
{
// For now consider all method symbols address taken.
// We could restrict this in the future to those that are referenced from
Expand Down
Loading
Loading