Skip to content

Remove UMThunkStub for all non-x86 scenarios #33581

Description

@AaronRobinsonMSFT

With the completion of support for NativeCallableAttribute being public - #33005, there is some additional cleanup that can now occur. The UMThunkStub() calls written in assembly can now be replaced by the newly added JIT helpers for Reverse P/Invoke Enter/Exit.

EXTERN_C void JIT_ReversePInvokeEnter(ReversePInvokeFrame* frame)
{
_ASSERTE(frame != NULL);
Thread* thread = GetThreadNULLOk();
// If a thread instance exists and is in the
// correct GC mode attempt a quick transition.
if (thread != NULL
&& !thread->PreemptiveGCDisabled())
{
// Manually inline the fast path in Thread::DisablePreemptiveGC().
thread->m_fPreemptiveGCDisabled.StoreWithoutBarrier(1);
if (g_TrapReturningThreads.LoadWithoutBarrier() == 0)
{
frame->currentThread = thread;
return;
}
}
JIT_ReversePInvokeEnterRare(frame);
}
EXTERN_C void JIT_ReversePInvokeExit(ReversePInvokeFrame* frame)
{
_ASSERTE(frame != NULL);
_ASSERTE(frame->currentThread == GetThread());
// Manually inline the fast path in Thread::EnablePreemptiveGC().
// This is a trade off with GC suspend performance. We are opting
// to make this exit faster.
frame->currentThread->m_fPreemptiveGCDisabled.StoreWithoutBarrier(0);
}

The x86 case must still use the UMThunkStub(), but all other can now be removed.

/cc @jkoritzinsky @jkotas @janvorli

Activity

  1. Dotnet-GitSync-Bot commented on Mar 14, 2020

    @Dotnet-GitSync-Bot
    Collaborator

    I couldn't add an area label to this Issue.

    Checkout this page to find out which area owner to ping, or please add exactly one area label to help train me in the future.

  2. changed the title [-]Remove UMThunkStub from non-Windows x86 scenarios[/-] [+]Remove UMThunkStub for all non-x86 scenarios[/+] on Mar 30, 2020
  3. added this to the 5.0 milestone on Mar 30, 2020
  4. added a commit that references this issue on Mar 30, 2020
    4e30ff0
  5. safern commented on Mar 31, 2020

    @safern
    Member

    This was reverted in: #34306

  6. reopened this on Mar 31, 2020
  7. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
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