diff options
author | Fadi Hanna <fadim@microsoft.com> | 2019-06-06 10:03:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-06 10:03:52 -0700 |
commit | 9f76c18356785ac8de21388998bc0e99425c454a (patch) | |
tree | 1c95d024bbf2e51ff27e200e92c9e4894bde767c /src/vm/arm64 | |
parent | d02b3efcd00258fa060657626dd1a960e2167391 (diff) | |
download | coreclr-9f76c18356785ac8de21388998bc0e99425c454a.tar.gz coreclr-9f76c18356785ac8de21388998bc0e99425c454a.tar.bz2 coreclr-9f76c18356785ac8de21388998bc0e99425c454a.zip |
PInvoke stubs for Unix platforms (#24834)
Enable pinvoke stub inlining on Unix
Exclude x86 Unix platforms from inlining pinvoke stubs (limited support)
Diffstat (limited to 'src/vm/arm64')
-rw-r--r-- | src/vm/arm64/asmconstants.h | 3 | ||||
-rw-r--r-- | src/vm/arm64/pinvokestubs.S | 82 |
2 files changed, 75 insertions, 10 deletions
diff --git a/src/vm/arm64/asmconstants.h b/src/vm/arm64/asmconstants.h index 258fe6dda7..3bb4f6494f 100644 --- a/src/vm/arm64/asmconstants.h +++ b/src/vm/arm64/asmconstants.h @@ -218,6 +218,9 @@ ASMCONSTANTS_C_ASSERT(InlinedCallFrame__m_pCallerReturnAddress == offsetof(Inlin #define InlinedCallFrame__m_pCalleeSavedFP 0x30 ASMCONSTANTS_C_ASSERT(InlinedCallFrame__m_pCalleeSavedFP == offsetof(InlinedCallFrame, m_pCalleeSavedFP)) +#define InlinedCallFrame__m_pThread 0x38 +ASMCONSTANTS_C_ASSERT(InlinedCallFrame__m_pThread == offsetof(InlinedCallFrame, m_pThread)) + #undef ASMCONSTANTS_RUNTIME_ASSERT #undef ASMCONSTANTS_C_ASSERT diff --git a/src/vm/arm64/pinvokestubs.S b/src/vm/arm64/pinvokestubs.S index d0fd3958ea..8b8a611f66 100644 --- a/src/vm/arm64/pinvokestubs.S +++ b/src/vm/arm64/pinvokestubs.S @@ -89,25 +89,87 @@ LOCAL_LABEL(\__PInvokeStubFuncName\()_0): // ------------------------------------------------------------------ // IN: // InlinedCallFrame (x0) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// before actual InlinedCallFrame data) // // - LEAF_ENTRY JIT_PInvokeBegin, _TEXT - // Not yet supported - EMIT_BREAKPOINT - ret lr - LEAF_END JIT_PInvokeBegin, _TEXT + NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler + + PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -32 + PROLOG_SAVE_REG x19, 16 //the stack slot at sp+24 is empty for 16 byte alignment + + PREPARE_EXTERNAL_VAR s_gsCookie, x9 + ldr x9, [x9] + str x9, [x0] + add x19, x0, SIZEOF__GSCookie + + // x19 = pFrame + + // set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) + PREPARE_EXTERNAL_VAR _ZTV16InlinedCallFrame, x9 + add x9, x9, 16 + str x9, [x19] + + str xzr, [x19, #InlinedCallFrame__m_Datum] + + add x9, sp, 32 + str x9, [x19, #InlinedCallFrame__m_pCallSiteSP] + str lr, [x19, #InlinedCallFrame__m_pCallerReturnAddress] + + ldr x9, [sp,#0] + str x9, [x19, #InlinedCallFrame__m_pCalleeSavedFP] + + // x0 = GetThread() + bl C_FUNC(GetThread) + str x0, [x19, #InlinedCallFrame__m_pThread] + + // pFrame->m_Next = pThread->m_pFrame; + ldr x9, [x0, #Thread_m_pFrame] + str x9, [x19, #Frame__m_Next] + + // pThread->m_pFrame = pFrame; + str x19, [x0, #Thread_m_pFrame] + + // pThread->m_fPreemptiveGCDisabled = 0 + str wzr, [x0, #Thread_m_fPreemptiveGCDisabled] + + EPILOG_RESTORE_REG x19, 16 //the stack slot at sp+24 is empty for 16 byte alignment + EPILOG_RESTORE_REG_PAIR_INDEXED fp, lr, 32 + EPILOG_RETURN + + NESTED_END JIT_PInvokeBegin, _TEXT // ------------------------------------------------------------------ // IN: // InlinedCallFrame (x0) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// before actual InlinedCallFrame data) // // LEAF_ENTRY JIT_PInvokeEnd, _TEXT - // Not yet supported - EMIT_BREAKPOINT - ret lr + + add x0, x0, SIZEOF__GSCookie + ldr x1, [x0, #InlinedCallFrame__m_pThread] + + // x0 = pFrame + // x1 = pThread + + // pThread->m_fPreemptiveGCDisabled = 1 + mov x9, 1 + str w9, [x1, #Thread_m_fPreemptiveGCDisabled] + + // Check return trap + PREPARE_EXTERNAL_VAR g_TrapReturningThreads, x9 + ldr x9, [x9] + cbnz x9, LOCAL_LABEL(RarePath) + + // pThread->m_pFrame = pFrame->m_Next + ldr x9, [x0, #Frame__m_Next] + str x9, [x1, #Thread_m_pFrame] + + ret + +LOCAL_LABEL(RarePath): + b C_FUNC(JIT_PInvokeEndRarePath) + LEAF_END JIT_PInvokeEnd, _TEXT // ------------------------------------------------------------------ |