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
2 changes: 1 addition & 1 deletion src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ PALIMPORT
int
PALAPI
// Log a method to the jitdump file.
PAL_PerfJitDump_LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo);
PAL_PerfJitDump_LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo, bool reportCodeBlock);

PALIMPORT
int
Expand Down
17 changes: 8 additions & 9 deletions src/coreclr/pal/src/misc/perfjitdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ struct PerfJitDumpState
return 0;
}

int LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo)
int LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo, bool reportCodeBlock)
{
int result = 0;

Expand All @@ -257,7 +257,9 @@ struct PerfJitDumpState

JitCodeLoadRecord record;

size_t bytesRemaining = sizeof(JitCodeLoadRecord) + symbolLen + 1 + codeSize;
size_t reportedCodeSize = reportCodeBlock ? codeSize : 0;

size_t bytesRemaining = sizeof(JitCodeLoadRecord) + symbolLen + 1 + reportedCodeSize;

record.header.timestamp = GetTimeStampNS();
record.vma = (uint64_t) pCode;
Expand All @@ -269,15 +271,12 @@ struct PerfJitDumpState
// ToDo insert debugInfo and unwindInfo record items immediately before the JitCodeLoadRecord.
{ &record, sizeof(JitCodeLoadRecord) },
{ (void *)symbol, symbolLen + 1 },
{ pCode, codeSize },
{ pCode, reportedCodeSize },
Comment thread
tommcdon marked this conversation as resolved.
};
size_t itemsCount = sizeof(items) / sizeof(items[0]);

size_t itemsWritten = 0;

if (result != 0)
return FatalError();

if (!enabled)
goto exit;

Expand Down Expand Up @@ -390,9 +389,9 @@ PAL_PerfJitDump_IsStarted()

int
PALAPI
PAL_PerfJitDump_LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo)
PAL_PerfJitDump_LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo, bool reportCodeBlock)
{
return GetState().LogMethod(pCode, codeSize, symbol, debugInfo, unwindInfo);
return GetState().LogMethod(pCode, codeSize, symbol, debugInfo, unwindInfo, reportCodeBlock);
}

int
Expand Down Expand Up @@ -420,7 +419,7 @@ PAL_PerfJitDump_IsStarted()

int
PALAPI
PAL_PerfJitDump_LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo)
PAL_PerfJitDump_LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo, bool reportCodeBlock)
{
return 0;
}
Expand Down
15 changes: 11 additions & 4 deletions src/coreclr/vm/perfmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void PerfMap::LogJITCompiledMethod(MethodDesc * pMethod, PCODE pCode, size_t cod
s_Current->WriteLine(line);
}

PAL_PerfJitDump_LogMethod((void*)pCode, codeSize, name.GetUTF8(), nullptr, nullptr);
PAL_PerfJitDump_LogMethod((void*)pCode, codeSize, name.GetUTF8(), nullptr, nullptr, /*reportCodeBlock*/true);
}
}
EX_CATCH{} EX_END_CATCH
Expand Down Expand Up @@ -380,7 +380,7 @@ void PerfMap::LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode)
if (methodRegionInfo.hotSize > 0)
{
CrstHolder ch(&(s_csPerfMap));
PAL_PerfJitDump_LogMethod((void*)methodRegionInfo.hotStartAddress, methodRegionInfo.hotSize, name.GetUTF8(), nullptr, nullptr);
PAL_PerfJitDump_LogMethod((void*)methodRegionInfo.hotStartAddress, methodRegionInfo.hotSize, name.GetUTF8(), nullptr, nullptr, /*reportCodeBlock*/true);
}

if (methodRegionInfo.coldSize > 0)
Expand All @@ -393,7 +393,7 @@ void PerfMap::LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode)
name.Append(W("[PreJit-cold]"));
}

PAL_PerfJitDump_LogMethod((void*)methodRegionInfo.coldStartAddress, methodRegionInfo.coldSize, name.GetUTF8(), nullptr, nullptr);
PAL_PerfJitDump_LogMethod((void*)methodRegionInfo.coldStartAddress, methodRegionInfo.coldSize, name.GetUTF8(), nullptr, nullptr, /*reportCodeBlock*/true);
}
}
EX_CATCH{} EX_END_CATCH
Expand Down Expand Up @@ -450,7 +450,14 @@ void PerfMap::LogStubs(const char* stubType, const char* stubOwner, PCODE pCode,
s_Current->WriteLine(line);
}

PAL_PerfJitDump_LogMethod((void*)pCode, codeSize, name.GetUTF8(), nullptr, nullptr);
// For block-level stub allocations, the memory may be reserved but not yet committed.
// Emitting code bytes in that case can cause jitdump logging to fail, and the bytes
// are optional in the jitdump specification.
Comment thread
tommcdon marked this conversation as resolved.
//
// Even when the memory is committed, block-level stubs are reported at commit time
// before the actual stub code has been written, so the code bytes would be zeros or
// uninitialized. We therefore skip code bytes for block allocations entirely.
PAL_PerfJitDump_LogMethod((void*)pCode, codeSize, name.GetUTF8(), nullptr, nullptr, /*reportCodeBlock*/ stubAllocationType != PerfMapStubType::Block);
}
}
EX_CATCH{} EX_END_CATCH
Expand Down
Loading