Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Preparation to introduce parallelism into CrossGen2 #27068

Merged
merged 3 commits into from
Oct 16, 2019
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 @@ -83,5 +83,22 @@ public ModuleToken GetModuleTokenForField(FieldDesc field, bool throwIfNotFound
{
return Resolver.GetModuleTokenForField(field, throwIfNotFound);
}

public bool Equals(SignatureContext other)

Choose a reason for hiding this comment

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

Nit: there shouldn't be a need for this, and we can just have the Equals(object) API. The other key structs have it because they implement IEquatable, because they are all structs and the IEquatable is the way to avoid boxing/unboxing, but SignatureContext is a class.
It's fine to leave this the way it is. This is just a FYI comment

{
return GlobalContext == other.GlobalContext
&& LocalContext == other.LocalContext;
}

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

public override int GetHashCode()
{
return GlobalContext.GetHashCode()
^ (LocalContext.GetHashCode() * 31);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,11 @@ public ReadyToRunCodegenNodeFactory(
if (!win32Resources.IsEmpty)
Win32ResourcesNode = new Win32ResourcesNode(win32Resources);

CreateCodegenNodeCaches();
CreateNodeCaches();
}

private void CreateCodegenNodeCaches()
private void CreateNodeCaches()
{

// Create node caches
fadimounir marked this conversation as resolved.
Show resolved Hide resolved
_constructedHelpers = new NodeCache<ReadyToRunHelper, ISymbolNode>(CreateReadyToRunHelperCell);

Expand Down Expand Up @@ -488,7 +487,6 @@ public override int GetHashCode()
{
return FixupKind.GetHashCode() ^ TypeAndMethod.GetHashCode();
}

}
fadimounir marked this conversation as resolved.
Show resolved Hide resolved

private NodeCache<MethodFixupKey, MethodFixupSignature> _methodSignatures;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public sealed class ReadyToRunSymbolNodeFactory
public ReadyToRunSymbolNodeFactory(ReadyToRunCodegenNodeFactory codegenNodeFactory)
{
_codegenNodeFactory = codegenNodeFactory;
CreateSymbolNodeCaches();
CreateNodeCaches();
}

private void CreateSymbolNodeCaches()
private void CreateNodeCaches()
{
_importStrings = new NodeCache<ModuleTokenAndSignatureContext, ISymbolNode>(key =>
{
Expand Down Expand Up @@ -203,7 +203,9 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
return Id.GetHashCode() ^ (SignatureContext.GetHashCode() * 31);
return Id.GetHashCode()
^ (Target.GetHashCode() * 23)
^ (SignatureContext.GetHashCode() * 31);
}
fadimounir marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
Expand All @@ -14,7 +15,6 @@
using Internal.TypeSystem;
using Internal.TypeSystem.Ecma;
using Internal.TypeSystem.Interop;
using System.Collections.Concurrent;

namespace ILCompiler
{
Expand Down