Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 66 additions & 4 deletions src/coreclr/vm/i386/pinvokestubs.S
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,44 @@
//
//
LEAF_ENTRY JIT_PInvokeBegin, _TEXT
// Not yet supported
int 3

// set first slot to the value of InlinedCallFrame identifier (checked by runtime code)
mov dword ptr [ecx], FRAMETYPE_InlinedCallFrame

mov dword ptr [ecx + InlinedCallFrame__m_Datum], 0

mov eax, esp
add eax, 4
mov dword ptr [ecx + InlinedCallFrame__m_pCallSiteSP], eax
mov dword ptr [ecx + InlinedCallFrame__m_pCalleeSavedFP], ebp

mov eax, [esp]
mov dword ptr [ecx + InlinedCallFrame__m_pCallerReturnAddress], eax

// edx = GetThread(). Trashes eax
push ecx
push edx
push esi
push edi
call C_FUNC(GetThreadHelper)
pop edi
pop esi
pop edx
pop ecx
mov edx, eax

// pFrame->m_Next = pThread->m_pFrame;
mov eax, dword ptr [edx + Thread_m_pFrame]
mov dword ptr [ecx + Frame__m_Next], eax

// pThread->m_pFrame = pFrame;
mov dword ptr [edx + Thread_m_pFrame], ecx

// pThread->m_fPreemptiveGCDisabled = 0
mov dword ptr [edx + Thread_m_fPreemptiveGCDisabled], 0

ret

LEAF_END JIT_PInvokeBegin, _TEXT

//
Expand All @@ -24,9 +59,36 @@ LEAF_END JIT_PInvokeBegin, _TEXT
//
//
LEAF_ENTRY JIT_PInvokeEnd, _TEXT
// Not yet supported
int 3

// edx = GetThread(). Trashes eax
push ecx
push edx
push esi
push edi
call C_FUNC(GetThreadHelper)
pop edi
pop esi
pop edx
pop ecx
mov edx, eax

// ecx = pFrame
// edx = pThread

// pThread->m_fPreemptiveGCDisabled = 1
mov dword ptr [edx + Thread_m_fPreemptiveGCDisabled], 1

// Check return trap
PREPARE_EXTERNAL_VAR g_TrapReturningThreads, eax
cmp DWORD PTR [eax], 0
jnz C_FUNC(JIT_PInvokeEndRarePath)

// pThread->m_pFrame = pFrame->m_Next
mov eax, dword ptr [ecx + Frame__m_Next]
mov dword ptr [edx + Thread_m_pFrame], eax

ret

LEAF_END JIT_PInvokeEnd, _TEXT

//
Expand Down
Loading