diff options
author | Fadi Hanna <fadim@microsoft.com> | 2019-04-01 12:07:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-01 12:07:47 -0700 |
commit | bc9248cad132fa01dd2b641b6b22849bc7a05457 (patch) | |
tree | 5d1ee71059353a66004fc7a4d2501a7452db849f /src/vm/methodtable.cpp | |
parent | ff43a803a814eaaa5eba02cafa4a91def3e4c7be (diff) | |
download | coreclr-bc9248cad132fa01dd2b641b6b22849bc7a05457.tar.gz coreclr-bc9248cad132fa01dd2b641b6b22849bc7a05457.tar.bz2 coreclr-bc9248cad132fa01dd2b641b6b22849bc7a05457.zip |
Enable R2R compilation/inlining of PInvoke stubs where no marshalling is required (#22560)
* These changes enable the inlining of some PInvokes that do not require any marshalling. With inlined pinvokes, R2R performance should become slightly better, since we'll avoid jitting some of the pinvoke IL stubs that we jit today for S.P.CoreLib. Performance gains not yet measured.
* Added JIT_PInvokeBegin/End helpers for all architectures. Linux stubs not yet implemented
* Add INLINE_GETTHREAD for arm/arm64
* Set CORJIT_FLAG_USE_PINVOKE_HELPERS jit flag for ReadyToRun compilations
* Updating R2RDump tool to handle pinvokes
Diffstat (limited to 'src/vm/methodtable.cpp')
-rw-r--r-- | src/vm/methodtable.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp index 0589cb28ce..208c734f4e 100644 --- a/src/vm/methodtable.cpp +++ b/src/vm/methodtable.cpp @@ -10159,6 +10159,54 @@ static BOOL ComputeIsLayoutFixedInCurrentVersionBubble(MethodTable * pMT) return TRUE; } +static BOOL ComputeIsLayoutInCurrentVersionBubble(MethodTable* pMT) +{ + if (pMT->IsTruePrimitive() || pMT->IsEnum()) + return TRUE; + + if (!pMT->GetModule()->IsInCurrentVersionBubble()) + return FALSE; + + ApproxFieldDescIterator fieldIterator(pMT, ApproxFieldDescIterator::INSTANCE_FIELDS); + for (FieldDesc *pFD = fieldIterator.Next(); pFD != NULL; pFD = fieldIterator.Next()) + { + MethodTable * pFieldMT = pFD->GetApproxFieldTypeHandleThrowing().AsMethodTable(); + if (!pFieldMT->IsLayoutInCurrentVersionBubble()) + return FALSE; + } + + if (!pMT->IsValueType()) + { + pMT = pMT->GetParentMethodTable(); + + while ((pMT != g_pObjectClass) && (pMT != NULL)) + { + if (!pMT->IsLayoutInCurrentVersionBubble()) + return FALSE; + + pMT = pMT->GetParentMethodTable(); + } + } + + return TRUE; +} + +BOOL MethodTable::IsLayoutInCurrentVersionBubble() +{ + STANDARD_VM_CONTRACT; + + const MethodTableWriteableData * pWriteableData = GetWriteableData(); + if (!(pWriteableData->m_dwFlags & MethodTableWriteableData::enum_flag_NGEN_IsLayoutInCurrentVersionBubbleComputed)) + { + MethodTableWriteableData * pWriteableDataForWrite = GetWriteableDataForWrite(); + if (ComputeIsLayoutInCurrentVersionBubble(this)) + *EnsureWritablePages(&pWriteableDataForWrite->m_dwFlags) |= MethodTableWriteableData::enum_flag_NGEN_IsLayoutInCurrentVersionBubble; + *EnsureWritablePages(&pWriteableDataForWrite->m_dwFlags) |= MethodTableWriteableData::enum_flag_NGEN_IsLayoutInCurrentVersionBubbleComputed; + } + + return (pWriteableData->m_dwFlags & MethodTableWriteableData::enum_flag_NGEN_IsLayoutInCurrentVersionBubble) != 0; +} + // // Is field layout in this type fixed within the current version bubble? // This check does not take the inheritance chain into account. |