Skip to content
Open
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
41 changes: 41 additions & 0 deletions src/coreclr/vm/perfmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,47 @@ void PerfMap::LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode)
EX_CATCH{} EX_END_CATCH
}

#ifdef FEATURE_INTERPRETER
// Log an interpreter IR bytecode range to the perfmap.
// This allows symbolication from perf scripts, when the interpreter IP is allocated to a fixed
// register in InterpExecMethod
void PerfMap::LogInterpreterMethod(MethodDesc * pMethod, PCODE irAddress, size_t irSize)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
MODE_PREEMPTIVE;
PRECONDITION(pMethod != nullptr);
PRECONDITION(irAddress != nullptr);
PRECONDITION(irSize > 0);
} CONTRACTL_END;

if (!s_enabled)
{
return;
}

EX_TRY
{
SString name;
pMethod->GetFullMethodInfo(name);

SString line;
line.Printf(FMT_CODE_ADDR " %x [Interpreter] %s\n", irAddress, irSize, name.GetUTF8());

{
CrstHolder ch(&(s_csPerfMap));

if (s_Current != nullptr)
{
s_Current->WriteLine(line);
}
}
Comment on lines +441 to +454
}
EX_CATCH{} EX_END_CATCH
}
#endif // FEATURE_INTERPRETER

// Log a set of stub to the map.
void PerfMap::LogStubs(const char* stubType, const char* stubOwner, PCODE pCode, size_t codeSize, PerfMapStubType stubAllocationType)
{
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/vm/perfmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ class PerfMap
// Log a pre-compiled method to the map.
static void LogPreCompiledMethod(MethodDesc * pMethod, PCODE pCode);

#ifdef FEATURE_INTERPRETER
// Log an interpreter IR bytecode range to the perfmap
static void LogInterpreterMethod(MethodDesc * pMethod, PCODE irAddress, size_t irSize);
#endif

// Log a set of stub to the map.
static void LogStubs(const char* stubType, const char* stubOwner, PCODE pCode, size_t codeSize, PerfMapStubType stubAllocationType);

Expand Down
16 changes: 14 additions & 2 deletions src/coreclr/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,20 @@ PCODE MethodDesc::JitCompileCodeLockedEventWrapper(PrepareCodeConfig* pConfig, J
#endif // PROFILING_SUPPORTED

#ifdef FEATURE_PERFMAP
// Save the JIT'd method information so that perf can resolve JIT'd call frames.
PerfMap::LogJITCompiledMethod(this, pCode, sizeOfCode, pConfig);
#if defined(FEATURE_INTERPRETER)
if (isInterpreterCode)
{
InterpreterPrecode* pPrecode = InterpreterPrecode::FromEntryPoint(pCode);
InterpByteCodeStart* interpreterCode = (InterpByteCodeStart*)pPrecode->GetData()->ByteCodeAddr;
PCODE irAddress = PINSTRToPCODE((TADDR)interpreterCode);
PerfMap::LogInterpreterMethod(this, irAddress, sizeOfCode);
}
Comment thread
BrzVlad marked this conversation as resolved.
else
#endif // FEATURE_INTERPRETER
{
// Save the JIT'd method information so that perf can resolve JIT'd call frames.
PerfMap::LogJITCompiledMethod(this, pCode, sizeOfCode, pConfig);
}
#endif

// The notification will only occur if someone has registered for this method.
Expand Down
Loading