ronantakizawa/codereview-bench huggingface dataset:
Repository: dotnet/runtime
File: src/coreclr/vm/perfmap.cpp (C++)

Code before:
}

// Disable the map for the process - called from EEShutdownHelper.
void PerfMap::Disable()
{
    LIMITED_METHOD_CONTRACT;

    if (s_enabled)
    {
        CrstHolder ch(&(s_csPerfMap));

        s_enabled = false;
        if (s_Current != nullptr)
        {
            delete s_Current;
            s_Current = nullptr;
        }

        // PAL_PerfJitDump_Finish is lock protected and can safely be called multiple times
        PAL_PerfJitDump_Finish();
    }
}

// Signal that all dependencies (AppDomain, ExecutionManager) are ready.
// Called from EEStartup after ExecutionManager::Init.
void PerfMap::SignalSendExistingReady()
{
    LIMITED_METHOD_CONTRACT;

    s_sendExistingReady = true;
}

// Construct a new map for the process.
PerfMap::PerfMap()
{
    LIMITED_METHOD_CONTRACT;

    // Initialize with no failures.
    m_ErrorEncountered = false;
}

// Clean-up resources.
PerfMap::~PerfMap()
{
    LIMITED_METHOD_CONTRACT;

    fclose(m_fp);
    m_fp = nullptr;
}

void PerfMap::OpenFileForPid(int pid, const char* basePath)

Review comment (suggestion):
```suggestion
void PerfMap::SignalDependenciesReady()
```
Would this be a better name to captures the intent?

When I see "SignalSendExistingReady", I think "anything that already exists and is in a ready state — go ahead and process it". It is not what this method does.

Code after:
}

// Disable the map for the process - called from EEShutdownHelper.
void PerfMap::Disable()
{
    LIMITED_METHOD_CONTRACT;

    if (s_enabled)
    {
        CrstHolder ch(&(s_csPerfMap));

        s_enabled = false;
        if (s_Current != nullptr)
        {
            delete s_Current;
            s_Current = nullptr;
        }

        // PAL_PerfJitDump_Finish is lock protected and can safely be called multiple times
        PAL_PerfJitDump_Finish();
    }
}

// Signal that all dependencies (AppDomain, ExecutionManager) are ready.
// This method must be called before any code is JITed or restored from R2R image.
void PerfMap::SignalDependenciesReady()
{
    LIMITED_METHOD_CONTRACT;

    s_dependenciesReady = true;
}

// Construct a new map for the process.
PerfMap::PerfMap()
{
    LIMITED_METHOD_CONTRACT;

    // Initialize with no failures.
    m_ErrorEncountered = false;
}

// Clean-up resources.
PerfMap::~PerfMap()
{
    LIMITED_METHOD_CONTRACT;

    fclose(m_fp);
    m_fp = nullptr;
}

void PerfMap::OpenFileForPid(int pid, const char* basePath)
Repository: dotnet/runtime
File: src/coreclr/vm/perfmap.cpp (C++)

Code before:
        }
    }
}

// Disable the map for the process - called from EEShutdownHelper.
void PerfMap::Disable()
{
    LIMITED_METHOD_CONTRACT;

    if (s_enabled)
    {
        CrstHolder ch(&(s_csPerfMap));

        s_enabled = false;
        if (s_Current != nullptr)
        {
            delete s_Current;
            s_Current = nullptr;
        }

        // PAL_PerfJitDump_Finish is lock protected and can safely be called multiple times
        PAL_PerfJitDump_Finish();
    }
}

// Signal that all dependencies (AppDomain, ExecutionManager) are ready.
// Called from EEStartup after ExecutionManager::Init.
void PerfMap::SignalSendExistingReady()
{
    LIMITED_METHOD_CONTRACT;

    s_sendExistingReady = true;
}

// Construct a new map for the process.
PerfMap::PerfMap()
{
    LIMITED_METHOD_CONTRACT;

    // Initialize with no failures.
    m_ErrorEncountered = false;
}

// Clean-up resources.
PerfMap::~PerfMap()
{
    LIMITED_METHOD_CONTRACT;

    fclose(m_fp);
    m_fp = nullptr;
}

Review comment (suggestion):
```suggestion
// Signal that all dependencies (AppDomain, ExecutionManager) are ready.
// This method must be called before any code is JITed or restored from R2R image. 
```

Code after:
        }
    }
}

// Disable the map for the process - called from EEShutdownHelper.
void PerfMap::Disable()
{
    LIMITED_METHOD_CONTRACT;

    if (s_enabled)
    {
        CrstHolder ch(&(s_csPerfMap));

        s_enabled = false;
        if (s_Current != nullptr)
        {
            delete s_Current;
            s_Current = nullptr;
        }

        // PAL_PerfJitDump_Finish is lock protected and can safely be called multiple times
        PAL_PerfJitDump_Finish();
    }
}

// Signal that all dependencies (AppDomain, ExecutionManager) are ready.
// This method must be called before any code is JITed or restored from R2R image.
void PerfMap::SignalDependenciesReady()
{
    LIMITED_METHOD_CONTRACT;

    s_dependenciesReady = true;
}

// Construct a new map for the process.
PerfMap::PerfMap()
{
    LIMITED_METHOD_CONTRACT;

    // Initialize with no failures.
    m_ErrorEncountered = false;
}

// Clean-up resources.
PerfMap::~PerfMap()
{
    LIMITED_METHOD_CONTRACT;

    fclose(m_fp);
    m_fp = nullptr;
}
Repository: dotnet/runtime
File: src/coreclr/jit/codegenwasm.cpp (C++)

Code before:
            ins = INS_none;
            NYI_WASM("genCodeForShift");
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(treeNode);
}

//----------------------------------------------------------------------
// genCodeForBitCast - Generate code for a GT_BITCAST that is not contained
//
// Arguments
//    tree - the GT_BITCAST for which we're generating code
//
void CodeGen::genCodeForBitCast(GenTreeOp* tree)
{
    assert(tree->OperIs(GT_BITCAST));
    genConsumeOperands(tree);
    assert(tree->TypeGet() == genActualType(tree));

    var_types toType   = tree->TypeGet();
    var_types fromType = tree->gtGetOp1()->TypeGet();

    assert(toType == genActualType(tree));
    assert(fromType == genActualType(tree->gtGetOp1()));

    instruction ins = INS_none;
    switch (PackTypes(toType, fromType))
    {
        case PackTypes(TYP_INT, TYP_FLOAT):
            ins = INS_i32_reinterpret_f32;
            break;
        case PackTypes(TYP_FLOAT, TYP_INT):
            ins = INS_f32_reinterpret_i32;
            break;
        case PackTypes(TYP_LONG, TYP_DOUBLE):
            ins = INS_i64_reinterpret_f64;
            break;
        case PackTypes(TYP_DOUBLE, TYP_LONG):
            ins = INS_f64_reinterpret_i64;
            break;
        default:
            unreached();
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(tree);
}


Review comment (suggestion):
This assert won't hold. The operand can be of arbitrary type (incl. small ones). It needs to be `genActualType`d explicitly.

Code after:
            ins = INS_none;
            NYI_WASM("genCodeForShift");
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(treeNode);
}

//----------------------------------------------------------------------
// genCodeForBitCast - Generate code for a GT_BITCAST that is not contained
//
// Arguments
//    tree - the GT_BITCAST for which we're generating code
//
void CodeGen::genCodeForBitCast(GenTreeOp* tree)
{
    assert(tree->OperIs(GT_BITCAST));
    genConsumeOperands(tree);

    var_types toType   = tree->TypeGet();
    var_types fromType = genActualType(tree->gtGetOp1()->TypeGet());
    assert(toType == genActualType(tree));

    instruction ins = INS_none;
    switch (PackTypes(toType, fromType))
    {
        case PackTypes(TYP_INT, TYP_FLOAT):
            ins = INS_i32_reinterpret_f32;
            break;
        case PackTypes(TYP_FLOAT, TYP_INT):
            ins = INS_f32_reinterpret_i32;
            break;
        case PackTypes(TYP_LONG, TYP_DOUBLE):
            ins = INS_i64_reinterpret_f64;
            break;
        case PackTypes(TYP_DOUBLE, TYP_LONG):
            ins = INS_f64_reinterpret_i64;
            break;
        default:
            unreached();
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(tree);
}

//------------------------------------------------------------------------
// genCodeForNegNot: Generate code for a neg/not
//
Repository: dotnet/runtime
File: src/coreclr/nativeaot/Runtime/TypeManager.h (C/C++)

Code before:
{
    // NOTE: Part of this layout is a contract with the managed side in TypeManagerHandle.cs
    HANDLE                      m_osModule;
    ReadyToRunHeader *          m_pHeader;
    uint8_t*                    m_pStaticsGCDataSection;
    uint8_t*                    m_pThreadStaticsDataSection;
    void**                      m_pClasslibFunctions;
    uint32_t                    m_nClasslibFunctions;

    TypeManager(HANDLE osModule, ReadyToRunHeader * pHeader, void** pClasslibFunctions, uint32_t nClasslibFunctions);

public:
    static TypeManager * Create(HANDLE osModule, void * pModuleHeader, void** pClasslibFunctions, uint32_t nClasslibFunctions);
    void * GetModuleSection(ReadyToRunSectionType sectionId, int * length);
    HANDLE GetOsModuleHandle();
    void* GetClasslibFunction(ClasslibFunctionId functionId);

private:

    struct ModuleInfoRow
    {
        int32_t SectionId;
        int32_t Length;
        void * Start;

        int GetLength();
    };
};

// TypeManagerHandle represents an AOT module in MRT based runtimes.
// These handles are a pointer to a TypeManager.
struct TypeManagerHandle
{
    static TypeManagerHandle Null()
    {
        TypeManagerHandle handle;
        handle._value = nullptr;
        return handle;
    }

    static TypeManagerHandle Create(TypeManager * value)
    {
        TypeManagerHandle handle;
        handle._value = value;
        return handle;
    }

    void *_value;

    TypeManager* AsTypeManager();
};

Review comment (suggestion):
Remove `GetLength()` and just use the `Length` field.

Code after:
{
    // NOTE: Part of this layout is a contract with the managed side in TypeManagerHandle.cs
    HANDLE                      m_osModule;
    ReadyToRunHeader *          m_pHeader;
    uint8_t*                    m_pStaticsGCDataSection;
    uint8_t*                    m_pThreadStaticsDataSection;
    void**                      m_pClasslibFunctions;
    uint32_t                    m_nClasslibFunctions;

    TypeManager(HANDLE osModule, ReadyToRunHeader * pHeader, void** pClasslibFunctions, uint32_t nClasslibFunctions);

public:
    static TypeManager * Create(HANDLE osModule, void * pModuleHeader, void** pClasslibFunctions, uint32_t nClasslibFunctions);
    void * GetModuleSection(ReadyToRunSectionType sectionId, int * length);
    HANDLE GetOsModuleHandle();
    void* GetClasslibFunction(ClasslibFunctionId functionId);

private:

    struct ModuleInfoRow
    {
        int32_t SectionId;
        int32_t Length;
        void * Start;
    };
};

// TypeManagerHandle represents an AOT module in MRT based runtimes.
// These handles are a pointer to a TypeManager.
struct TypeManagerHandle
{
    static TypeManagerHandle Null()
    {
        TypeManagerHandle handle;
        handle._value = nullptr;
        return handle;
    }

    static TypeManagerHandle Create(TypeManager * value)
    {
        TypeManagerHandle handle;
        handle._value = value;
        return handle;
    }

    void *_value;

    TypeManager* AsTypeManager();
};
Repository: dotnet/runtime
File: src/coreclr/jit/emitwasm.cpp (C++)

Code before:
    return count;
}

size_t emitter::emitOutputOpcode(BYTE* dst, instruction ins)
{
    size_t   sz     = 0;
    unsigned opcode = GetInsOpcode(ins);

    assert(FitsIn<uint16_t>(opcode));
    if (FitsIn<uint8_t>(opcode))
    {
        emitOutputByte(dst, opcode);
        sz += 1;
    }
    else if (FitsIn<uint16_t>(opcode))
    {
        dst += emitOutputByte(dst, opcode & 0xFF);
        emitOutputByte(dst, opcode >> 8);
        sz += 2;
    }
    return sz;
}

size_t emitter::emitOutputPaddedReloc(uint8_t* destination, bool isSigned)
{
    // FIXME: Write fill pattern
    if (destination)
        memset(destination + writeableOffset, 0, PADDED_RELOC_SIZE);
    return PADDED_RELOC_SIZE;
}

size_t emitter::emitOutputConstant(uint8_t* destination, const instrDesc* id, bool isSigned, CorInfoReloc relocType)
{
    if (id->idIsCnsReloc())
    {
        emitRecordRelocation(destination, (void*)emitGetInsSC(id), relocType);
        return emitOutputPaddedReloc(destination, isSigned);
    }
    else if (isSigned)
        return emitOutputSLEB128(destination, (int64_t)emitGetInsSC(id));
    else
        return emitOutputULEB128(destination, (uint64_t)emitGetInsSC(id));
}

size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
{
    BYTE*       dst    = *dp;
    size_t      sz     = emitSizeOfInsDsc(id);
    instruction ins    = id->idIns();
    insFormat   insFmt = id->idInsFmt();
    unsigned    opcode = GetInsOpcode(ins);

Review comment (suggestion):
I think we should do the proper fill for the produced code blob to be decodable in-memory as-is if not for anything else. R2R will overwrite the value - I am not sure what the SPMI behavior is. It is simpler to just do it.

Code after:
    memcpy(destination + writeableOffset, source, count);
    return count;
}

size_t emitter::emitOutputOpcode(BYTE* dst, instruction ins)
{
    size_t   sz     = 0;
    unsigned opcode = GetInsOpcode(ins);

    assert(FitsIn<uint16_t>(opcode));
    if (FitsIn<uint8_t>(opcode))
    {
        emitOutputByte(dst, opcode);
        sz += 1;
    }
    else if (FitsIn<uint16_t>(opcode))
    {
        dst += emitOutputByte(dst, opcode & 0xFF);
        emitOutputByte(dst, opcode >> 8);
        sz += 2;
    }
    return sz;
}

size_t emitter::emitOutputPaddedReloc(uint8_t* destination)
{
    static_assert(PADDED_RELOC_SIZE > 1);
    // Write zeroes with the bit set that indicates another byte is coming
    for (unsigned i = 0; i < PADDED_RELOC_SIZE - 1; i++)
    {
        destination += emitOutputByte(destination, 0x80);
    }

    emitOutputByte(destination, 0x0);
    return PADDED_RELOC_SIZE;
}

size_t emitter::emitOutputConstant(uint8_t* destination, const instrDesc* id, bool isSigned, CorInfoReloc relocType)
{
    if (id->idIsCnsReloc())
    {
        emitRecordRelocation(destination, (void*)emitGetInsSC(id), relocType);
        return emitOutputPaddedReloc(destination);
    }

    if (isSigned)
    {
        return emitOutputSLEB128(destination, (int64_t)emitGetInsSC(id));
    }
    else
    {
Repository: dotnet/runtime
File: src/coreclr/jit/emitwasm.cpp (C++)

Code before:
    return count;
}

size_t emitter::emitOutputOpcode(BYTE* dst, instruction ins)
{
    size_t   sz     = 0;
    unsigned opcode = GetInsOpcode(ins);

    assert(FitsIn<uint16_t>(opcode));
    if (FitsIn<uint8_t>(opcode))
    {
        emitOutputByte(dst, opcode);
        sz += 1;
    }
    else if (FitsIn<uint16_t>(opcode))
    {
        dst += emitOutputByte(dst, opcode & 0xFF);
        emitOutputByte(dst, opcode >> 8);
        sz += 2;
    }
    return sz;
}

size_t emitter::emitOutputPaddedReloc(uint8_t* destination)
{
    if (destination)
    {
        static_assert(PADDED_RELOC_SIZE > 1);
        // Write zeroes with the bit set that indicates another byte is coming
        for (unsigned i = 1; i < PADDED_RELOC_SIZE; i++)
            *(destination++ + writeableOffset) = 0x80;

        // Write a final zero
        *(destination + writeableOffset) = 0x0;
    }
    return PADDED_RELOC_SIZE;
}

size_t emitter::emitOutputConstant(uint8_t* destination, const instrDesc* id, bool isSigned, CorInfoReloc relocType)
{
    if (id->idIsCnsReloc())
    {
        emitRecordRelocation(destination, (void*)emitGetInsSC(id), relocType);
        return emitOutputPaddedReloc(destination);
    }
    else if (isSigned)
        return emitOutputSLEB128(destination, (int64_t)emitGetInsSC(id));
    else
        return emitOutputULEB128(destination, (uint64_t)emitGetInsSC(id));
}


Review comment (bug):
We should never have a null destination here.

(If we want to make that legal in the future, the style of nullchecks in the Jit is `!= nullptr`)

Code after:
    memcpy(destination + writeableOffset, source, count);
    return count;
}

size_t emitter::emitOutputOpcode(BYTE* dst, instruction ins)
{
    size_t   sz     = 0;
    unsigned opcode = GetInsOpcode(ins);

    assert(FitsIn<uint16_t>(opcode));
    if (FitsIn<uint8_t>(opcode))
    {
        emitOutputByte(dst, opcode);
        sz += 1;
    }
    else if (FitsIn<uint16_t>(opcode))
    {
        dst += emitOutputByte(dst, opcode & 0xFF);
        emitOutputByte(dst, opcode >> 8);
        sz += 2;
    }
    return sz;
}

size_t emitter::emitOutputPaddedReloc(uint8_t* destination)
{
    static_assert(PADDED_RELOC_SIZE > 1);
    // Write zeroes with the bit set that indicates another byte is coming
    for (unsigned i = 0; i < PADDED_RELOC_SIZE - 1; i++)
    {
        destination += emitOutputByte(destination, 0x80);
    }

    emitOutputByte(destination, 0x0);
    return PADDED_RELOC_SIZE;
}

size_t emitter::emitOutputConstant(uint8_t* destination, const instrDesc* id, bool isSigned, CorInfoReloc relocType)
{
    if (id->idIsCnsReloc())
    {
        emitRecordRelocation(destination, (void*)emitGetInsSC(id), relocType);
        return emitOutputPaddedReloc(destination);
    }

    if (isSigned)
    {
        return emitOutputSLEB128(destination, (int64_t)emitGetInsSC(id));
    }
    else
    {
Repository: dotnet/runtime
File: src/coreclr/jit/gschecks.cpp (C++)

Code before:
//
// Returns:
//    Suitable phase status
//
PhaseStatus Compiler::gsPhase()
{
    bool madeChanges = false;

    if (getNeedsGSSecurityCookie())
    {
        unsigned const prevBBCount = fgBBcount;
        gsGSChecksInitCookie();

        if (compGSReorderStackLayout)
        {
            gsCopyShadowParams();
        }

        madeChanges = true;
    }
    else
    {
#ifdef DEBUG
        if (compGSSecurityCheckBlocker != nullptr)
        {
            JITDUMP("GS security check requested, but not provided: %s\n", compGSSecurityCheckBlocker)
        }
        else
        {
            JITDUMP("No GS security needed\n");
        }
#endif
    }

    return madeChanges ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING;
}

//------------------------------------------------------------------------
// gsGSChecksInitCookie:
//   Initialize the GS cookie local and value.
//
void Compiler::gsGSChecksInitCookie()
{
    var_types type = TYP_I_IMPL;

    lvaGSSecurityCookie = lvaGrabTempWithImplicitUse(false DEBUGARG("GSSecurityCookie"));

    // Prevent cookie init/check from being optimized
    lvaSetVarAddrExposed(lvaGSSecurityCookie DEBUGARG(AddressExposedReason::TOO_CONSERVATIVE));
    lvaTable[lvaGSSecurityCookie].lvType = type;


Review comment (security):
Missing semicolon after the JITDUMP call; as written this won't compile (the macro expands to a statement that requires a terminating ';').
```suggestion
            JITDUMP("GS security check requested, but not provided: %s\n", compGSSecurityCheckBlocker);
```

Code after:
//
// Returns:
//    Suitable phase status
//
PhaseStatus Compiler::gsPhase()
{
    bool madeChanges = false;

    if (getNeedsGSSecurityCookie())
    {
        unsigned const prevBBCount = fgBBcount;
        gsGSChecksInitCookie();

        if (compGSReorderStackLayout)
        {
            gsCopyShadowParams();
        }

        madeChanges = true;
    }
    else
    {
#ifdef DEBUG
        if (compGSSecurityCheckBlocker != nullptr)
        {
            JITDUMP("GS security check requested, but not provided: %s\n", compGSSecurityCheckBlocker);
        }
        else
        {
            JITDUMP("No GS security needed\n");
        }
#endif
    }

    return madeChanges ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING;
}

//------------------------------------------------------------------------
// gsGSChecksInitCookie:
//   Initialize the GS cookie local and value.
//
void Compiler::gsGSChecksInitCookie()
{
    var_types type = TYP_I_IMPL;

    lvaGSSecurityCookie = lvaGrabTempWithImplicitUse(false DEBUGARG("GSSecurityCookie"));

    // Prevent cookie init/check from being optimized
    lvaSetVarAddrExposed(lvaGSSecurityCookie DEBUGARG(AddressExposedReason::TOO_CONSERVATIVE));
    lvaTable[lvaGSSecurityCookie].lvType = type;
Repository: dotnet/runtime
File: src/coreclr/jit/codegenwasm.cpp (C++)

Code before:
    assert(block->KindIs(BBJ_CALLFINALLY));
    NYI_WASM("genCallFinally");
    return nullptr;
}

void CodeGen::genEHCatchRet(BasicBlock* block)
{
    NYI_WASM("genEHCatchRet");
}

void CodeGen::genStructReturn(GenTree* treeNode)
{
    NYI_WASM("genStructReturn");
}

void CodeGen::genEmitGSCookieCheck(bool tailCall)
{
    // TODO-WASM: GS cookie checks have limited utility on WASM since they can only help
    // with detecting linear memory stack corruption. Decide if we want them anyway.
    NYI_WASM("genEmitGSCookieCheck");
}

void CodeGen::genProfilingLeaveCallback(unsigned helper)
{
    NYI_WASM("genProfilingLeaveCallback");
}

void CodeGen::genSpillVar(GenTree* tree)
{
    NYI_WASM("Put all spillng to memory under '#if HAS_FIXED_REGISTER_SET'");
}

//------------------------------------------------------------------------
// genLoadLocalIntoReg: set the register to "load(local on stack)".
//
// Arguments:
//    targetReg - The register to load into
//    lclNum    - The local on stack to load from
//
void CodeGen::genLoadLocalIntoReg(regNumber targetReg, unsigned lclNum)
{
    LclVarDsc* varDsc = m_compiler->lvaGetDesc(lclNum);
    var_types  type   = varDsc->GetRegisterType();
    GetEmitter()->emitIns_I(INS_local_get, EA_PTRSIZE, WasmRegToIndex(GetFramePointerReg()));
    GetEmitter()->emitIns_S(ins_Load(type), emitTypeSize(type), lclNum, 0);
    GetEmitter()->emitIns_I(INS_local_set, emitTypeSize(type), WasmRegToIndex(targetReg));
}

//------------------------------------------------------------------------
// inst_JMP: Emit a jump instruction.
//

Review comment (suggestion):
I think we should add the exact unwinding scheme for variable-sized frames we settled on here into the ABI document.

Code after:
        default:
            unreached();
    }

    GetEmitter()->emitIns(ins);

    if (invertSense)
    {
        GetEmitter()->emitIns(INS_i32_eqz);
    }

    WasmProduceReg(treeNode);
}

//------------------------------------------------------------------------
// genLclHeap: Generate code for LCLHEAP
//
// Arguments:
//    tree -- LCLHEAP tree
//
// Notes:
//   Codegen varies depending on:
//   * whether the size operand is a constant or not
//   * whether the allocated memory needs to be zeroed or not (info.compInitMem)
//
//   If the sp is changed, the value at sp[0] must be the frame pointer
//   so that the runtime unwinder can locate the base of the fixed area
//   in the shadow stack.
//
void CodeGen::genLclHeap(GenTree* tree)
{
    assert(tree->OperIs(GT_LCLHEAP));
    assert(m_compiler->compLocallocUsed);
    assert(isFramePointerUsed());

    bool const     needsZeroing = m_compiler->info.compInitMem;
    GenTree* const size         = tree->AsOp()->gtOp1;

    // We reserve this amount of space below any allocation for
    // establishing unwind invariants.
    //
    size_t const reservedSpace = STACK_ALIGN;

    // Constant LCLHEAP size operands are contained by lower.
    //
    if (size->isContainedIntOrIImmed())
    {
        size_t amount = size->AsIntCon()->gtIconVal;

        // Handle zero
        //