Permalink
Browse files

Add getMethodTable and getBaseSize to CorInfo

  • Loading branch information...
xoofx committed Oct 1, 2015
1 parent c65ac4f commit 381d422e4cadac50468b1d47c95ed8548bb74b97
Showing with 79 additions and 4 deletions.
  1. +8 −1 src/inc/corinfo.h
  2. +34 −0 src/vm/jitinterface.cpp
  3. +6 −1 src/vm/jitinterface.h
  4. +27 −0 src/zap/zapinfo.cpp
  5. +4 −2 src/zap/zapinfo.h
@@ -2866,7 +2866,10 @@ class ICorStaticInfo
// Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & CORINFO_FLG_VALUECLASS, except faster.
virtual BOOL isValueClass(CORINFO_CLASS_HANDLE cls) = 0;

// If this method returns true, JIT will do optimization to inline the check for
// getMethodTable
virtual void* getMethodTable(CORINFO_CLASS_HANDLE cls) = 0;

// If this method returns true, JIT will do optimization to inline the check for
// GetTypeFromHandle(handle) == obj.GetType()
virtual BOOL canInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE cls) = 0;

@@ -2910,6 +2913,10 @@ class ICorStaticInfo
void **ppIndirection
) = 0;

virtual unsigned getBaseSize(
CORINFO_CLASS_HANDLE cls
) = 0;

// return the number of bytes needed by an instance of the class
virtual unsigned getClassSize (
CORINFO_CLASS_HANDLE cls
@@ -2290,6 +2290,29 @@ CEEInfo::findSig(

//---------------------------------------------------------------------------------------
//
unsigned
CEEInfo::getBaseSize(
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);
result = VMClsHnd.GetMethodTable()->GetBaseSize();

EE_TO_JIT_TRANSITION_LEAF();

return result;
}

unsigned
CEEInfo::getClassSize(
CORINFO_CLASS_HANDLE clsHnd)
@@ -8918,6 +8941,17 @@ CONTRACTL {
return result;
}

void* CEEInfo::getMethodTable(CORINFO_CLASS_HANDLE classHnd)
{
JIT_TO_EE_TRANSITION_LEAF();

TypeHandle VMClsHnd(classHnd);
void* pMethodTable = VMClsHnd.GetMethodTable();
EE_TO_JIT_TRANSITION_LEAF();

return pMethodTable;
}

/*********************************************************************/
void CEEInfo::getMethodVTableOffset (CORINFO_METHOD_HANDLE methodHnd,
unsigned * pOffsetOfIndirection,
@@ -475,6 +475,10 @@ class CEEInfo : public ICorJitInfo
BOOL fFullInst,
BOOL fAssembly);
BOOL isValueClass (CORINFO_CLASS_HANDLE cls);

// Returns the method handle for a class as an opaque pointer
void* getMethodTable(CORINFO_CLASS_HANDLE classHnd);

BOOL canInlineTypeCheckWithObjectVTable (CORINFO_CLASS_HANDLE cls);

DWORD getClassAttribs (CORINFO_CLASS_HANDLE cls);
@@ -484,7 +488,8 @@ class CEEInfo : public ICorJitInfo

BOOL isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls);

unsigned getClassSize (CORINFO_CLASS_HANDLE cls);
unsigned getBaseSize(CORINFO_CLASS_HANDLE cls);
unsigned getClassSize (CORINFO_CLASS_HANDLE cls);
unsigned getClassAlignmentRequirement(CORINFO_CLASS_HANDLE cls, BOOL fDoubleAlignHint);
static unsigned getClassAlignmentRequirementStatic(TypeHandle clsHnd);

@@ -3822,6 +3822,12 @@ BOOL ZapInfo::isValueClass(CORINFO_CLASS_HANDLE cls)
return m_pEEJitInfo->isValueClass(cls);
}

void* ZapInfo::getMethodTable(CORINFO_CLASS_HANDLE cls)
{
return m_pEEJitInfo->getMethodTable(cls);
}


BOOL ZapInfo::canInlineTypeCheckWithObjectVTable (CORINFO_CLASS_HANDLE cls)
{
#ifdef MDIL
@@ -4165,6 +4171,27 @@ size_t ZapInfo::getClassModuleIdForStatics(CORINFO_CLASS_HANDLE cls, CORINFO_MOD
return NULL;
}


unsigned ZapInfo::getBaseSize(CORINFO_CLASS_HANDLE cls)
{
DWORD size = m_pEEJitInfo->getBaseSize(cls);

#ifdef FEATURE_READYTORUN_COMPILER
if (IsReadyToRunCompilation())
{
if (m_pEECompileInfo->NeedsTypeLayoutCheck(cls))
{
ZapImport * pImport = m_pImage->GetImportTable()->GetCheckTypeLayoutImport(cls);
AppendImport(pImport);

m_ClassLoadTable.Load(cls, TRUE);
}
}
#endif

return size;
}

unsigned ZapInfo::getClassSize(CORINFO_CLASS_HANDLE cls)
{
DWORD size = m_pEEJitInfo->getClassSize(cls);
@@ -571,7 +571,8 @@ class ZapInfo
BOOL fFullInst,
BOOL fAssembly);
BOOL isValueClass(CORINFO_CLASS_HANDLE clsHnd);
BOOL canInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE clsHnd);
void* getMethodTable(CORINFO_CLASS_HANDLE cls);
BOOL canInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE clsHnd);
DWORD getClassAttribs(CORINFO_CLASS_HANDLE cls);
BOOL isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls);
CORINFO_MODULE_HANDLE getClassModule(CORINFO_CLASS_HANDLE cls);
@@ -581,7 +582,8 @@ class ZapInfo
void LongLifetimeFree(void* obj);
size_t getClassModuleIdForStatics(CORINFO_CLASS_HANDLE cls, CORINFO_MODULE_HANDLE *pModule, void **ppIndirection);

unsigned getClassSize(CORINFO_CLASS_HANDLE cls);
unsigned getBaseSize(CORINFO_CLASS_HANDLE cls);
unsigned getClassSize(CORINFO_CLASS_HANDLE cls);
unsigned getClassAlignmentRequirement(CORINFO_CLASS_HANDLE cls, BOOL fDoubleAlignHint);

CORINFO_FIELD_HANDLE getFieldInClass(CORINFO_CLASS_HANDLE clsHnd, INT num);

0 comments on commit 381d422

Please sign in to comment.