none
Rejit RRS feed

  • Question

  • Hi all,

    I am working with the unmanaged Profiling API and specifically with RequestRejit.

    Does anyone have a working sample ?

    I have followed the guidelines provided by David Broman and I do not get calls to JITStartCompilation after making  a successful request to RequestRejit.

    Any help would be welcome,

    Thanks

    David

    Tuesday, May 30, 2017 3:58 PM

All replies

  • Just to double check:

    • Are you sure the target process called the method after ReJIT? (I believe that if execution has already entered a method, then it will be unaffected, but new calls will be trigger the JIT and be affected.)
    • Are you sure the target method was not inlined? If you want to ReJIT a method that was inlined, then you will need to separately request ReJIT of each method that it was inlined into. (or just block the inlining of methods that you will likely want to ReJIT)
    Tuesday, May 30, 2017 10:10 PM
  • Hi Brian,

    Thanks for the response.

    Yes, the target method calls the method after the request to rejit. I also disabled inlining by setting COR_PRF_DISABLE_OPTIMIZATIONS and COR_PRF_DISABLE_INLINING in the call to SetEventMask.

    But the good news is that I do receive the following notifications, after the target app calls the rejitted function.

    ReJITCompilationStarted
    GetReJITParameters
    ReJITCompilationFinished
    ReJITError 

    Moreover, in the call to ReJITCompilationStarted I can also inject more IL, in the same way I did in the original call to JITCompilationStarted.

    However, I am not able to revert to the original IL.

    Am I expected to store the original IL and to inject it again in the ReJITCompilationStarted call?

    I thought that the RequestRevert call was supposed to handle this for me.

    However, this function still does not work.

    I tried calling it immediately after the call to RequestRejit, and I tried within ReJITCompilationStarted, and within GetReJITParameters. In each case, the function returns S_OK and returns S_OK for the particular method I am making the request for.

    And yet the code is not reverted.

    So, to summarize, my problem is currently with the RequestRevert function only.

    Can you help with this?

    Thanks!

    Wednesday, May 31, 2017 9:23 AM
  • I worked around this by retrieving the original IL (using GetILFunctionBody), requesting a rejit (using RequestRejit) and finally, restoring the original IL (using SetILFunctionBody).

    Using this approach I need to store the jitted IL for all the functions that I instrumented, so that I can restore their IL later. I would prefer to use RequestRevert to simplify the code.

    Maybe I am not calling RequestRevert at the right time. Some other reason?

    If anyone could point to an example project that uses RequestRevert correctly I would greatly appreciate it.

    Thanks

    David


    Friday, June 2, 2017 2:11 PM
  • you can use ICorDebugFunction3::GetActiveReJitRequestILCode Method  to get the pointer to the IL from an active ReJIT request. A ReJIT request becomes active just after execution returns from the ICorProfilerCallback4::GetReJITParameters method call

    A ReJIT request becomes inactive during the profiler's call to the ICorProfilerInfo4::RequestRevert method

    Monday, June 5, 2017 9:37 AM
  • Can you explain what you mean by "A rejit request becomes inactive during .."

    When is it active? It does not seem to become active ever - as the code is not reverted.

    Can you specify what the sequence of operations should be (that includes a call to RequestRevert) that will replace the active IL code with the original IL code?

    Thanks!

    David

    Monday, June 5, 2017 7:23 PM
  • Hi DavidSackstein,

    Based on the document, A ReJIT request becomes active just after execution returns from the ICorProfilerCallback4::GetReJITParameters method call.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, June 7, 2017 9:46 AM
    Moderator
  • What does being "active" mean?

    I do not see the function being reverted at all...

    Tuesday, June 13, 2017 10:12 PM