Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Internal.TypeSystem;

namespace ILCompiler.DependencyAnalysis
{
internal struct TypeAndMethod : IEquatable<TypeAndMethod>
{
public readonly TypeDesc Type;
public readonly MethodDesc Method;
public readonly bool IsUnboxingStub;
public readonly bool IsInstantiatingStub;

public TypeAndMethod(TypeDesc type, MethodDesc method, bool isUnboxingStub, bool isInstantiatingStub)
{
Type = type;
Method = method;
IsUnboxingStub = isUnboxingStub;
IsInstantiatingStub = isInstantiatingStub;
}

public bool Equals(TypeAndMethod other)
{
return Type == other.Type &&
Method == other.Method &&
IsUnboxingStub == other.IsUnboxingStub &&
IsInstantiatingStub == other.IsInstantiatingStub;
}

public override bool Equals(object obj)
{
return obj is TypeAndMethod other && Equals(other);
}

public override int GetHashCode()
{
return (Type?.GetHashCode() ?? 0) ^ unchecked(Method.GetHashCode() * 31) ^ (IsUnboxingStub ? -0x80000000 : 0) ^ (IsInstantiatingStub ? 0x40000000 : 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public sealed class ReadyToRunCodegenCompilation : Compilation
private readonly string _inputFilePath;

public new ReadyToRunCodegenNodeFactory NodeFactory { get; }

public ReadyToRunSymbolNodeFactory SymbolNodeFactory { get; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether it might be more descriptive to call the new class "ReadyToRunHelperFactory".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably :)


internal ReadyToRunCodegenCompilation(
DependencyAnalyzerBase<NodeFactory> dependencyGraph,
ReadyToRunCodegenNodeFactory nodeFactory,
Expand All @@ -50,6 +53,7 @@ internal ReadyToRunCodegenCompilation(
: base(dependencyGraph, nodeFactory, roots, ilProvider, debugInformationProvider, devirtualizationManager, logger)
{
NodeFactory = nodeFactory;
SymbolNodeFactory = new ReadyToRunSymbolNodeFactory(nodeFactory);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is such a big hack. It will probably take several iterations to finish the transition, for now I believe this is just fine.

_corInfo = new Dictionary<EcmaModule, CorInfoImpl>();
_jitConfigProvider = configProvider;

Expand Down
2 changes: 2 additions & 0 deletions src/ILCompiler.ReadyToRun/src/ILCompiler.ReadyToRun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
<Compile Include="Compiler\DependencyAnalysis\ReadyToRun\Target_X86\ImportThunk.cs" />
<Compile Include="Compiler\DependencyAnalysis\ReadyToRun\TypeFixupSignature.cs" />
<Compile Include="Compiler\DependencyAnalysis\ReadyToRun\TypesTableNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\ReadyToRunSymbolNodeFactory.cs" />
<Compile Include="Compiler\DependencyAnalysis\TypeAndMethod.cs" />
<Compile Include="Compiler\ReadyToRunHashCode.cs" />
<Compile Include="Compiler\ReadyToRunLibraryRootProvider.cs" />
<Compile Include="Compiler\ReadyToRunCompilerContext.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void ComputeLookup(ref CORINFO_RESOLVED_TOKEN pResolvedToken, object ent
else
{
lookup.lookupKind.needsRuntimeLookup = false;
ISymbolNode constLookup = _compilation.NodeFactory.ComputeConstantLookup(helperId, entity, _signatureContext);
ISymbolNode constLookup = _compilation.SymbolNodeFactory.ComputeConstantLookup(helperId, entity, _signatureContext);
lookup.constLookup = CreateConstLookupToSymbol(constLookup);
}
}
Expand All @@ -122,7 +122,7 @@ private bool getReadyToRunHelper(ref CORINFO_RESOLVED_TOKEN pResolvedToken, ref
if (type.IsCanonicalSubtype(CanonicalFormKind.Any))
return false;

pLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.ReadyToRunHelper(ReadyToRunHelperId.NewHelper, type, _signatureContext));
pLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.ReadyToRunHelper(ReadyToRunHelperId.NewHelper, type, _signatureContext));
}
break;
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_NEWARR_1:
Expand All @@ -132,7 +132,7 @@ private bool getReadyToRunHelper(ref CORINFO_RESOLVED_TOKEN pResolvedToken, ref
if (type.IsCanonicalSubtype(CanonicalFormKind.Any))
return false;

pLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.ReadyToRunHelper(ReadyToRunHelperId.NewArr1, type, _signatureContext));
pLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.ReadyToRunHelper(ReadyToRunHelperId.NewArr1, type, _signatureContext));
}
break;
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_ISINSTANCEOF:
Expand All @@ -145,7 +145,7 @@ private bool getReadyToRunHelper(ref CORINFO_RESOLVED_TOKEN pResolvedToken, ref
if (type.IsNullable)
type = type.Instantiation[0];

pLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.ReadyToRunHelper(ReadyToRunHelperId.IsInstanceOf, type, _signatureContext));
pLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.ReadyToRunHelper(ReadyToRunHelperId.IsInstanceOf, type, _signatureContext));
}
break;
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_CHKCAST:
Expand All @@ -158,7 +158,7 @@ private bool getReadyToRunHelper(ref CORINFO_RESOLVED_TOKEN pResolvedToken, ref
if (type.IsNullable)
type = type.Instantiation[0];

pLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.ReadyToRunHelper(ReadyToRunHelperId.CastClass, type, _signatureContext));
pLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.ReadyToRunHelper(ReadyToRunHelperId.CastClass, type, _signatureContext));
}
break;
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_STATIC_BASE:
Expand All @@ -167,7 +167,7 @@ private bool getReadyToRunHelper(ref CORINFO_RESOLVED_TOKEN pResolvedToken, ref
if (type.IsCanonicalSubtype(CanonicalFormKind.Any))
return false;

pLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.ReadyToRunHelper(ReadyToRunHelperId.GetNonGCStaticBase, type, _signatureContext));
pLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.ReadyToRunHelper(ReadyToRunHelperId.GetNonGCStaticBase, type, _signatureContext));
}
break;
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE:
Expand Down Expand Up @@ -239,7 +239,7 @@ private void getReadyToRunDelegateCtorHelper(ref CORINFO_RESOLVED_TOKEN pTargetM
*/
{
pLookup.lookupKind.needsRuntimeLookup = false;
pLookup.constLookup = CreateConstLookupToSymbol(_compilation.NodeFactory.DelegateCtor(
pLookup.constLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.DelegateCtor(
delegateTypeDesc, targetMethod, _signatureContext));
}
}
Expand Down Expand Up @@ -523,7 +523,7 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum)
throw new NotImplementedException(ftnNum.ToString());
}

return _compilation.NodeFactory.ExternSymbol(id);
return _compilation.SymbolNodeFactory.ExternSymbol(id);
}

private void getFunctionEntryPoint(CORINFO_METHOD_STRUCT_* ftn, ref CORINFO_CONST_LOOKUP pResult, CORINFO_ACCESS_FLAGS accessFlags)
Expand All @@ -539,14 +539,14 @@ private void getFunctionEntryPoint(CORINFO_METHOD_STRUCT_* ftn, ref CORINFO_CONS

private InfoAccessType constructStringLiteral(CORINFO_MODULE_STRUCT_* module, mdToken metaTok, ref void* ppValue)
{
ISymbolNode stringObject = _compilation.NodeFactory.StringLiteral(new ModuleToken(_tokenContext, metaTok));
ISymbolNode stringObject = _compilation.SymbolNodeFactory.StringLiteral(new ModuleToken(_tokenContext, metaTok));
ppValue = (void*)ObjectToHandle(stringObject);
return InfoAccessType.IAT_PPVALUE;
}

public ISymbolNode ComputeConstantLookup(ReadyToRunHelperId helperId, object entity, SignatureContext signatureContext)
{
return _compilation.NodeFactory.ReadyToRunHelper(helperId, entity, signatureContext);
return _compilation.SymbolNodeFactory.ReadyToRunHelper(helperId, entity, signatureContext);
}

enum EHInfoFields
Expand Down
8 changes: 4 additions & 4 deletions src/JitInterface/src/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ private void getFieldInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_MET
{
pResult.fieldLookup = CreateConstLookupToSymbol(
#if READYTORUN
_compilation.NodeFactory.ReadyToRunHelper(helperId, field.OwningType, _signatureContext)
_compilation.SymbolNodeFactory.ReadyToRunHelper(helperId, field.OwningType, _signatureContext)
#else
_compilation.NodeFactory.ReadyToRunHelper(helperId, field.OwningType)
#endif
Expand Down Expand Up @@ -2683,7 +2683,7 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO
if (targetMethod.RequiresInstMethodDescArg())
{
#if READYTORUN
instParam = _compilation.NodeFactory.MethodGenericDictionary(concreteMethod, _signatureContext);
instParam = _compilation.SymbolNodeFactory.MethodGenericDictionary(concreteMethod, _signatureContext);
#else
instParam = _compilation.NodeFactory.MethodGenericDictionary(concreteMethod);
#endif
Expand All @@ -2692,7 +2692,7 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO
{
// Ask for a constructed type symbol because we need the vtable to get to the dictionary
#if READYTORUN
instParam = _compilation.NodeFactory.ConstructedTypeSymbol(concreteMethod.OwningType, _signatureContext);
instParam = _compilation.SymbolNodeFactory.ConstructedTypeSymbol(concreteMethod.OwningType, _signatureContext);
#else
instParam = _compilation.NodeFactory.ConstructedTypeSymbol(concreteMethod.OwningType);
#endif
Expand Down Expand Up @@ -2794,7 +2794,7 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO
pResult.codePointerOrStubLookup.constLookup.accessType = InfoAccessType.IAT_PVALUE;
pResult.codePointerOrStubLookup.constLookup.addr = (void*)ObjectToHandle(
#if READYTORUN
_compilation.NodeFactory.InterfaceDispatchCell(targetMethod, _signatureContext, isUnboxingStub: false
_compilation.SymbolNodeFactory.InterfaceDispatchCell(targetMethod, _signatureContext, isUnboxingStub: false
#else
_compilation.NodeFactory.InterfaceDispatchCell(targetMethod
#endif // READYTORUN
Expand Down