Skip to content

Commit

Permalink
Implement GenericComCallStub
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Sep 20, 2024
1 parent 5e29b59 commit 69413fe
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 27 deletions.
6 changes: 0 additions & 6 deletions src/coreclr/vm/comtoclrcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,6 @@ class ComCallMethodDesc
return -COMMETHOD_PREPAD;
}

static DWORD GetOffsetOfMethodDesc()
{
LIMITED_METHOD_CONTRACT;
return ((DWORD) offsetof(class ComCallMethodDesc, m_pMD));
}

//get call sig
PCCOR_SIGNATURE GetSig(DWORD *pcbSigSize = NULL)
{
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/vm/dllimportcallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,6 @@ class UMEntryThunk
RETURN m_pMD;
}

static DWORD GetOffsetOfMethodDesc()
{
LIMITED_METHOD_CONTRACT;
return offsetof(class UMEntryThunk, m_pMD);
}

static DWORD GetCodeOffset()
{
LIMITED_METHOD_CONTRACT;
Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/vm/frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -1820,20 +1820,6 @@ class UnmanagedToManagedFrame : public Frame
return m_pvDatum;
}

static int GetOffsetOfDatum()
{
LIMITED_METHOD_CONTRACT;
return offsetof(UnmanagedToManagedFrame, m_pvDatum);
}

#ifdef TARGET_X86
static int GetOffsetOfCalleeSavedRegisters()
{
LIMITED_METHOD_CONTRACT;
return offsetof(UnmanagedToManagedFrame, m_calleeSavedRegisters);
}
#endif

int GetFrameType()
{
LIMITED_METHOD_DAC_CONTRACT;
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/i386/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__FrameHandlerExRecord__m_pEntryFrame == offsetof(
#define STACK_OVERWRITE_BARRIER_VALUE 0xabcdefab
#endif

#define COMMETHOD_PREPAD_ASM 8
ASMCONSTANTS_C_ASSERT(COMMETHOD_PREPAD_ASM == COMMETHOD_PREPAD)
#endif

#define CLRToCOMCallMethodDesc__m_pCLRToCOMCallInfo DBG_FRE(0x20, 0xC)
Expand Down
40 changes: 39 additions & 1 deletion src/coreclr/vm/i386/asmhelpers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ EXTERN _TheUMEntryPrestubWorker@4:PROC

ifdef FEATURE_COMINTEROP
EXTERN _CLRToCOMWorker@8:PROC
EXTERN _COMToCLRWorker@4:PROC
endif

EXTERN _ExternalMethodFixupWorker@16:PROC
Expand Down Expand Up @@ -1237,7 +1238,44 @@ _GenericCLRToCOMCallStub@0 proc public
_GenericCLRToCOMCallStub@0 endp

_GenericComCallStub@0 proc public
int 3

; Pop ComCallMethodDesc* pushed by prestub
pop eax

; push ebp-frame
push ebp
mov ebp,esp

; save CalleeSavedRegisters
push ebx
push esi
push edi

push eax ; datum
sub esp, 3*4 ; next, vtable, gscookie

lea eax, [esp+4]

push eax
call _COMToCLRWorker@4

add esp, 3*4

; pop the MethodDesc*
pop ecx

; pop CalleeSavedRegisters
pop edi
pop esi
pop ebx
pop ebp

sub ecx, COMMETHOD_PREPAD_ASM
jmp ecx

; This will never be executed. It is just to help out stack-walking logic
; which disassembles the epilog to unwind the stack.
ret

_GenericComCallStub@0 endp

Expand Down

0 comments on commit 69413fe

Please sign in to comment.