Cleanup fragile NGen leftovers (#65869)
authorJan Kotas <jkotas@microsoft.com>
Fri, 25 Feb 2022 05:57:13 +0000 (21:57 -0800)
committerGitHub <noreply@github.com>
Fri, 25 Feb 2022 05:57:13 +0000 (21:57 -0800)
15 files changed:
src/coreclr/inc/corcompile.h
src/coreclr/inc/corinfo.h
src/coreclr/inc/jiteeversionguid.h
src/coreclr/inc/jithelpers.h
src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs
src/coreclr/vm/amd64/ExternalMethodFixupThunk.asm
src/coreclr/vm/amd64/externalmethodfixupthunk.S
src/coreclr/vm/arm/asmhelpers.S
src/coreclr/vm/arm/asmhelpers.asm
src/coreclr/vm/arm64/asmhelpers.S
src/coreclr/vm/arm64/asmhelpers.asm
src/coreclr/vm/cgensys.h
src/coreclr/vm/i386/asmhelpers.S
src/coreclr/vm/i386/asmhelpers.asm
src/coreclr/vm/prestub.cpp

index 3c7a7ca..fda3120 100644 (file)
@@ -33,8 +33,6 @@ typedef DPTR(struct CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY)
    PTR_CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY;
 typedef DPTR(struct CORCOMPILE_EXCEPTION_CLAUSE)
    PTR_CORCOMPILE_EXCEPTION_CLAUSE;
-typedef DPTR(struct CORCOMPILE_EXTERNAL_METHOD_THUNK)
-    PTR_CORCOMPILE_EXTERNAL_METHOD_THUNK;
 typedef DPTR(struct CORCOMPILE_EXTERNAL_METHOD_DATA_ENTRY)
     PTR_CORCOMPILE_EXTERNAL_METHOD_DATA_ENTRY;
 typedef DPTR(struct CORCOMPILE_IMPORT_SECTION)
@@ -139,54 +137,6 @@ inline BOOL CORCOMPILE_IS_FIXUP_TAGGED(SIZE_T fixup, PTR_CORCOMPILE_IMPORT_SECTI
     return ((((SIZE_T)(fixup)) & CORCOMPILE_TOKEN_TAG) == CORCOMPILE_TOKEN_TAG);
 }
 
-/*********************************************************************************/
-
-#if defined(TARGET_X86) || defined(TARGET_AMD64)
-
-#define _PRECODE_EXTERNAL_METHOD_THUNK      0x41
-    struct  CORCOMPILE_EXTERNAL_METHOD_THUNK
-    {
-        BYTE                callJmp[5];     // Call/Jmp Pc-Rel32
-        BYTE                precodeType;    // 0x41 _PRECODE_EXTERNAL_METHOD_THUNK
-        WORD                padding;
-    };
-
-#elif defined(TARGET_ARM)
-
-    struct  CORCOMPILE_EXTERNAL_METHOD_THUNK
-    {
-        // Array of words to do the following:
-        //
-        // mov r12, pc       ; Save the current address relative to which we will get GCRef bitmap and address to patch.
-        // ldr pc, [pc, #4]  ; Load the target address. Initially it will point to the helper stub that will patch it
-        //                   ; to point to the actual target on the first run.
-        WORD                m_rgCode[3];
-
-        WORD                m_padding;
-
-        // The target address - initially, this will point to ExternalMethodFixupStub.
-        // Post patchup by the stub, it will point to the actual method body.
-        PCODE               m_pTarget;
-    };
-
-#elif defined(TARGET_ARM64)
-    struct  CORCOMPILE_EXTERNAL_METHOD_THUNK
-    {
-        // Array of words to do the following:
-        // adr         x12, #0            ; Save the current address relative to which we will get slot ID and address to patch.
-        // ldr         x10, [x12, #16]    ; Load the target address.
-        // br          x10                ; Jump to the target
-        DWORD                m_rgCode[3];
-
-        DWORD                m_padding; //aligning stack to 16 bytes
-
-        // The target address - initially, this will point to ExternalMethodFixupStub.
-        // Post patchup by the stub, it will point to the actual method body.
-        PCODE                m_pTarget;
-    };
-
-#endif
-
 //
 // GCRefMap blob starts with DWORDs lookup index of relative offsets into the blob. This lookup index is used to limit amount
 // of linear scanning required to find entry in the GCRefMap. The size of this lookup index is
index 28f4c88..99dd1fb 100644 (file)
@@ -582,7 +582,6 @@ enum CorInfoHelpFunc
     CORINFO_HELP_ARE_TYPES_EQUIVALENT, // Check whether two TypeHandles (native structure pointers) are equivalent
 
     CORINFO_HELP_VIRTUAL_FUNC_PTR,      // look up a virtual method at run-time
-    //CORINFO_HELP_VIRTUAL_FUNC_PTR_LOG,  // look up a virtual method at run-time, with IBC logging
 
     // Not a real helpers. Instead of taking handle arguments, these helpers point to a small stub that loads the handle argument and calls the static helper.
     CORINFO_HELP_READYTORUN_NEW,
@@ -595,16 +594,6 @@ enum CorInfoHelpFunc
     CORINFO_HELP_READYTORUN_DELEGATE_CTOR,
     CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE,
 
-    CORINFO_HELP_EE_PRESTUB,            // Not real JIT helper. Used in native images.
-
-    CORINFO_HELP_EE_PRECODE_FIXUP,      // Not real JIT helper. Used for Precode fixup in native images.
-    CORINFO_HELP_EE_PINVOKE_FIXUP,      // Not real JIT helper. Used for PInvoke target fixup in native images.
-    CORINFO_HELP_EE_VSD_FIXUP,          // Not real JIT helper. Used for VSD cell fixup in native images.
-    CORINFO_HELP_EE_EXTERNAL_FIXUP,     // Not real JIT helper. Used for to fixup external method thunks in native images.
-    CORINFO_HELP_EE_VTABLE_FIXUP,       // Not real JIT helper. Used for inherited vtable slot fixup in native images.
-
-    CORINFO_HELP_EE_REMOTING_THUNK,     // Not real JIT helper. Used for remoting precode in native images.
-
     CORINFO_HELP_EE_PERSONALITY_ROUTINE,// Not real JIT helper. Used in native images.
     CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET,// Not real JIT helper. Used in native images to detect filter funclets.
 
index 303f97b..1b0afc9 100644 (file)
@@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
 #define GUID_DEFINED
 #endif // !GUID_DEFINED
 
-constexpr GUID JITEEVersionIdentifier = { /* 80a6aaf7-7fb3-44b2-8fe5-95fd47308798 */
-    0x80a6aaf7,
-    0x7fb3,
-    0x44b2,
-    {0x8f, 0xe5, 0x95, 0xfd, 0x47, 0x30, 0x87, 0x98}
+constexpr GUID JITEEVersionIdentifier = { /* bcc99ca6-5291-4cc0-a5d9-2758456053f3 */
+    0xbcc99ca6,
+    0x5291,
+    0x4cc0,
+    { 0xa5, 0xd9, 0x27, 0x58, 0x45, 0x60, 0x53, 0xf3 }
   };
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
index 82b43a7..e2c4e0e 100644 (file)
     JITHELPER(CORINFO_HELP_ARE_TYPES_EQUIVALENT, NULL, CORINFO_HELP_SIG_REG_ONLY)
 
     JITHELPER(CORINFO_HELP_VIRTUAL_FUNC_PTR,    JIT_VirtualFunctionPointer, CORINFO_HELP_SIG_4_STACK)
-    //JITHELPER(CORINFO_HELP_VIRTUAL_FUNC_PTR_LOG,JIT_VirtualFunctionPointerLogging)
 
     JITHELPER(CORINFO_HELP_READYTORUN_NEW,                 NULL,   CORINFO_HELP_SIG_NO_ALIGN_STUB)
     JITHELPER(CORINFO_HELP_READYTORUN_NEWARR_1,            NULL,   CORINFO_HELP_SIG_NO_ALIGN_STUB)
     JITHELPER(CORINFO_HELP_READYTORUN_DELEGATE_CTOR,       NULL,   CORINFO_HELP_SIG_NO_ALIGN_STUB)
     JITHELPER(CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE, NULL,   CORINFO_HELP_SIG_NO_ALIGN_STUB)
 
-    JITHELPER(CORINFO_HELP_EE_PRESTUB,          ThePreStub,                 CORINFO_HELP_SIG_NO_ALIGN_STUB)
-
-#if defined(HAS_FIXUP_PRECODE)
-    JITHELPER(CORINFO_HELP_EE_PRECODE_FIXUP,    PrecodeFixupThunk,          CORINFO_HELP_SIG_NO_ALIGN_STUB)
-#else
-    JITHELPER(CORINFO_HELP_EE_PRECODE_FIXUP,    NULL,                       CORINFO_HELP_SIG_NO_ALIGN_STUB)
-#endif
-
-    JITHELPER(CORINFO_HELP_EE_PINVOKE_FIXUP,    NDirectImportThunk,         CORINFO_HELP_SIG_NO_ALIGN_STUB)
-
-    JITHELPER(CORINFO_HELP_EE_VSD_FIXUP,        NULL,                       CORINFO_HELP_SIG_NO_ALIGN_STUB)
-    JITHELPER(CORINFO_HELP_EE_EXTERNAL_FIXUP,   ExternalMethodFixupStub,    CORINFO_HELP_SIG_NO_ALIGN_STUB)
-    JITHELPER(CORINFO_HELP_EE_VTABLE_FIXUP,     NULL,                       CORINFO_HELP_SIG_NO_ALIGN_STUB)
-
-    JITHELPER(CORINFO_HELP_EE_REMOTING_THUNK,   NULL,                       CORINFO_HELP_SIG_UNDEF)
-
-// We do not need this to be saved in ngen images on Mac64 since the exception dispatch
-// is not done via the OS and thus, there wont be any need to know this information
-// by anyone.
 #ifdef FEATURE_EH_FUNCLETS
     JITHELPER(CORINFO_HELP_EE_PERSONALITY_ROUTINE, ProcessCLRException,               CORINFO_HELP_SIG_UNDEF)
     JITHELPER(CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET, ProcessCLRException,CORINFO_HELP_SIG_UNDEF)
index 0e5f836..e395356 100644 (file)
@@ -229,7 +229,6 @@ namespace Internal.JitInterface
         CORINFO_HELP_ARE_TYPES_EQUIVALENT, // Check whether two TypeHandles (native structure pointers) are equivalent
 
         CORINFO_HELP_VIRTUAL_FUNC_PTR,      // look up a virtual method at run-time
-                                            //CORINFO_HELP_VIRTUAL_FUNC_PTR_LOG,  // look up a virtual method at run-time, with IBC logging
 
         // Not a real helpers. Instead of taking handle arguments, these helpers point to a small stub that loads the handle argument and calls the static helper.
         CORINFO_HELP_READYTORUN_NEW,
@@ -242,16 +241,6 @@ namespace Internal.JitInterface
         CORINFO_HELP_READYTORUN_DELEGATE_CTOR,
         CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE,
 
-        CORINFO_HELP_EE_PRESTUB,            // Not real JIT helper. Used in native images.
-
-        CORINFO_HELP_EE_PRECODE_FIXUP,      // Not real JIT helper. Used for Precode fixup in native images.
-        CORINFO_HELP_EE_PINVOKE_FIXUP,      // Not real JIT helper. Used for PInvoke target fixup in native images.
-        CORINFO_HELP_EE_VSD_FIXUP,          // Not real JIT helper. Used for VSD cell fixup in native images.
-        CORINFO_HELP_EE_EXTERNAL_FIXUP,     // Not real JIT helper. Used for to fixup external method thunks in native images.
-        CORINFO_HELP_EE_VTABLE_FIXUP,       // Not real JIT helper. Used for inherited vtable slot fixup in native images.
-
-        CORINFO_HELP_EE_REMOTING_THUNK,     // Not real JIT helper. Used for remoting precode in native images.
-
         CORINFO_HELP_EE_PERSONALITY_ROUTINE,// Not real JIT helper. Used in native images.
         CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET,// Not real JIT helper. Used in native images to detect filter funclets.
 
index 1a0671e..c205d43 100644 (file)
@@ -11,27 +11,6 @@ ifdef FEATURE_READYTORUN
     extern DynamicHelperWorker:proc
 endif
 
-;============================================================================================
-;; EXTERN_C VOID __stdcall ExternalMethodFixupStub()
-
-NESTED_ENTRY ExternalMethodFixupStub, _TEXT, ProcessCLRException
-
-        PROLOG_WITH_TRANSITION_BLOCK 0, 8, rdx
-
-        lea             rcx, [rsp + __PWTB_TransitionBlock] ; pTransitionBlock
-        sub             rdx, 5                              ; pThunk
-        mov             r8, 0                               ; sectionIndex
-        mov             r9, 0                               ; pModule
-
-        call            ExternalMethodFixupWorker
-
-        EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
-PATCH_LABEL ExternalMethodFixupPatchLabel
-        TAILJMP_RAX
-
-NESTED_END ExternalMethodFixupStub, _TEXT
-
-
 ifdef FEATURE_READYTORUN
 
 NESTED_ENTRY DelayLoad_MethodCall, _TEXT
@@ -45,8 +24,8 @@ NESTED_ENTRY DelayLoad_MethodCall, _TEXT
 
         EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
 
-        ; Share the patch label
-        jmp ExternalMethodFixupPatchLabel
+PATCH_LABEL ExternalMethodFixupPatchLabel
+        TAILJMP_RAX
 
 NESTED_END DelayLoad_MethodCall, _TEXT
 
index 217e9dd..2c8f104 100644 (file)
@@ -5,26 +5,6 @@
 #include "unixasmmacros.inc"
 #include "asmconstants.h"
 
-//============================================================================================
-// EXTERN_C VOID __stdcall ExternalMethodFixupStub()
-
-NESTED_ENTRY ExternalMethodFixupStub, _TEXT, NoHandler
-
-        PROLOG_WITH_TRANSITION_BLOCK 0, 8, rsi, 0, 0
-
-        lea             rdi, [rsp + __PWTB_TransitionBlock] // pTransitionBlock
-        sub             rsi, 5                              // pThunk
-        mov             rdx, 0                              // sectionIndex
-        mov             rcx, 0                              // pModule
-
-        call            C_FUNC(ExternalMethodFixupWorker)
-
-        EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
-PATCH_LABEL ExternalMethodFixupPatchLabel
-        TAILJMP_RAX
-
-NESTED_END ExternalMethodFixupStub, _TEXT
-
 #ifdef FEATURE_READYTORUN
 
 NESTED_ENTRY DelayLoad_MethodCall, _TEXT, NoHandler
@@ -38,8 +18,8 @@ NESTED_ENTRY DelayLoad_MethodCall, _TEXT, NoHandler
 
         EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
 
-        // Share the patch label
-        jmp C_FUNC(ExternalMethodFixupPatchLabel)
+PATCH_LABEL ExternalMethodFixupPatchLabel
+        TAILJMP_RAX
 
 NESTED_END DelayLoad_MethodCall, _TEXT
 
index d1695b2..f49ed94 100644 (file)
@@ -592,43 +592,6 @@ LOCAL_LABEL(stackProbe_loop):
     NESTED_END stackProbe, _TEXT
 
 //------------------------------------------------
-// ExternalMethodFixupStub
-//
-// In NGEN images, calls to cross-module external methods initially
-// point to a jump thunk that calls into the following function that will
-// call into a VM helper. The VM helper is responsible for patching up the
-// thunk, upon executing the precode, so that all subsequent calls go directly
-// to the actual method body.
-//
-// This is done lazily for performance reasons.
-//
-// On entry:
-//
-// R12 = Address of thunk + 4
-
-    NESTED_ENTRY ExternalMethodFixupStub, _TEXT, NoHandler
-
-    PROLOG_WITH_TRANSITION_BLOCK
-
-    add         r0, sp, #__PWTB_TransitionBlock // pTransitionBlock
-
-    // Adjust (read comment above for details) and pass the address of the thunk
-    sub         r1, r12, #4                     // pThunk
-
-    mov         r2, #0  // sectionIndex
-    mov         r3, #0  // pModule
-    bl          C_FUNC(ExternalMethodFixupWorker)
-
-    // mov the address we patched to in R12 so that we can tail call to it
-    mov         r12, r0
-
-    EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
-    PATCH_LABEL ExternalMethodFixupPatchLabel
-    bx r12
-
-    NESTED_END ExternalMethodFixupStub, _TEXT
-
-//------------------------------------------------
 // JIT_RareDisableHelper
 //
 // The JIT expects this helper to preserve registers used for return values
@@ -936,8 +899,8 @@ DelayLoad_MethodCall:
 
     EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
 
-    // Share the patch label
-    b C_FUNC(ExternalMethodFixupPatchLabel)
+    PATCH_LABEL ExternalMethodFixupPatchLabel
+    bx r12
 
     NESTED_END DelayLoad_MethodCall_FakeProlog, _TEXT
 
index db75842..0afdbf4 100644 (file)
@@ -1029,43 +1029,6 @@ stackProbe_loop
     NESTED_END
 
 ;------------------------------------------------
-; ExternalMethodFixupStub
-;
-; In NGEN images, calls to cross-module external methods initially
-; point to a jump thunk that calls into the following function that will
-; call into a VM helper. The VM helper is responsible for patching up the
-; thunk, upon executing the precode, so that all subsequent calls go directly
-; to the actual method body.
-;
-; This is done lazily for performance reasons.
-;
-; On entry:
-;
-; R12 = Address of thunk + 4
-
-    NESTED_ENTRY ExternalMethodFixupStub
-
-    PROLOG_WITH_TRANSITION_BLOCK
-
-    add         r0, sp, #__PWTB_TransitionBlock ; pTransitionBlock
-
-    ; Adjust (read comment above for details) and pass the address of the thunk
-    sub         r1, r12, #4                     ; pThunk
-
-    mov         r2, #0  ; sectionIndex
-    mov         r3, #0  ; pModule
-    bl          ExternalMethodFixupWorker
-
-    ; mov the address we patched to in R12 so that we can tail call to it
-    mov         r12, r0
-
-    EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
-    PATCH_LABEL ExternalMethodFixupPatchLabel
-    EPILOG_BRANCH_REG   r12
-
-    NESTED_END
-
-;------------------------------------------------
 ; JIT_RareDisableHelper
 ;
 ; The JIT expects this helper to preserve registers used for return values
@@ -1676,8 +1639,8 @@ DelayLoad_MethodCall
 
     EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
 
-    ; Share the patch label
-    EPILOG_BRANCH ExternalMethodFixupPatchLabel
+    PATCH_LABEL ExternalMethodFixupPatchLabel
+    EPILOG_BRANCH_REG   r12
 
     NESTED_END
 
index ac85299..937d69f 100644 (file)
@@ -500,41 +500,6 @@ LEAF_ENTRY JIT_PatchedCodeLast, _TEXT
     ret  lr
 LEAF_END JIT_PatchedCodeLast, _TEXT
 
-//------------------------------------------------
-// ExternalMethodFixupStub
-//
-// In NGEN images, calls to cross-module external methods initially
-// point to a jump thunk that calls into the following function that will
-// call into a VM helper. The VM helper is responsible for patching up the
-// thunk, upon executing the precode, so that all subsequent calls go directly
-// to the actual method body.
-//
-// This is done lazily for performance reasons.
-//
-// On entry:
-//
-// x12 = Address of thunk
-
-NESTED_ENTRY ExternalMethodFixupStub, _TEXT, NoHandler
-
-    PROLOG_WITH_TRANSITION_BLOCK
-
-    add x0, sp, #__PWTB_TransitionBlock // pTransitionBlock
-    mov x1, x12 // pThunk
-    mov x2, #0  // sectionIndex
-    mov x3, #0  // pModule
-
-    bl C_FUNC(ExternalMethodFixupWorker)
-
-    // mov the address we patched to in x12 so that we can tail call to it
-    mov x12, x0
-
-    EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
-    PATCH_LABEL ExternalMethodFixupPatchLabel
-    EPILOG_BRANCH_REG   x12
-
-NESTED_END ExternalMethodFixupStub, _TEXT
-
 // void SinglecastDelegateInvokeStub(Delegate *pThis)
 LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT
     cmp x0, #0
@@ -858,8 +823,8 @@ C_FUNC(DelayLoad_MethodCall):
     mov x12, x0
 
     EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
-    // Share patch label
-    b C_FUNC(ExternalMethodFixupPatchLabel)
+    PATCH_LABEL ExternalMethodFixupPatchLabel
+    EPILOG_BRANCH_REG   x12
 
 NESTED_END DelayLoad_MethodCall_FakeProlog, _TEXT
 
index f383c57..ee3ada0 100644 (file)
@@ -550,41 +550,6 @@ Exit
         ret      lr
     LEAF_END
 
-;------------------------------------------------
-; ExternalMethodFixupStub
-;
-; In NGEN images, calls to cross-module external methods initially
-; point to a jump thunk that calls into the following function that will
-; call into a VM helper. The VM helper is responsible for patching up the
-; thunk, upon executing the precode, so that all subsequent calls go directly
-; to the actual method body.
-;
-; This is done lazily for performance reasons.
-;
-; On entry:
-;
-; x12 = Address of thunk
-
-    NESTED_ENTRY ExternalMethodFixupStub
-
-    PROLOG_WITH_TRANSITION_BLOCK
-
-    add         x0, sp, #__PWTB_TransitionBlock ; pTransitionBlock
-    mov         x1, x12                         ; pThunk
-    mov         x2, #0                          ; sectionIndex
-    mov         x3, #0                          ; pModule
-
-    bl          ExternalMethodFixupWorker
-
-    ; mov the address we patched to in x12 so that we can tail call to it
-    mov         x12, x0
-
-    EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
-    PATCH_LABEL ExternalMethodFixupPatchLabel
-    EPILOG_BRANCH_REG   x12
-
-    NESTED_END
-
 ; void SinglecastDelegateInvokeStub(Delegate *pThis)
     LEAF_ENTRY SinglecastDelegateInvokeStub
         cmp     x0, #0
@@ -1217,8 +1182,9 @@ Fail
     mov x12, x0
 
     EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
-    ; Share patch label
-    b ExternalMethodFixupPatchLabel
+    PATCH_LABEL ExternalMethodFixupPatchLabel
+    EPILOG_BRANCH_REG   x12
+
     NESTED_END
 
     MACRO
index e9312f1..ad02efe 100644 (file)
@@ -17,7 +17,6 @@ class CrawlFrame;
 struct EE_ILEXCEPTION_CLAUSE;
 struct TransitionBlock;
 struct VASigCookie;
-struct CORCOMPILE_EXTERNAL_METHOD_THUNK;
 class ComPlusCallMethodDesc;
 
 #include <cgencpu.h>
index 20d179f..ee675c8 100644 (file)
@@ -663,47 +663,6 @@ LOCAL_LABEL(GoCallCalliWorker):
     jmp C_FUNC(GenericPInvokeCalliHelper)
 LEAF_END GenericPInvokeCalliHelper, _TEXT
 
-// ==========================================================================
-NESTED_ENTRY ExternalMethodFixupStub, _TEXT_ NoHandler
-    // pop off the return address to the stub
-    // leaving the actual caller's return address on top of the stack
-    pop     eax
-
-    STUB_PROLOG
-
-    mov         esi, esp
-
-    // EAX is return address into CORCOMPILE_EXTERNAL_METHOD_THUNK. Subtract 5 to get start address.
-    sub         eax, 5
-
-.att_syntax
-    pushl       $0
-    pushl       $0
-.intel_syntax noprefix
-
-    push        eax
-
-    // pTransitionBlock
-    push        esi
-
-    call        C_FUNC(ExternalMethodFixupWorker)
-
-    // eax now contains replacement stub. PreStubWorker will never return
-    // NULL (it throws an exception if stub creation fails.)
-
-    // From here on, mustn't trash eax
-
-    STUB_EPILOG
-
-PATCH_LABEL ExternalMethodFixupPatchLabel
-    // Tailcall target
-    jmp eax
-
-    // This will never be executed. It is just to help out stack-walking logic
-    // which disassembles the epilog to unwind the stack.
-    ret
-NESTED_END ExternalMethodFixupStub, _TEXT
-
 #ifdef FEATURE_READYTORUN
 NESTED_ENTRY DynamicHelperArgsStub, _TEXT, NoHandler
     .cfi_def_cfa_offset 16
@@ -739,8 +698,9 @@ NESTED_ENTRY DelayLoad_MethodCall, _TEXT, NoHandler
 
     STUB_EPILOG
 
-    // Share the patch label
-    jmp C_FUNC(ExternalMethodFixupPatchLabel)
+PATCH_LABEL ExternalMethodFixupPatchLabel
+    // Tailcall target
+    jmp eax
 
     // This will never be executed. It is just to help out stack-walking logic
     // which disassembles the epilog to unwind the stack.
index 896c249..9258b78 100644 (file)
@@ -47,10 +47,6 @@ EXTERN _NDirectImportWorker@4:PROC
 EXTERN _VarargPInvokeStubWorker@12:PROC
 EXTERN _GenericPInvokeCalliStubWorker@12:PROC
 
-ifndef FEATURE_CORECLR
-EXTERN _CopyCtorCallStubWorker@4:PROC
-endif
-
 EXTERN _PreStubWorker@8:PROC
 EXTERN _TheUMEntryPrestubWorker@4:PROC
 
@@ -1266,75 +1262,6 @@ FASTCALL_ENDFUNC
 
 endif ; FEATURE_COMINTEROP
 
-ifndef FEATURE_CORECLR
-
-;==========================================================================
-; This is small stub whose purpose is to record current stack pointer and
-; call CopyCtorCallStubWorker to invoke copy constructors and destructors
-; as appropriate. This stub operates on arguments already pushed to the
-; stack by JITted IL stub and must not create a new frame, i.e. it must tail
-; call to the target for it to see the arguments that copy ctors have been
-; called on.
-;
-_CopyCtorCallStub@0 proc public
-    ; there may be an argument in ecx - save it
-    push    ecx
-
-    ; push pointer to arguments
-    lea     edx, [esp + 8]
-    push    edx
-
-    call    _CopyCtorCallStubWorker@4
-
-    ; restore ecx and tail call to the target
-    pop     ecx
-    jmp     eax
-_CopyCtorCallStub@0 endp
-
-endif ; !FEATURE_CORECLR
-
-;==========================================================================
-_ExternalMethodFixupStub@0 proc public
-
-    pop     eax             ; pop off the return address to the stub
-                            ; leaving the actual caller's return address on top of the stack
-
-    STUB_PROLOG
-
-    mov         esi, esp
-
-    ; EAX is return address into CORCOMPILE_EXTERNAL_METHOD_THUNK. Subtract 5 to get start address.
-    sub         eax, 5
-
-    push        0
-    push        0
-
-    push        eax
-
-    ; pTransitionBlock
-    push        esi
-
-    call        _ExternalMethodFixupWorker@16
-
-    ; eax now contains replacement stub. PreStubWorker will never return
-    ; NULL (it throws an exception if stub creation fails.)
-
-    ; From here on, mustn't trash eax
-
-    STUB_EPILOG
-
-_ExternalMethodFixupPatchLabel@0:
-public _ExternalMethodFixupPatchLabel@0
-
-    ; Tailcall target
-    jmp eax
-
-    ; This will never be executed. It is just to help out stack-walking logic
-    ; which disassembles the epilog to unwind the stack.
-    ret
-
-_ExternalMethodFixupStub@0 endp
-
 ifdef FEATURE_READYTORUN
 ;==========================================================================
 _DelayLoad_MethodCall@0 proc public
@@ -1360,8 +1287,11 @@ _DelayLoad_MethodCall@0 proc public
 
     STUB_EPILOG
 
-    ; Share the patch label
-    jmp _ExternalMethodFixupPatchLabel@0
+_ExternalMethodFixupPatchLabel@0:
+public _ExternalMethodFixupPatchLabel@0
+
+    ; Tailcall target
+    jmp eax
 
     ; This will never be executed. It is just to help out stack-walking logic
     ; which disassembles the epilog to unwind the stack.
index 6813016..4d8d954 100644 (file)
@@ -2326,44 +2326,8 @@ static PCODE PatchNonVirtualExternalMethod(MethodDesc * pMD, PCODE pCode, PTR_CO
     }
 #endif //HAS_FIXUP_PRECODE
 
-    if (pImportSection->Flags & CORCOMPILE_IMPORT_FLAGS_CODE)
-    {
-        CORCOMPILE_EXTERNAL_METHOD_THUNK * pThunk = (CORCOMPILE_EXTERNAL_METHOD_THUNK *)pIndirection;
-
-#if defined(TARGET_X86) || defined(TARGET_AMD64)
-        INT64 oldValue = *(INT64*)pThunk;
-        BYTE* pOldValue = (BYTE*)&oldValue;
-
-        if (pOldValue[0] == X86_INSTR_CALL_REL32)
-        {
-            INT64 newValue = oldValue;
-            BYTE* pNewValue = (BYTE*)&newValue;
-            pNewValue[0] = X86_INSTR_JMP_REL32;
-
-            *(INT32 *)(pNewValue+1) = rel32UsingJumpStub((INT32*)(&pThunk->callJmp[1]), pCode, pMD, NULL);
-
-            _ASSERTE(IS_ALIGNED((size_t)pThunk, sizeof(INT64)));
-            ExecutableWriterHolder<INT64> thunkWriterHolder((INT64*)pThunk, sizeof(INT64));
-            FastInterlockCompareExchangeLong(thunkWriterHolder.GetRW(), newValue, oldValue);
-
-            FlushInstructionCache(GetCurrentProcess(), pThunk, 8);
-        }
-#elif  defined(TARGET_ARM) || defined(TARGET_ARM64)
-        // Patchup the thunk to point to the actual implementation of the cross module external method
-        pThunk->m_pTarget = pCode;
-
-        #if defined(TARGET_ARM)
-        // ThumbBit must be set on the target address
-        _ASSERTE(pCode & THUMB_CODE);
-        #endif
-#else
-        PORTABILITY_ASSERT("ExternalMethodFixupWorker");
-#endif
-    }
-    else
-    {
-        *(TADDR *)pIndirection = pCode;
-    }
+    _ASSERTE((pImportSection->Flags & CORCOMPILE_IMPORT_FLAGS_CODE) == 0);
+    *(TADDR *)pIndirection = pCode;
 
     return pCode;
 }
@@ -2468,17 +2432,9 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl
         }
         _ASSERTE(pImportSection != NULL);
 
-        COUNT_T index;
-        if (pImportSection->Flags & CORCOMPILE_IMPORT_FLAGS_CODE)
-        {
-            _ASSERTE(pImportSection->EntrySize == sizeof(CORCOMPILE_EXTERNAL_METHOD_THUNK));
-            index = (rva - pImportSection->Section.VirtualAddress) / sizeof(CORCOMPILE_EXTERNAL_METHOD_THUNK);
-        }
-        else
-        {
-            _ASSERTE(pImportSection->EntrySize == sizeof(TADDR));
-            index = (rva - pImportSection->Section.VirtualAddress) / sizeof(TADDR);
-        }
+        _ASSERTE((pImportSection->Flags & CORCOMPILE_IMPORT_FLAGS_CODE) == 0);
+        _ASSERTE(pImportSection->EntrySize == sizeof(TADDR));
+        COUNT_T index = (rva - pImportSection->Section.VirtualAddress) / sizeof(TADDR);
 
         PTR_DWORD pSignatures = dac_cast<PTR_DWORD>(pNativeImage->GetRvaData(pImportSection->Signatures));