[x86/linux] Implement BackPatchWorkerAsmStub (dotnet/coreclr#9690)
authorYongseop Kim <yons.kim@samsung.com>
Tue, 28 Feb 2017 09:25:10 +0000 (18:25 +0900)
committerJan Vorlicek <janvorli@microsoft.com>
Tue, 28 Feb 2017 09:25:10 +0000 (10:25 +0100)
* [x86/linux] Implement BackPatchWorkerAsmStub

This implementation is ported from BackPatchWorkerAsmStub in
vm/i386/virtualcallstubcpu.hpp

Commit migrated from https://github.com/dotnet/coreclr/commit/e9ad7cf9690fdca6f4f3f1b6bafdebe9406db9b7

src/coreclr/src/vm/i386/asmhelpers.S
src/coreclr/src/vm/i386/unixstubs.cpp
src/coreclr/src/vm/virtualcallstub.cpp
src/coreclr/src/vm/virtualcallstub.h

index 89e946d..921e09f 100644 (file)
@@ -1104,3 +1104,26 @@ LOCAL_LABEL(fail):
 
 NESTED_END ResolveWorkerChainLookupAsmStub, _TEXT
 #endif // CROSSGEN_COMPILE
+
+// backpatch a call site to point to a different stub
+NESTED_ENTRY BackPatchWorkerAsmStub, _TEXT, NoHandler
+    PROLOG_BEG
+    PROLOG_PUSH eax // it may contain siteAddrForRegisterIndirect
+    PROLOG_PUSH ecx
+    PROLOG_PUSH edx
+    PROLOG_END
+
+    sub     esp, 4     //  for 16 bytes align
+    push    eax        //  push any indirect call address as the second arg to BackPatchWorker
+    push    [ebp+8]    //  and push return address as the first arg to BackPatchWorker
+
+    call    C_FUNC(BackPatchWorkerStaticStub)
+    add     esp, 12
+
+    EPILOG_BEG
+    EPILOG_POP edx
+    EPILOG_POP ecx
+    EPILOG_POP eax
+    EPILOG_END
+    ret
+NESTED_END BackPatchWorkerAsmStub, _TEXT
index 9705ab0..8441b07 100644 (file)
@@ -31,11 +31,6 @@ extern "C"
     }
 };
 
-EXTERN_C VOID BackPatchWorkerAsmStub()
-{
-    PORTABILITY_ASSERT("BackPatchWorkerAsmStub");
-}
-
 EXTERN_C VOID JIT_TailCall()
 {
   PORTABILITY_ASSERT("JIT_TailCall");
index 6681b31..01b15c6 100644 (file)
@@ -4047,3 +4047,10 @@ BOOL VirtualCallStubManagerManager::TraceManager(
     // Forward the call to the appropriate manager.
     return pMgr->TraceManager(thread, trace, pContext, pRetAddr);
 }
+
+#if defined(_TARGET_X86_) && defined(FEATURE_PAL)
+void BackPatchWorkerStaticStub(PCODE returnAddr, TADDR siteAddrForRegisterIndirect)
+{
+    VirtualCallStubManager::BackPatchWorkerStatic(returnAddr, siteAddrForRegisterIndirect);
+}
+#endif
index 4bdc1da..7b6fedf 100644 (file)
@@ -164,6 +164,9 @@ extern "C" void ResolveWorkerChainLookupAsmStub();    // for chaining of entries
 
 #ifdef _TARGET_X86_ 
 extern "C" void BackPatchWorkerAsmStub();             // backpatch a call site to point to a different stub
+#ifdef FEATURE_PAL
+extern "C" void BackPatchWorkerStaticStub(PCODE returnAddr, TADDR siteAddrForRegisterIndirect);
+#endif // FEATURE_PAL
 #endif // _TARGET_X86_
 
 
@@ -548,6 +551,10 @@ private:
 #endif                            
                                    );
 
+#if defined(_TARGET_X86_) && defined(FEATURE_PAL)
+    friend void BackPatchWorkerStaticStub(PCODE returnAddr, TADDR siteAddrForRegisterIndirect);
+#endif
+
     //These are the entrypoints that the stubs actually end up calling via the
     // xxxAsmStub methods above
     static void STDCALL BackPatchWorkerStatic(PCODE returnAddr, TADDR siteAddrForRegisterIndirect);