Partager via


ICorProfilerCallback::JITCachedFunctionSearchStarted Method

Notifies the profiler that a search has started for a function that was compiled previously using the Native Image Generator (NGen.exe).

HRESULT JITCachedFunctionSearchStarted(
    [in] FunctionID functionId,
    [out] BOOL      *pbUseCachedFunction);

Parameters

Parameter Description

functionId

[in] The ID of the function for which the search is being performed.

pbUseCachedFunction

[out] true if the execution engine should use the cached version of a function (if available); otherwise false. If the value is false, the execution engine JIT-compiles the function instead of using a version that is not JIT-compiled.

Remarks

In the .NET Framework version 2.0, the ICorProfilerCallback::JITCachedFunctionSearchStarted Method and JITCachedFunctionSearchFinished callbacks will not be made for all functions in regular NGen images. Only NGen images optimized for a profile will generate callbacks for all functions in the image. However, due to the additional overhead, a profiler should request profiler-optimized NGen images only if it intends to use these callbacks to force a function to be compiled just-in-time (JIT). Otherwise, the profiler should use a lazy strategy for gathering function information.

Profilers must support cases where multiple threads of a profiled application are calling the same method simultaneously. For example, thread A calls JITCachedFunctionSearchStarted and the profiler responds by setting pbUseCachedFunction to FALSE to force JIT compilation. Thread A then calls ICorProfilerCallback::JITCompilationStarted Method and ICorProfilerCallback::JITCompilationFinished Method.

Now thread B calls JITCachedFunctionSearchStarted for the same function. Even though the profiler has stated its intention to JIT-compile the function, the profiler receives the second callback because thread B sends the callback before the profiler has responded to thread A's call to JITCachedFunctionSearchStarted. The order in which the threads make calls depends on how the threads are scheduled.

When the profiler receives duplicate callbacks, it must set the value referenced by pbUseCachedFunction to the same value for all the duplicate callbacks. That is, when JITCachedFunctionSearchStarted is called multiple times with the same functionId value, the profiler must respond the same each time.

Requirements

Platforms: Windows 2000, Windows XP, Windows Server 2003 family

Header: CorProf.idl

Library: CorGuids.lib

.NET Framework Version: 2.0

See Also

Reference

ICorProfilerCallback Interface