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

Commit

Permalink
Preparation to introduce parallelism into CrossGen2 (#27068)
Browse files Browse the repository at this point in the history
* Preparation to introduce parallelism into CrossGen2

- Change dictionaries in ReadyToRunCodegenNodeFactory and ReadyToRunSymbolNodeFactory to NodeCaches (i.e. ConcurrentDictionary, at the moment)
- Add structs to act as keys for the above NodeCaches (MethodFixupKey, DynamicHelperKey, ReadyToRunHelperKey)
- Synchronize logger
- Update some Dictionaries to ConcurrentDictionary
- Add .Equals and GetHashCode to SignatureContext.
  • Loading branch information
SrivastavaAnubhav authored and Fadi Hanna committed Oct 16, 2019
1 parent eb507a7 commit 2ac3fc4
Show file tree
Hide file tree
Showing 12 changed files with 642 additions and 464 deletions.
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)
{
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

0 comments on commit 2ac3fc4

Please sign in to comment.