コード例 #1
0
// --------------------------------------------------------------------------------------
// 
// Initialize iteration on heaps directory (hotHeapsDirectoryData) with heap hot data (hotHeapsData).
// The caller guarantees that the heap hot data end where heaps directory beggins.
// 
void 
HotHeapsDirectoryIterator::Initialize(
    DataBuffer hotHeapsDirectoryData, 
    DataBuffer hotHeapsData)
{
    _ASSERTE(hotHeapsData.GetDataPointerBehind() == hotHeapsDirectoryData.GetDataPointer());
    m_RemainingHeapsDirectoryData = hotHeapsDirectoryData;
    m_HotHeapsData = hotHeapsData;
} // HotHeapsDirectoryIterator::Initialize
コード例 #2
0
ファイル: hotheap.cpp プロジェクト: 0-wiz-0/coreclr
// --------------------------------------------------------------------------------------
// 
// Initializes hot heap from its header and data.
// Provides limited debug-only validation of the structure.
// 
__checkReturn 
HRESULT 
HotHeap::Initialize(
    struct HotHeapHeader *pHotHeapHeader, 
    DataBuffer            hotHeapData)
{
    _ASSERTE(hotHeapData.GetDataPointerBehind() == reinterpret_cast<BYTE *>(pHotHeapHeader));
    
    UINT32 nMaximumNegativeOffset = hotHeapData.GetSize();
    if (pHotHeapHeader->m_nIndexTableStart_NegativeOffset > nMaximumNegativeOffset)
    {
        m_pHotHeapHeader = NULL;
        Debug_ReportError("Invalid hot heap header format - invalid index table offset.");
        return METADATA_E_INVALID_FORMAT;
    }
    if ((pHotHeapHeader->m_nIndexTableStart_NegativeOffset % 4) != 0)
    {
        m_pHotHeapHeader = NULL;
        Debug_ReportError("Invalid hot heap header format - index table offset is not aligned.");
        return METADATA_E_INVALID_FORMAT;
    }
    if (pHotHeapHeader->m_nValueOffsetTableStart_NegativeOffset > nMaximumNegativeOffset)
    {
        m_pHotHeapHeader = NULL;
        Debug_ReportError("Invalid hot heap header format - invalid value offset table offset.");
        return METADATA_E_INVALID_FORMAT;
    }
    if ((pHotHeapHeader->m_nValueOffsetTableStart_NegativeOffset % 4) != 0)
    {
        m_pHotHeapHeader = NULL;
        Debug_ReportError("Invalid hot heap header format - value offset table offset is not aligned.");
        return METADATA_E_INVALID_FORMAT;
    }
    // Index table has to be behind value offset table
    if (pHotHeapHeader->m_nValueOffsetTableStart_NegativeOffset < pHotHeapHeader->m_nIndexTableStart_NegativeOffset)
    {
        m_pHotHeapHeader = NULL;
        Debug_ReportError("Invalid hot heap header format - value offset table doesn't start before index table.");
        return METADATA_E_INVALID_FORMAT;
    }
    if (pHotHeapHeader->m_nValueHeapStart_NegativeOffset > nMaximumNegativeOffset)
    {
        m_pHotHeapHeader = NULL;
        Debug_ReportError("Invalid hot heap header format - invalid value heap offset.");
        return METADATA_E_INVALID_FORMAT;
    }
    m_pHotHeapHeader = pHotHeapHeader;
    return S_OK;
} // HotHeap::Initialize