From: Yongseop Kim Date: Tue, 28 Feb 2017 09:25:10 +0000 (+0900) Subject: [x86/linux] Implement BackPatchWorkerAsmStub (dotnet/coreclr#9690) X-Git-Tag: submit/tizen/20210909.063632~11030^2~7923 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9e87f2f791de309af70587a76771b7f028036e8;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [x86/linux] Implement BackPatchWorkerAsmStub (dotnet/coreclr#9690) * [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 --- diff --git a/src/coreclr/src/vm/i386/asmhelpers.S b/src/coreclr/src/vm/i386/asmhelpers.S index 89e946d..921e09f 100644 --- a/src/coreclr/src/vm/i386/asmhelpers.S +++ b/src/coreclr/src/vm/i386/asmhelpers.S @@ -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 diff --git a/src/coreclr/src/vm/i386/unixstubs.cpp b/src/coreclr/src/vm/i386/unixstubs.cpp index 9705ab0..8441b07 100644 --- a/src/coreclr/src/vm/i386/unixstubs.cpp +++ b/src/coreclr/src/vm/i386/unixstubs.cpp @@ -31,11 +31,6 @@ extern "C" } }; -EXTERN_C VOID BackPatchWorkerAsmStub() -{ - PORTABILITY_ASSERT("BackPatchWorkerAsmStub"); -} - EXTERN_C VOID JIT_TailCall() { PORTABILITY_ASSERT("JIT_TailCall"); diff --git a/src/coreclr/src/vm/virtualcallstub.cpp b/src/coreclr/src/vm/virtualcallstub.cpp index 6681b31..01b15c6 100644 --- a/src/coreclr/src/vm/virtualcallstub.cpp +++ b/src/coreclr/src/vm/virtualcallstub.cpp @@ -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 diff --git a/src/coreclr/src/vm/virtualcallstub.h b/src/coreclr/src/vm/virtualcallstub.h index 4bdc1da..7b6fedf 100644 --- a/src/coreclr/src/vm/virtualcallstub.h +++ b/src/coreclr/src/vm/virtualcallstub.h @@ -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);