Partager via


ICorProfilerCallback::JITCompilationStarted Method

Notifies the profiler that the just-in-time (JIT) compiler has started to compile a function.

HRESULT JITCompilationStarted(
    [in] FunctionID functionId,
    [in] BOOL       fIsSafeToBlock);

Parameters

Parameter Description

functionId

[in] The ID of the function for which the compilation is starting.

fIsSafeToBlock

[in] A value indicating to the profiler whether blocking will affect the operation of the runtime. The value is true if blocking may cause the runtime to wait for the calling thread to return from this callback; otherwise, false.

Although a value of true will not harm the runtime, it can skew the profiling results.

Remarks

It is possible to receive more than one pair of JITCompilationStarted and ICorProfilerCallback::JITCompilationFinished Method calls for each function because of the way the runtime handles class constructors. For example, the runtime starts to JIT-compile method A, but the class constructor for class B needs to be run. The runtime therefore JIT-compiles the constructor for class B and runs it. While the constructor is running, it makes a call to method A, which causes method A to be JIT-compiled again. In this scenario, the first JIT compilation of method A is halted. However, both attempts to JIT-compile method A are reported with JIT-compilation events. If the profiler is going to replace intermediate language (IL) code for method A by calling the ICorProfilerInfo::SetILFunctionBody Method function, it must do so for both JITCompilationStarted events, but may use the same IL block for both.

Profilers must support the sequence of JIT callbacks in cases where two threads are simultaneously making callbacks. For example, thread A calls JITCompilationStarted. However, before thread A calls ICorProfilerCallback::JITCompilationFinished Method, thread B calls ICorProfilerCallback::ExceptionSearchFunctionEnter Method with the function ID from thread A's JITCompilationStarted callback. It might appear that the function ID should not yet be valid because a call to ICorProfilerCallback::JITCompilationFinished Method had not yet been received by the profiler. However, in a case like this one, the function ID is valid.

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