Skip to content
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
1 change: 0 additions & 1 deletion src/coreclr/ToolBox/SOS/DIALib/DIALib.il
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// 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.

// Metadata version: v4.0.30319
.assembly extern mscorlib
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// 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 System.Linq;
Expand All @@ -10,89 +9,98 @@

namespace Mono.Linker
{
public readonly struct MessageOrigin : IComparable<MessageOrigin>, IEquatable<MessageOrigin>
{
public readonly struct MessageOrigin : IComparable<MessageOrigin>, IEquatable<MessageOrigin>
{
#nullable enable
public string? FileName { get; }
public IMemberDefinition? MemberDefinition { get; }
public string? FileName { get; }
public IMemberDefinition? MemberDefinition { get; }
#nullable disable
public int SourceLine { get; }
public int SourceColumn { get; }
public int? ILOffset { get; }
public int SourceLine { get; }
public int SourceColumn { get; }
public int? ILOffset { get; }

public MessageOrigin (string fileName, int sourceLine = 0, int sourceColumn = 0)
{
FileName = fileName;
SourceLine = sourceLine;
SourceColumn = sourceColumn;
MemberDefinition = null;
ILOffset = null;
}
public MessageOrigin(string fileName, int sourceLine = 0, int sourceColumn = 0)
{
FileName = fileName;
SourceLine = sourceLine;
SourceColumn = sourceColumn;
MemberDefinition = null;
ILOffset = null;
}

public MessageOrigin (IMemberDefinition memberDefinition, int? ilOffset = null)
{
FileName = null;
MemberDefinition = memberDefinition;
SourceLine = 0;
SourceColumn = 0;
ILOffset = ilOffset;
}
public MessageOrigin(IMemberDefinition memberDefinition, int? ilOffset = null)
{
FileName = null;
MemberDefinition = memberDefinition;
SourceLine = 0;
SourceColumn = 0;
ILOffset = ilOffset;
}

public override string ToString ()
{
int sourceLine = SourceLine, sourceColumn = SourceColumn;
string fileName = FileName;
if (MemberDefinition is MethodDefinition method &&
method.DebugInformation.HasSequencePoints) {
var offset = ILOffset ?? 0;
SequencePoint correspondingSequencePoint = method.DebugInformation.SequencePoints
.Where (s => s.Offset <= offset)?.Last ();
if (correspondingSequencePoint != null) {
fileName = correspondingSequencePoint.Document.Url;
sourceLine = correspondingSequencePoint.StartLine;
sourceColumn = correspondingSequencePoint.StartColumn;
}
}
public override string ToString()
{
int sourceLine = SourceLine, sourceColumn = SourceColumn;
string fileName = FileName;
if (MemberDefinition is MethodDefinition method &&
method.DebugInformation.HasSequencePoints)
{
var offset = ILOffset ?? 0;
SequencePoint correspondingSequencePoint = method.DebugInformation.SequencePoints
.Where(s => s.Offset <= offset)?.Last();
if (correspondingSequencePoint != null)
{
fileName = correspondingSequencePoint.Document.Url;
sourceLine = correspondingSequencePoint.StartLine;
sourceColumn = correspondingSequencePoint.StartColumn;
}
}

if (fileName == null)
return null;
if (fileName == null)
return null;

StringBuilder sb = new StringBuilder (fileName);
if (sourceLine != 0) {
sb.Append ("(").Append (sourceLine);
if (sourceColumn != 0)
sb.Append (",").Append (sourceColumn);
StringBuilder sb = new StringBuilder(fileName);
if (sourceLine != 0)
{
sb.Append("(").Append(sourceLine);
if (sourceColumn != 0)
sb.Append(",").Append(sourceColumn);

sb.Append (")");
}
sb.Append(")");
}

return sb.ToString ();
}
return sb.ToString();
}

public bool Equals (MessageOrigin other) =>
(FileName, MemberDefinition, SourceLine, SourceColumn) == (other.FileName, other.MemberDefinition, other.SourceLine, other.SourceColumn);
public bool Equals(MessageOrigin other) =>
(FileName, MemberDefinition, SourceLine, SourceColumn) == (other.FileName, other.MemberDefinition, other.SourceLine, other.SourceColumn);

public override bool Equals (object obj) => obj is MessageOrigin messageOrigin && Equals (messageOrigin);
public override int GetHashCode () => (FileName, MemberDefinition, SourceLine, SourceColumn).GetHashCode ();
public static bool operator == (MessageOrigin lhs, MessageOrigin rhs) => lhs.Equals (rhs);
public static bool operator != (MessageOrigin lhs, MessageOrigin rhs) => !lhs.Equals (rhs);
public override bool Equals(object obj) => obj is MessageOrigin messageOrigin && Equals(messageOrigin);
public override int GetHashCode() => (FileName, MemberDefinition, SourceLine, SourceColumn).GetHashCode();
public static bool operator ==(MessageOrigin lhs, MessageOrigin rhs) => lhs.Equals(rhs);
public static bool operator !=(MessageOrigin lhs, MessageOrigin rhs) => !lhs.Equals(rhs);

public int CompareTo (MessageOrigin other)
{
if (MemberDefinition != null && other.MemberDefinition != null) {
return (MemberDefinition.DeclaringType?.Module?.Assembly?.Name?.Name, MemberDefinition.DeclaringType?.Name, MemberDefinition?.Name).CompareTo
((other.MemberDefinition.DeclaringType?.Module?.Assembly?.Name?.Name, other.MemberDefinition.DeclaringType?.Name, other.MemberDefinition?.Name));
} else if (MemberDefinition == null && other.MemberDefinition == null) {
if (FileName != null && other.FileName != null) {
return string.Compare (FileName, other.FileName);
} else if (FileName == null && other.FileName == null) {
return (SourceLine, SourceColumn).CompareTo ((other.SourceLine, other.SourceColumn));
}
public int CompareTo(MessageOrigin other)
{
if (MemberDefinition != null && other.MemberDefinition != null)
{
return (MemberDefinition.DeclaringType?.Module?.Assembly?.Name?.Name, MemberDefinition.DeclaringType?.Name, MemberDefinition?.Name).CompareTo
((other.MemberDefinition.DeclaringType?.Module?.Assembly?.Name?.Name, other.MemberDefinition.DeclaringType?.Name, other.MemberDefinition?.Name));
}
else if (MemberDefinition == null && other.MemberDefinition == null)
{
if (FileName != null && other.FileName != null)
{
return string.Compare(FileName, other.FileName);
}
else if (FileName == null && other.FileName == null)
{
return (SourceLine, SourceColumn).CompareTo((other.SourceLine, other.SourceColumn));
}

return (FileName == null) ? 1 : -1;
}
return (FileName == null) ? 1 : -1;
}

return (MemberDefinition == null) ? 1 : -1;
}
}
return (MemberDefinition == null) ? 1 : -1;
}
}
}
131 changes: 65 additions & 66 deletions src/coreclr/tools/Common/Pgo/PgoFormat.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// 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 System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using ILCompiler;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Collections;
using ILCompiler;

namespace Internal.Pgo
{
Expand Down Expand Up @@ -240,7 +239,7 @@ public static IEnumerable<PgoSchemaElem> ParsePgoData<TType>(IPgoSchemaDataLoade
else
{
int dataIndex = curSchema.Count - dataCountToRead;
switch(curSchema.InstrumentationKind & PgoInstrumentationKind.MarshalMask)
switch (curSchema.InstrumentationKind & PgoInstrumentationKind.MarshalMask)
{
case PgoInstrumentationKind.FourByte:
if (longsAreCompressed)
Expand Down Expand Up @@ -332,7 +331,7 @@ public static IEnumerable<PgoSchemaElem> ParsePgoData<TType>(IPgoSchemaDataLoade
case PgoInstrumentationKind.None:
yield return curSchema;
break;

case PgoInstrumentationKind.FourByte:
if (curSchema.Count > 1)
{
Expand Down Expand Up @@ -414,42 +413,42 @@ public static void EncodePgoData<TType>(IEnumerable<PgoSchemaElem> schemas, IPgo
case PgoInstrumentationKind.None:
break;
case PgoInstrumentationKind.FourByte:
{
long valueToEmit;
if (schema.Count == 1)
{
valueToEmit = schema.DataLong;
}
else
{
valueToEmit = ((int[])schema.DataObject)[i];
long valueToEmit;
if (schema.Count == 1)
{
valueToEmit = schema.DataLong;
}
else
{
valueToEmit = ((int[])schema.DataObject)[i];
}
valueEmitter.EmitLong(valueToEmit, prevEmittedIntData);
prevEmittedIntData = valueToEmit;
break;
}
valueEmitter.EmitLong(valueToEmit, prevEmittedIntData);
prevEmittedIntData = valueToEmit;
break;
}
case PgoInstrumentationKind.EightByte:
{
long valueToEmit;
if (schema.Count == 1)
{
valueToEmit = schema.DataLong;
long valueToEmit;
if (schema.Count == 1)
{
valueToEmit = schema.DataLong;
}
else
{
valueToEmit = ((long[])schema.DataObject)[i];
}
valueEmitter.EmitLong(valueToEmit, prevEmittedIntData);
prevEmittedIntData = valueToEmit;
break;
}
else
case PgoInstrumentationKind.TypeHandle:
{
valueToEmit = ((long[])schema.DataObject)[i];
TType typeToEmit = ((TType[])schema.DataObject)[i];
valueEmitter.EmitType(typeToEmit, prevEmittedType);
prevEmittedType = typeToEmit;
break;
}
valueEmitter.EmitLong(valueToEmit, prevEmittedIntData);
prevEmittedIntData = valueToEmit;
break;
}
case PgoInstrumentationKind.TypeHandle:
{
TType typeToEmit = ((TType[])schema.DataObject)[i];
valueEmitter.EmitType(typeToEmit, prevEmittedType);
prevEmittedType = typeToEmit;
break;
}
}
}

Expand Down Expand Up @@ -559,43 +558,43 @@ void MergeInSchemaElem(Dictionary<PgoSchemaElem, PgoSchemaElem> dataMerger, PgoS

switch (existingSchemaItem.InstrumentationKind)
{
case PgoInstrumentationKind.BasicBlockIntCount:
case PgoInstrumentationKind.TypeHandleHistogramCount:
if ((existingSchemaItem.Count != 1) || (schema.Count != 1))
{
throw new Exception("Unable to merge pgo data. Invalid format");
}
mergedElem.DataLong = existingSchemaItem.DataLong + schema.DataLong;
break;

case PgoInstrumentationKind.TypeHandleHistogramTypeHandle:
{
mergedElem.Count = existingSchemaItem.Count + schema.Count;
TType[] newMergedTypeArray = new TType[mergedElem.Count];
mergedElem.DataObject = newMergedTypeArray;
int i = 0;
foreach (TType type in (TType[])existingSchemaItem.DataObject)
case PgoInstrumentationKind.BasicBlockIntCount:
case PgoInstrumentationKind.TypeHandleHistogramCount:
if ((existingSchemaItem.Count != 1) || (schema.Count != 1))
{
newMergedTypeArray[i++] = type;
throw new Exception("Unable to merge pgo data. Invalid format");
}
foreach (TType type in (TType[])schema.DataObject)
mergedElem.DataLong = existingSchemaItem.DataLong + schema.DataLong;
break;

case PgoInstrumentationKind.TypeHandleHistogramTypeHandle:
{
newMergedTypeArray[i++] = type;
mergedElem.Count = existingSchemaItem.Count + schema.Count;
TType[] newMergedTypeArray = new TType[mergedElem.Count];
mergedElem.DataObject = newMergedTypeArray;
int i = 0;
foreach (TType type in (TType[])existingSchemaItem.DataObject)
{
newMergedTypeArray[i++] = type;
}
foreach (TType type in (TType[])schema.DataObject)
{
newMergedTypeArray[i++] = type;
}
break;
}
break;
}

case PgoInstrumentationKind.Version:
{
mergedElem.Other = Math.Max(existingSchemaItem.Other, schema.Other);
break;
}
case PgoInstrumentationKind.Version:
{
mergedElem.Other = Math.Max(existingSchemaItem.Other, schema.Other);
break;
}

case PgoInstrumentationKind.NumRuns:
{
mergedElem.Other = existingSchemaItem.Other + schema.Other;
break;
}
case PgoInstrumentationKind.NumRuns:
{
mergedElem.Other = existingSchemaItem.Other + schema.Other;
break;
}
}

Debug.Assert(PgoSchemaMergeComparer.Singleton.Compare(schema, mergedElem) == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# 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.
#

PACKAGE=$1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# 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.
#

PACKAGE=$1
Expand Down
Loading