Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23666e9

Browse files
authored
Merge branch 'main' into riscv-emit-output-instr-refactor
2 parents 97b0951 + b498582 commit 23666e9

File tree

8 files changed

+98
-46
lines changed

8 files changed

+98
-46
lines changed

src/coreclr/jit/compiler.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5231,21 +5231,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
52315231

52325232
#if FEATURE_LOOP_ALIGN
52335233

5234-
// TODO-Quirk: Remove
5235-
static bool HasOldChildLoop(Compiler* comp, FlowGraphNaturalLoop* loop)
5236-
{
5237-
for (FlowGraphNaturalLoop* child = loop->GetChild(); child != nullptr; child = child->GetSibling())
5238-
{
5239-
if (child->GetHeader()->HasFlag(BBF_OLD_LOOP_HEADER_QUIRK))
5240-
return true;
5241-
5242-
if (HasOldChildLoop(comp, child))
5243-
return true;
5244-
}
5245-
5246-
return false;
5247-
}
5248-
52495234
//------------------------------------------------------------------------
52505235
// shouldAlignLoop: Check if it is legal and profitable to align a loop.
52515236
//
@@ -5265,16 +5250,7 @@ static bool HasOldChildLoop(Compiler* comp, FlowGraphNaturalLoop* loop)
52655250
//
52665251
bool Compiler::shouldAlignLoop(FlowGraphNaturalLoop* loop, BasicBlock* top)
52675252
{
5268-
// TODO-Quirk: Remove. When removing we will likely need to add some
5269-
// form of "lexicality" heuristic here: only align loops whose blocks
5270-
// are fairly tightly packed together physically.
5271-
if (!loop->GetHeader()->HasFlag(BBF_OLD_LOOP_HEADER_QUIRK))
5272-
{
5273-
return false;
5274-
}
5275-
5276-
// TODO-Quirk: Switch to loop->GetChild() != nullptr
5277-
if (HasOldChildLoop(this, loop))
5253+
if (loop->GetChild() != nullptr)
52785254
{
52795255
JITDUMP("Skipping alignment for " FMT_LP "; not an innermost loop\n", loop->GetIndex());
52805256
return false;

src/coreclr/jit/optimizer.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3430,12 +3430,6 @@ PhaseStatus Compiler::optUnrollLoops()
34303430
// Visit loops in post order (inner loops before outer loops).
34313431
for (FlowGraphNaturalLoop* loop : m_loops->InPostOrder())
34323432
{
3433-
// TODO-Quirk: Remove
3434-
if (!loop->GetHeader()->HasFlag(BBF_OLD_LOOP_HEADER_QUIRK))
3435-
{
3436-
continue;
3437-
}
3438-
34393433
if (BitVecOps::IsMember(&loopTraits, loopsWithUnrolledDescendant, loop->GetIndex()))
34403434
{
34413435
continue;

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSwitchManager.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,8 @@ public AssemblyFeatureInfo(EcmaModule module, Logger logger, IReadOnlyDictionary
925925

926926
PEMemoryBlock resourceDirectory = module.PEReader.GetSectionData(module.PEReader.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress);
927927

928+
BodyAndFieldSubstitutions substitutions = default;
929+
928930
foreach (var resourceHandle in module.MetadataReader.ManifestResources)
929931
{
930932
ManifestResource resource = module.MetadataReader.GetManifestResource(resourceHandle);
@@ -947,13 +949,7 @@ public AssemblyFeatureInfo(EcmaModule module, Logger logger, IReadOnlyDictionary
947949
ms = new UnmanagedMemoryStream(reader.CurrentPointer, length);
948950
}
949951

950-
BodyAndFieldSubstitutions substitutions = BodySubstitutionsParser.GetSubstitutions(logger, module.Context, ms, resource, module, "name", featureSwitchValues);
951-
952-
// Also apply any global substitutions
953-
// Note we allow these to overwrite substitutions in the assembly
954-
substitutions.AppendFrom(globalSubstitutions);
955-
956-
(BodySubstitutions, FieldSubstitutions) = (substitutions.BodySubstitutions, substitutions.FieldSubstitutions);
952+
substitutions = BodySubstitutionsParser.GetSubstitutions(logger, module.Context, ms, resource, module, "name", featureSwitchValues);
957953
}
958954
else if (InlineableStringsResourceNode.IsInlineableStringsResource(module, resourceName))
959955
{
@@ -977,6 +973,12 @@ public AssemblyFeatureInfo(EcmaModule module, Logger logger, IReadOnlyDictionary
977973
}
978974
}
979975
}
976+
977+
// Also apply any global substitutions
978+
// Note we allow these to overwrite substitutions in the assembly
979+
substitutions.AppendFrom(globalSubstitutions);
980+
981+
(BodySubstitutions, FieldSubstitutions) = (substitutions.BodySubstitutions, substitutions.FieldSubstitutions);
980982
}
981983
}
982984
}

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void WriteLineReference(long offset)
140140

141141
public DwarfExpressionBuilder GetExpressionBuilder()
142142
{
143-
_expressionBufferWriter.Clear();
143+
_expressionBufferWriter.ResetWrittenCount();
144144
return new DwarfExpressionBuilder(TargetArchitecture, TargetPointerSize, _expressionBufferWriter);
145145
}
146146

src/coreclr/vm/riscv64/stubs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// File: stubs.cpp
55
//
66
// This file contains stub functions for unimplemented features need to
7-
// run on the ARM64 platform.
7+
// run on the RISCV64 platform.
88

99
#include "common.h"
1010
#include "dllimportcallback.h"
@@ -985,7 +985,7 @@ LONG CLRNoCatchHandler(EXCEPTION_POINTERS* pExceptionInfo, PVOID pv)
985985

986986
void FlushWriteBarrierInstructionCache()
987987
{
988-
// this wouldn't be called in arm64, just to comply with gchelpers.h
988+
// this wouldn't be called in riscv64, just to comply with gchelpers.h
989989
}
990990

991991
int StompWriteBarrierEphemeral(bool isRuntimeSuspended)

src/coreclr/vm/riscv64/virtualcallstubcpu.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//
44
// VirtualCallStubCpu.hpp
55
//
6-
#ifndef _VIRTUAL_CALL_STUB_ARM_H
7-
#define _VIRTUAL_CALL_STUB_ARM_H
6+
#ifndef _VIRTUAL_CALL_STUB_RISCV64_H
7+
#define _VIRTUAL_CALL_STUB_RISCV64_H
88

99
#define DISPATCH_STUB_FIRST_DWORD 0x00000e97
1010
#define RESOLVE_STUB_FIRST_DWORD 0x00053e03
@@ -513,4 +513,4 @@ void VTableCallHolder::Initialize(unsigned slot)
513513

514514
#endif //DECLARE_DATA
515515

516-
#endif // _VIRTUAL_CALL_STUB_ARM_H
516+
#endif // _VIRTUAL_CALL_STUB_RISCV64_H

src/libraries/Common/tests/System/Collections/DebugView.Tests.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ private static IEnumerable<object[]> TestDebuggerAttributes_GenericDictionaries(
4747
new ("[\"Two\"]", "2"),
4848
}
4949
};
50+
CustomKeyedCollection<string, int> collection = new ();
51+
collection.GetKeyForItemHandler = value => (2 * value).ToString();
52+
collection.InsertItem(0, 1);
53+
collection.InsertItem(1, 3);
54+
yield return new object[] { collection,
55+
new KeyValuePair<string, string>[]
56+
{
57+
new ("[\"2\"]", "1"),
58+
new ("[\"6\"]", "3"),
59+
}
60+
};
5061
}
5162

5263
private static IEnumerable<object[]> TestDebuggerAttributes_NonGenericDictionaries()
@@ -173,7 +184,7 @@ public static IEnumerable<object[]> TestDebuggerAttributes_Inputs()
173184

174185
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
175186
[MemberData(nameof(TestDebuggerAttributes_InputsPresentedAsDictionary))]
176-
public static void TestDebuggerAttributes_Dictionary(IDictionary obj, KeyValuePair<string, string>[] expected)
187+
public static void TestDebuggerAttributes_Dictionary(object obj, KeyValuePair<string, string>[] expected)
177188
{
178189
DebuggerAttributes.ValidateDebuggerDisplayReferences(obj);
179190
DebuggerAttributeInfo info = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(obj);
@@ -206,5 +217,32 @@ public static void TestDebuggerAttributes_Null(object obj)
206217
TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object)null));
207218
Assert.IsType<ArgumentNullException>(tie.InnerException);
208219
}
220+
221+
private class CustomKeyedCollection<TKey, TValue> : KeyedCollection<TKey, TValue> where TKey : notnull
222+
{
223+
public CustomKeyedCollection() : base()
224+
{
225+
}
226+
227+
public CustomKeyedCollection(IEqualityComparer<TKey> comparer) : base(comparer)
228+
{
229+
}
230+
231+
public CustomKeyedCollection(IEqualityComparer<TKey> comparer, int dictionaryCreationThreshold) : base(comparer, dictionaryCreationThreshold)
232+
{
233+
}
234+
235+
public Func<TValue, TKey> GetKeyForItemHandler { get; set; }
236+
237+
protected override TKey GetKeyForItem(TValue item)
238+
{
239+
return GetKeyForItemHandler(item);
240+
}
241+
242+
public new void InsertItem(int index, TValue item)
243+
{
244+
base.InsertItem(index, item);
245+
}
246+
}
209247
}
210248
}

src/libraries/System.ObjectModel/src/System/Collections/ObjectModel/KeyedCollection.cs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace System.Collections.ObjectModel
99
{
1010
[Serializable]
11-
[DebuggerTypeProxy(typeof(CollectionDebugView<>))]
11+
[DebuggerTypeProxy(typeof(KeyedCollection<,>.KeyedCollectionDebugView))]
1212
[DebuggerDisplay("Count = {Count}")]
1313
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
1414
public abstract class KeyedCollection<TKey, TItem> : Collection<TItem> where TKey : notnull
@@ -280,5 +280,47 @@ private void RemoveKey(TKey key)
280280
keyCount--;
281281
}
282282
}
283+
284+
private sealed class KeyedCollectionDebugView
285+
{
286+
private readonly KeyedCollection<TKey, TItem> _collection;
287+
288+
public KeyedCollectionDebugView(KeyedCollection<TKey, TItem> collection)
289+
{
290+
ArgumentNullException.ThrowIfNull(collection);
291+
_collection = collection;
292+
}
293+
294+
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
295+
public KeyedCollectionDebugViewItem[] Items
296+
{
297+
get
298+
{
299+
var items = new KeyedCollectionDebugViewItem[_collection.Count];
300+
for (int i = 0; i < items.Length; i++)
301+
{
302+
TItem item = _collection[i];
303+
items[i] = new KeyedCollectionDebugViewItem(_collection.GetKeyForItem(item), item);
304+
}
305+
return items;
306+
}
307+
}
308+
309+
[DebuggerDisplay("{Value}", Name = "[{Key}]")]
310+
internal readonly struct KeyedCollectionDebugViewItem
311+
{
312+
public KeyedCollectionDebugViewItem(TKey key, TItem value)
313+
{
314+
Key = key;
315+
Value = value;
316+
}
317+
318+
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
319+
public TKey Key { get; }
320+
321+
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
322+
public TItem Value { get; }
323+
}
324+
}
283325
}
284326
}

0 commit comments

Comments
 (0)