diff options
author | Eugene Rozenfeld <erozen@microsoft.com> | 2018-10-11 13:03:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-11 13:03:26 -0700 |
commit | 5f9f37432568b9abd91de39949ae860e9151798e (patch) | |
tree | d526a60db61b6add23c2c3c90a3ca7f3c6eaa35d /src/vm/jitinterface.cpp | |
parent | 5c039559b96bf71e4281331977160ff4c8c44af8 (diff) | |
download | coreclr-5f9f37432568b9abd91de39949ae860e9151798e.tar.gz coreclr-5f9f37432568b9abd91de39949ae860e9151798e.tar.bz2 coreclr-5f9f37432568b9abd91de39949ae860e9151798e.zip |
JitEE interface additions to support object stack allocation. (#20283)
Add two methods to JitEE interface: getHeapClassSize and canAllocateOnStack.
Change JITEEVersionIdentifier.
Diffstat (limited to 'src/vm/jitinterface.cpp')
-rw-r--r-- | src/vm/jitinterface.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index 7532f5e9aa..f52009ac3f 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -1937,6 +1937,72 @@ CEEInfo::getClassSize( return result; } +//--------------------------------------------------------------------------------------- +// +// Get the size of a reference type as allocated on the heap. This includes the size of the fields +// (and any padding between the fields) and the size of a method table pointer but doesn't include +// object header size or any padding for minimum size. +unsigned +CEEInfo::getHeapClassSize( + CORINFO_CLASS_HANDLE clsHnd) +{ + CONTRACTL{ + SO_TOLERANT; + NOTHROW; + GC_NOTRIGGER; + MODE_PREEMPTIVE; + } CONTRACTL_END; + + unsigned result = 0; + + JIT_TO_EE_TRANSITION_LEAF(); + + TypeHandle VMClsHnd(clsHnd); + MethodTable* pMT = VMClsHnd.GetMethodTable(); + _ASSERTE(pMT); + _ASSERTE(!pMT->IsValueType()); + + // Add OBJECT_SIZE to account for method table pointer. + result = pMT->GetNumInstanceFieldBytes() + OBJECT_SIZE; + + EE_TO_JIT_TRANSITION_LEAF(); + return result; +} + +//--------------------------------------------------------------------------------------- +// +// Return TRUE if an object of this type can be allocated on the stack. +BOOL CEEInfo::canAllocateOnStack(CORINFO_CLASS_HANDLE clsHnd) +{ + CONTRACTL{ + SO_TOLERANT; + NOTHROW; + GC_NOTRIGGER; + MODE_PREEMPTIVE; + } CONTRACTL_END; + + BOOL result = FALSE; + + JIT_TO_EE_TRANSITION_LEAF(); + + TypeHandle VMClsHnd(clsHnd); + MethodTable* pMT = VMClsHnd.GetMethodTable(); + _ASSERTE(pMT); + _ASSERTE(!pMT->IsValueType()); + + result = !pMT->HasFinalizer(); + +#ifdef FEATURE_READYTORUN_COMPILER + if (IsReadyToRunCompilation() && !pMT->IsInheritanceChainLayoutFixedInCurrentVersionBubble()) + { + result = false; + } +#endif + + EE_TO_JIT_TRANSITION_LEAF(); + return result; +} + unsigned CEEInfo::getClassAlignmentRequirement(CORINFO_CLASS_HANDLE type, BOOL fDoubleAlignHint) { CONTRACTL { |