ICorProfilerInfo4::RequestReJIT Method

Requests a JIT recompilation of all instances of the specified functions.


HRESULT RequestReJIT (  
   [in] ULONG    cFunctions,  
   [in, size_is(cFunctions)]  ModuleID    moduleIds[],  
   [in, size_is(cFunctions)]  mdMethodDef methodIds[]);  


[in] The number of functions to recompile.

[in] Specifies the moduleId portion of the (module, methodDef) pairs that identify the functions to be recompiled.

[in] Specifies the methodId portion of the (module, methodDef) pairs that identify the functions to be recompiled.

Return Value

This method returns the following specific HRESULTs as well as HRESULT errors that indicate method failure.

HRESULT Description
S_OK An attempt was made to mark all the methods for JIT recompilation. The profiler must implement the ICorProfilerCallback4::ReJITError method to determine which methods were successfully marked for JIT recompilation.
CORPROF_E_CALLBACK4_REQUIRED The profiler must implement the ICorProfilerCallback4 interface for this call to be supported.
CORPROF_E_REJIT_NOT_ENABLED JIT recompilation has not been enabled. You must enable JIT recompilation during initialization by using the ICorProfilerInfo::SetEventMask method to set the COR_PRF_ENABLE_REJIT flag.
E_INVALIDARG cFunctions is 0, or moduleIds or methodIds is NULL.
E_OUTOFMEMORY The CLR was unable to complete the request because it ran out of memory.


Call RequestReJIT to have the runtime recompile a specified set of functions. A code profiler can then use the ICorProfilerFunctionControl interface to adjust the code that is generated when the functions are recompiled. This does not affect currently executing functions, only future function invocations. If any of the specified functions has previously been JIT-recompiled, requesting a recompilation is equivalent to reverting and recompiling the function. To preserve reversibility, when the JIT compiler compiles the original version of a function, it considers only the original versions of its callees for inlining decisions. When the JIT compiler recompiles a function, it considers the current versions (recompiled or original) of its callees for inlining.

A profiler typically calls RequestReJIT in response to user input requesting that the profiler instrument one or more methods. RequestReJIT typically suspends the runtime in order to do some of its work, and can potentially trigger a garbage collection. As such, the profiler should call RequestReJIT from a thread it previously created, and not from a CLR-created thread that is currently executing a profiler callback.


Platforms: See System Requirements.

Header: CorProf.idl, CorProf.h

Library: CorGuids.lib

.NET Framework Versions: Available since 4.5

See also