Exemplo n.º 1
0
//------------------------------------------------------------------------
// Compiler::unwindReserveFuncHelper: Reserve the unwind information from the VM for a
// given main function or funclet, for either the hot or the cold section.
//
// Arguments:
//    func      - The main function or funclet to reserve unwind info for.
//    isHotCode - 'true' to reserve the hot section, 'false' to reserve the cold section.
//
void Compiler::unwindReserveFuncHelper(FuncInfoDsc* func, bool isHotCode)
{
    DWORD unwindCodeBytes = 0;
    if (isHotCode)
    {
#ifdef UNIX_AMD64_ABI
        if ((opts.eeFlags & CORJIT_FLG_CFI_UNWIND) != 0)
        {
            unwindCodeBytes = func->cfiCodes->size() * sizeof(CFI_CODE);
        }
        else
#endif // UNIX_AMD64_ABI
        {
            assert(func->unwindHeader.Version == 1); // Can't call this before unwindBegProlog
            assert(func->unwindHeader.CountOfUnwindCodes == 0); // Only call this once per prolog

            // Set the size of the prolog to be the last encoded action
            if (func->unwindCodeSlot < sizeof(func->unwindCodes))
            {
                UNWIND_CODE * code = (UNWIND_CODE*)&func->unwindCodes[func->unwindCodeSlot];
                func->unwindHeader.SizeOfProlog = code->CodeOffset;
            }
            else
            {
                func->unwindHeader.SizeOfProlog = 0;
            }
            func->unwindHeader.CountOfUnwindCodes = (BYTE)((sizeof(func->unwindCodes) - func->unwindCodeSlot) / sizeof(UNWIND_CODE));

            // Prepend the unwindHeader onto the unwind codes
            assert(func->unwindCodeSlot >= offsetof(UNWIND_INFO, UnwindCode));

            func->unwindCodeSlot -= offsetof(UNWIND_INFO, UnwindCode);
            UNWIND_INFO * pHeader = (UNWIND_INFO*)&func->unwindCodes[func->unwindCodeSlot];
            memcpy(pHeader, &func->unwindHeader, offsetof(UNWIND_INFO, UnwindCode));

            unwindCodeBytes = sizeof(func->unwindCodes) - func->unwindCodeSlot;
        }
    }

    BOOL isFunclet = (func->funKind != FUNC_ROOT);
    BOOL isColdCode = isHotCode ? FALSE : TRUE;

    eeReserveUnwindInfo(isFunclet, isColdCode, unwindCodeBytes);
}
Exemplo n.º 2
0
//------------------------------------------------------------------------
// Compiler::unwindReserveFuncHelper: Reserve the unwind information from the VM for a
// given main function or funclet, for either the hot or the cold section.
//
// Arguments:
//    func      - The main function or funclet to reserve unwind info for.
//    isHotCode - 'true' to reserve the hot section, 'false' to reserve the cold section.
//
void Compiler::unwindReserveFuncHelper(FuncInfoDsc* func, bool isHotCode)
{
    DWORD unwindCodeBytes;

    if (isHotCode)
    {
        // Set the size of the prolog to be the last encoded action
        if (func->unwindCodeSlot < sizeof(func->unwindCodes))
        {
            UNWIND_CODE * code = (UNWIND_CODE*)&func->unwindCodes[func->unwindCodeSlot];
            func->unwindHeader.SizeOfProlog = code->CodeOffset;
        }
        else
        {
            func->unwindHeader.SizeOfProlog = 0;
        }
        func->unwindHeader.CountOfUnwindCodes = (BYTE)((sizeof(func->unwindCodes) - func->unwindCodeSlot) / sizeof(UNWIND_CODE));

        // Prepend the unwindHeader onto the unwind codes
        assert(func->unwindCodeSlot >= offsetof(UNWIND_INFO, UnwindCode));

        func->unwindCodeSlot -= offsetof(UNWIND_INFO, UnwindCode);
        UNWIND_INFO * pHeader = (UNWIND_INFO*)&func->unwindCodes[func->unwindCodeSlot];
        memcpy(pHeader, &func->unwindHeader, offsetof(UNWIND_INFO, UnwindCode));

        unwindCodeBytes = sizeof(func->unwindCodes) - func->unwindCodeSlot;
    }
    else
    {
        unwindCodeBytes = 0;
    }

    BOOL isFunclet = (func->funKind != FUNC_ROOT);
    BOOL isColdCode = isHotCode ? FALSE : TRUE;

    eeReserveUnwindInfo(isFunclet, isColdCode, unwindCodeBytes);
}