Skip to content

Reverse P/Invokes should notify profiler when transitioning between unmanaged and managed #46177

Closed

Description

@jkoritzinsky

Today, the runtime notifies the profiler when an unmanaged<->managed transition happens in the following scenarios:

  • P/Invokes on all platforms
  • COM->CLR calls on Windows
  • CLR->COM calls on Windows
  • Reverse P/Invokes on Windows x86 only

We should either notify the profiler about transitions for all Reverse P/Invokes or none (probably all).

cc: @noahfalk @AaronRobinsonMSFT

Activity

  1. added this to the 6.0.0 milestone on Dec 17, 2020
  2. added
    untriaged
    on Dec 17, 2020
  3. AaronRobinsonMSFT commented on Dec 17, 2020

    @AaronRobinsonMSFT
    Member
  4. removed
    untriaged
    on Dec 17, 2020
  5. davmason commented on Dec 17, 2020

    @davmason
    Contributor

    Thanks for reporting this, if you have any other context could we capture that? Do you know why we only notify on x86 for reverse pinvokes? Is it due to IL stubs not being on x86?

  6. jkoritzinsky commented on Dec 17, 2020

    @jkoritzinsky
    MemberAuthor

    On x86 we use a dynamically emitted assembly stub that wraps the IL stub. That assembly stub is what emits the profiler notifications. On other platforms we just use the IL stubs, so nothing is calling the profiler.

  7. jkotas commented on Dec 17, 2020

    @jkotas
    Member

    I assume that you mean UnmanagedCallersOnly methods. Is that right?

    Marshaled delegates that are sometimes also called reverse PInvoke should be fine.

  8. jkoritzinsky commented on Dec 17, 2020

    @jkoritzinsky
    MemberAuthor

    From what I could tell both delegate reverse pinvoke and UnmanagedCallersOnly reverse pinvoke are the same for this case.

  9. jkotas commented on Dec 17, 2020

    @jkotas
    Member

    FWIW, DirectStubLinker::EmitProfilerBeginTransitionCallback is supposed to handle the delegate reverse pinvoke case.

  10. added a commit that references this issue on Dec 18, 2020
    d54420b
  11. ghost added
    in-pr
    on Dec 19, 2020
  12. ghost removed
    in-pr
    on Jan 20, 2021
  13. added a commit that references this issue on Jan 20, 2021
    5ec0c7a
  14. jkoritzinsky commented on Apr 27, 2021

    @jkoritzinsky
    MemberAuthor

    Fixed by #46238

  15. ghost locked as resolved and limited conversation to collaborators on May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions