From 52dfd6d87297c26c573c30e96aa4714eb3690680 Mon Sep 17 00:00:00 2001 From: SaeHie Park Date: Wed, 4 Jan 2017 19:10:13 +0900 Subject: [PATCH] [x86/Linux] Implement SinglecastDelegateInvokeStub (dotnet/coreclr#8799) Implement SinglecastDelegateInvokeStub for x86/Linux - Code copied from that of AMD64 and some translation - Fixes LargeObjectAlloc.exe unit test case and maybe others Commit migrated from https://github.com/dotnet/coreclr/commit/4519be41745ea4c46d29078dc7e2524966b75436 --- src/coreclr/src/vm/i386/asmconstants.h | 18 ++++++++++++++++++ src/coreclr/src/vm/i386/asmhelpers.S | 21 +++++++++++++++++++++ src/coreclr/src/vm/i386/unixstubs.cpp | 5 ----- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/coreclr/src/vm/i386/asmconstants.h b/src/coreclr/src/vm/i386/asmconstants.h index c42b167..ee34300 100644 --- a/src/coreclr/src/vm/i386/asmconstants.h +++ b/src/coreclr/src/vm/i386/asmconstants.h @@ -467,6 +467,24 @@ ASMCONSTANTS_C_ASSERT(Thread__m_pDomain == offsetof(Thread, m_pDomain)); #endif +#ifdef FEATURE_STUBS_AS_IL +// DelegateObject from src/vm/object.h +#define DelegateObject___target 0x04 // offset 0 is m_pMethTab of base class Object +#define DelegateObject___methodBase 0x08 +#define DelegateObject___methodPtr 0x0c +#define DelegateObject___methodPtrAux 0x10 +#define DelegateObject___invocationList 0x14 +#define DelegateObject___invocationCount 0x18 + +ASMCONSTANTS_C_ASSERT(DelegateObject___target == offsetof(DelegateObject, _target)); +ASMCONSTANTS_C_ASSERT(DelegateObject___methodBase == offsetof(DelegateObject, _methodBase)); +ASMCONSTANTS_C_ASSERT(DelegateObject___methodPtr == offsetof(DelegateObject, _methodPtr)); +ASMCONSTANTS_C_ASSERT(DelegateObject___methodPtrAux == offsetof(DelegateObject, _methodPtrAux)); +ASMCONSTANTS_C_ASSERT(DelegateObject___invocationList == offsetof(DelegateObject, _invocationList)); +ASMCONSTANTS_C_ASSERT(DelegateObject___invocationCount == offsetof(DelegateObject, _invocationCount)); + +#endif + #undef ASMCONSTANTS_C_ASSERT #undef ASMCONSTANTS_RUNTIME_ASSERT diff --git a/src/coreclr/src/vm/i386/asmhelpers.S b/src/coreclr/src/vm/i386/asmhelpers.S index 1c6f0a3..6f3dc31 100644 --- a/src/coreclr/src/vm/i386/asmhelpers.S +++ b/src/coreclr/src/vm/i386/asmhelpers.S @@ -1138,3 +1138,24 @@ NESTED_ENTRY ResolveWorkerAsmStub, _TEXT, NoHandler // Now jump to the target jmp eax // continue on into the method NESTED_END ResolveWorkerAsmStub, _TEXT + +#ifdef FEATURE_STUBS_AS_IL +// ========================================================================== +// void SinglecastDelegateInvokeStub(); +// +LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT + + test ecx, ecx + jz LOCAL_LABEL(NullObject) + + mov eax, [ecx + DelegateObject___methodPtr] + mov ecx, [ecx + DelegateObject___target] // replace "this" pointer + jmp eax + +LOCAL_LABEL(NullObject): + + mov ecx, CORINFO_NullReferenceException_ASM + jmp C_FUNC(JIT_InternalThrow) + +LEAF_END SinglecastDelegateInvokeStub, _TEXT +#endif // FEATURE_STUBS_AS_IL diff --git a/src/coreclr/src/vm/i386/unixstubs.cpp b/src/coreclr/src/vm/i386/unixstubs.cpp index 9fe7127..8ad8419 100644 --- a/src/coreclr/src/vm/i386/unixstubs.cpp +++ b/src/coreclr/src/vm/i386/unixstubs.cpp @@ -70,11 +70,6 @@ VOID __cdecl PopSEHRecords(LPVOID pTargetSP) PORTABILITY_ASSERT("Implement for PAL"); } -EXTERN_C VOID SinglecastDelegateInvokeStub() -{ - PORTABILITY_ASSERT("SinglecastDelegateInvokeStub"); -} - EXTERN_C VOID ResolveWorkerChainLookupAsmStub() { PORTABILITY_ASSERT("ResolveWorkerChainLookupAsmStub"); -- 2.7.4