summaryrefslogtreecommitdiff
path: root/src/vm/prestub.cpp
diff options
context:
space:
mode:
authorMukul Sabharwal <mjsabby@gmail.com>2016-10-21 09:24:21 -0700
committerMukul Sabharwal <mjsabby@gmail.com>2016-10-21 09:24:21 -0700
commitb1f9f8315e011a693eab1f0bc7fb8f1a9c91350d (patch)
tree9ad45b9454bdc4deab96bef9991321b8bf22a70c /src/vm/prestub.cpp
parentbed314bb3005e3c5fc0b3c0723e398e702e08f65 (diff)
downloadcoreclr-b1f9f8315e011a693eab1f0bc7fb8f1a9c91350d.tar.gz
coreclr-b1f9f8315e011a693eab1f0bc7fb8f1a9c91350d.tar.bz2
coreclr-b1f9f8315e011a693eab1f0bc7fb8f1a9c91350d.zip
Add LCG JIT Compilation Profiler Callbacks
Methods that contain no metadata (e.g. of sources are IL Stubs, DynamicMethod, Expression Trees, etc.) also known as LCG methods are not reported to profilers via the Profiling API. LCG, introduced in .NET 2.0 timeframe is unique in that it doesn't require the method to be hosted in an assembly > module > type heirarchy and is GCable in of itself. This change adds new APIs that notify the profiler of such methods but since there is no metadata to go lookup, it provides some useful pieces of information that the profiler author may want to expose to the profiler user. In the compilation start method we provide a className (always dynamicClass), a methodName that can be a set of few predetermined names like (ILStub_COMToCLR, etc.) or if the user has set the name for the LCG method that can show up here. For example, when using the Expression Trees API, the user can specify a friendly name which would be returned here. In the jit completed callback we provide information for the native code start address and size. This is particularly useful to get more accurate accounting of what the (previously unidentified) code is. At least the user would know it is JITTed if nothing more (but most likely more information like what kind of stub). Furthermore, since this is going to be a profiler callback, the profiler can initiate a stackwalk and give more contextual information to its users beyond the pieces of information we can provide here that could identify what they're encountering. Finally, there is also the case that today the profiling APIs underreport JITTed code in the process. Considerable amount of LCG code can now be present in the program and in security-sensitive environments where tracking JITTed code for security reasons is important the profiling apis fall short. In such environments there is also often restrictions on running with elevated privileges, so procuring this data through other means (like ETW) may pose a challenge.
Diffstat (limited to 'src/vm/prestub.cpp')
-rw-r--r--src/vm/prestub.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/vm/prestub.cpp b/src/vm/prestub.cpp
index 77febfbf4b..ff897fa4fb 100644
--- a/src/vm/prestub.cpp
+++ b/src/vm/prestub.cpp
@@ -441,6 +441,10 @@ PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, DWORD flags, DWO
COR_ILMETHOD *pilHeader = GetILHeader(TRUE);
new (ILHeader) COR_ILMETHOD_DECODER(pilHeader, GetMDImport(), NULL);
}
+ else
+ {
+ g_profControlBlock.pProfInterface->DynamicMethodJITCompilationStarted((FunctionID) this, (LPCBYTE)ILHeader);
+ }
END_PIN_PROFILER();
}
#endif // PROFILING_SUPPORTED
@@ -593,6 +597,10 @@ GotNewCode:
pEntry->m_hrResultCode,
TRUE);
}
+ else
+ {
+ g_profControlBlock.pProfInterface->DynamicMethodJITCompilationFinished((FunctionID) this);
+ }
END_PIN_PROFILER();
}
#endif // PROFILING_SUPPORTED