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 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
2 changes: 1 addition & 1 deletion src/tools/crossgen2/Common/Compiler/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Logger

public Logger(TextWriter writer, bool isVerbose)
{
Writer = writer;
Writer = TextWriter.Synchronized(writer);
IsVerbose = isVerbose;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;

using ILCompiler.DependencyAnalysis;
using System.Threading;

using Internal.JitInterface;
using Internal.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
Expand All @@ -25,9 +25,9 @@ public class ModuleTokenResolver
/// Reverse lookup table mapping external types to reference tokens in the input modules. The table
/// gets lazily initialized as various tokens are resolved in CorInfoImpl.
/// </summary>
private readonly Dictionary<EcmaType, ModuleToken> _typeToRefTokens = new Dictionary<EcmaType, ModuleToken>();
private readonly ConcurrentDictionary<EcmaType, ModuleToken> _typeToRefTokens = new ConcurrentDictionary<EcmaType, ModuleToken>();

private readonly Dictionary<FieldDesc, ModuleToken> _fieldToRefTokens = new Dictionary<FieldDesc, ModuleToken>();
private readonly ConcurrentDictionary<FieldDesc, ModuleToken> _fieldToRefTokens = new ConcurrentDictionary<FieldDesc, ModuleToken>();

private readonly CompilationModuleGroup _compilationModuleGroup;

Expand Down Expand Up @@ -163,6 +163,7 @@ public void AddModuleTokenForField(FieldDesc field, ModuleToken token)
}

_fieldToRefTokens[canonField] = token;

switch (token.TokenType)
{
case CorTokenType.mdtMemberRef:
Expand Down
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);
}
}
}
Loading