Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Use static workaround since UnscopedRef is not yet available
  • Loading branch information
jakobbotsch committed Aug 15, 2022
commit 17a4e22734b6bfe1450b228682b89d22d7fb174f
4 changes: 2 additions & 2 deletions src/coreclr/tools/dotnet-pgo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ void AddToInstrumentationData(int eventClrInstanceId, long methodID, int methodF
if (data->ProcessId != p.ProcessID)
continue;

Span<LbrEntry32> lbr32 = data->Entries(e.EventDataLength);
Span<LbrEntry32> lbr32 = LbrTraceEventData32.Entries(ref *data, e.EventDataLength);
correlator.AttributeSampleToLbrRuns(lbr32);
}
else
Expand All @@ -1640,7 +1640,7 @@ void AddToInstrumentationData(int eventClrInstanceId, long methodID, int methodF
if (data->ProcessId != p.ProcessID)
continue;

Span<LbrEntry64> lbr64 = data->Entries(e.EventDataLength);
Span<LbrEntry64> lbr64 = LbrTraceEventData64.Entries(ref *data, e.EventDataLength);
correlator.AttributeSampleToLbrRuns(lbr64);
}
}
Expand Down
15 changes: 6 additions & 9 deletions src/coreclr/tools/dotnet-pgo/SPGO/LbrEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -56,11 +55,10 @@ public unsafe struct LbrTraceEventData32
public LbrOptionFlags Options;
private LbrEntry32 _entries;

[UnscopedRef]
public Span<LbrEntry32> Entries(int totalSize)
public static Span<LbrEntry32> Entries(ref LbrTraceEventData32 data, int totalSize)
{
IntPtr entriesOffset = Unsafe.ByteOffset(ref Unsafe.As<LbrTraceEventData32, byte>(ref this), ref Unsafe.As<LbrEntry32, byte>(ref _entries));
return MemoryMarshal.CreateSpan(ref _entries, (totalSize - (int)entriesOffset) / sizeof(LbrEntry32));
IntPtr entriesOffset = Unsafe.ByteOffset(ref Unsafe.As<LbrTraceEventData32, byte>(ref data), ref Unsafe.As<LbrEntry32, byte>(ref data._entries));
return MemoryMarshal.CreateSpan(ref data._entries, (totalSize - (int)entriesOffset) / sizeof(LbrEntry32));
}
}

Expand All @@ -73,11 +71,10 @@ public unsafe struct LbrTraceEventData64
public LbrOptionFlags Options;
private LbrEntry64 _entries;

[UnscopedRef]
public Span<LbrEntry64> Entries(int totalSize)
public static Span<LbrEntry64> Entries(ref LbrTraceEventData64 data, int totalSize)
{
IntPtr entriesOffset = Unsafe.ByteOffset(ref Unsafe.As<LbrTraceEventData64, byte>(ref this), ref Unsafe.As<LbrEntry64, byte>(ref _entries));
return MemoryMarshal.CreateSpan(ref _entries, (totalSize - (int)entriesOffset) / sizeof(LbrEntry64));
IntPtr entriesOffset = Unsafe.ByteOffset(ref Unsafe.As<LbrTraceEventData64, byte>(ref data), ref Unsafe.As<LbrEntry64, byte>(ref data._entries));
return MemoryMarshal.CreateSpan(ref data._entries, (totalSize - (int)entriesOffset) / sizeof(LbrEntry64));
}
}
}