diff options
author | Fadi Hanna <fadim@microsoft.com> | 2018-11-13 12:44:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-13 12:44:49 -0800 |
commit | d2cd0df600cfa697d30cf7ef5a7cf1c3c33b9959 (patch) | |
tree | 5780e415551b7aa0d43cc18d04c977c014a4d3a3 /src/zap | |
parent | d8bfe11f24598e6e909e6e49aea8fba3925c91b7 (diff) | |
download | coreclr-d2cd0df600cfa697d30cf7ef5a7cf1c3c33b9959.tar.gz coreclr-d2cd0df600cfa697d30cf7ef5a7cf1c3c33b9959.tar.bz2 coreclr-d2cd0df600cfa697d30cf7ef5a7cf1c3c33b9959.zip |
Optimize vtable calls (#20696)
* Implementation of R2R vtable call thunks. These thunks will fetch the target code pointer from the vtable of the input thisPtr, and jump to that address.
This is especially helpful with generics, since we can avoid a generic dictionary lookup cost for a simple vtable call.
Overall, these thunks cause the CPU to have less branch mispredictions, and give a small performance boost to vtable calls.
These stubs are under VirtualCallStubManager so that the managed debugger can handle stepping through them.
Diffstat (limited to 'src/zap')
-rw-r--r-- | src/zap/zapinfo.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp index 8efeedded6..e0acd819c9 100644 --- a/src/zap/zapinfo.cpp +++ b/src/zap/zapinfo.cpp @@ -2145,29 +2145,28 @@ void ZapInfo::getCallInfo(CORINFO_RESOLVED_TOKEN * pResolvedToken, return; } -#ifdef FEATURE_READYTORUN_COMPILER if (IsReadyToRunCompilation()) { ZapImport * pImport = m_pImage->GetImportTable()->GetStubDispatchCell(pResolvedToken); pResult->stubLookup.constLookup.accessType = IAT_PVALUE; pResult->stubLookup.constLookup.addr = pImport; - break; } -#endif - - CORINFO_CLASS_HANDLE calleeOwner = pResolvedToken->hClass; - CORINFO_METHOD_HANDLE callee = pResolvedToken->hMethod; - _ASSERTE(callee == pResult->hMethod); + else + { - // - // Create the indirection cell - // - pTarget = m_pImage->GetImportTable()->GetStubDispatchCell(calleeOwner, callee); + CORINFO_CLASS_HANDLE calleeOwner = pResolvedToken->hClass; + CORINFO_METHOD_HANDLE callee = pResolvedToken->hMethod; + _ASSERTE(callee == pResult->hMethod); - pResult->stubLookup.constLookup.accessType = IAT_PVALUE; + // + // Create the indirection cell + // + pTarget = m_pImage->GetImportTable()->GetStubDispatchCell(calleeOwner, callee); - pResult->stubLookup.constLookup.addr = pTarget; + pResult->stubLookup.constLookup.accessType = IAT_PVALUE; + pResult->stubLookup.constLookup.addr = pTarget; + } } break; @@ -2183,7 +2182,6 @@ void ZapInfo::getCallInfo(CORINFO_RESOLVED_TOKEN * pResolvedToken, return; case CORINFO_CALL: -#ifdef FEATURE_READYTORUN_COMPILER if (IsReadyToRunCompilation()) { // Constrained token is not interesting with this transforms @@ -2207,12 +2205,11 @@ void ZapInfo::getCallInfo(CORINFO_RESOLVED_TOKEN * pResolvedToken, pResult->codePointerLookup.constLookup.accessType = IAT_PVALUE; pResult->codePointerLookup.constLookup.addr = pImport; } -#endif break; case CORINFO_VIRTUALCALL_VTABLE: - // READYTORUN: FUTURE: support for vtable-based calls (currently, only calls within the CoreLib version bubble is supported, and the codegen we generate - // is the same as the fragile NI (because CoreLib and the runtime will always be updated together anyways - this is a special case) + // Only calls within the CoreLib version bubble support fragile NI codegen with vtable based calls, for better performance (because + // CoreLib and the runtime will always be updated together anyways - this is a special case) break; case CORINFO_VIRTUALCALL_LDVIRTFTN: @@ -2240,7 +2237,6 @@ void ZapInfo::getCallInfo(CORINFO_RESOLVED_TOKEN * pResolvedToken, break; } -#ifdef FEATURE_READYTORUN_COMPILER if (IsReadyToRunCompilation() && pResult->sig.hasTypeArg()) { if (pResult->exactContextNeedsRuntimeLookup) @@ -2272,8 +2268,8 @@ void ZapInfo::getCallInfo(CORINFO_RESOLVED_TOKEN * pResolvedToken, AppendConditionalImport(pImport); } } -#endif } + BOOL ZapInfo::canAccessFamily(CORINFO_METHOD_HANDLE hCaller, CORINFO_CLASS_HANDLE hInstanceType) { @@ -2285,7 +2281,6 @@ BOOL ZapInfo::isRIDClassDomainID (CORINFO_CLASS_HANDLE cls) return m_pEEJitInfo->isRIDClassDomainID(cls); } - unsigned ZapInfo::getClassDomainID (CORINFO_CLASS_HANDLE cls, void **ppIndirection) { _ASSERTE(ppIndirection != NULL); |