Repository: dotnet/runtime
File: src/coreclr/jit/lclvars.cpp (C++)

Code before:

    lvaIncrementFrameSize(size);
    stkOffs -= size;
    lcl->SetStackOffset(stkOffs);

#ifdef DEBUG
    if (verbose)
    {
        printf("Assign ");
        gtDispLclVar(lclNum, /*pad*/ false);
        printf(", size=%d, stkOffs=%c0x%x\n", size, stkOffs < 0 ? '-' : '+', stkOffs < 0 ? -stkOffs : stkOffs);
    }
#endif

    return stkOffs;
}

//------------------------------------------------------------------------
// lvaAllocAsyncContexts:
//   Allocate stack space for the two async context locals, if present.
//
// Arguments:
//   stkOffs - Current stack offset
//
// Return Value:
//    New stck offset.
//
int Compiler::lvaAllocAsyncContexts(int stkOffs)
{
    if (lvaAsyncExecutionContextVar != BAD_VAR_NUM)
    {
        stkOffs = lvaAllocLocalAndSetVirtualOffset(lvaAsyncExecutionContextVar,
                                                   lvaLclStackHomeSize(lvaAsyncExecutionContextVar), stkOffs);
    }
    else
    {
        // For x86 EnC the VM expects that we always allocate stack space
        // for this local when contexts were saved.
        assert((info.compMethodInfo->options & CORINFO_ASYNC_SAVE_CONTEXTS) == 0);
    }

    if (lvaAsyncSynchronizationContextVar != BAD_VAR_NUM)
    {
        stkOffs = lvaAllocLocalAndSetVirtualOffset(lvaAsyncSynchronizationContextVar,
                                                   lvaLclStackHomeSize(lvaAsyncSynchronizationContextVar), stkOffs);
    }
    else
    {
        assert((info.compMethodInfo->options & CORINFO_ASYNC_SAVE_CONTEXTS) == 0);
    }


Review comment (suggestion):
Typo in the return value documentation comment. Should be "stack offset" instead of "stck offset".
```suggestion
//    New stack offset.
```

Code after:
//
// Arguments:
//   stkOffs - Current stack offset
//
// Return Value:
//    New stack offset.
//
int Compiler::lvaAllocAsyncContexts(int stkOffs)
{
    if (lvaAsyncExecutionContextVar != BAD_VAR_NUM)
    {
        stkOffs = lvaAllocLocalAndSetVirtualOffset(lvaAsyncExecutionContextVar,
                                                   lvaLclStackHomeSize(lvaAsyncExecutionContextVar), stkOffs);
    }
    else
    {
        // For x86 EnC the VM expects that we always allocate stack space
        // for this local when contexts were saved.
        assert((info.compMethodInfo->options & CORINFO_ASYNC_SAVE_CONTEXTS) == 0);
    }

    if (lvaAsyncSynchronizationContextVar != BAD_VAR_NUM)
    {
        stkOffs = lvaAllocLocalAndSetVirtualOffset(lvaAsyncSynchronizationContextVar,
                                                   lvaLclStackHomeSize(lvaAsyncSynchronizationContextVar), stkOffs);
    }
    else
    {
        assert((info.compMethodInfo->options & CORINFO_ASYNC_SAVE_CONTEXTS) == 0);
    }

    return stkOffs;
}

#ifdef TARGET_AMD64
/*****************************************************************************
 *  lvaIsCalleeSavedIntRegCountEven() :  returns true if the number of integer registers
 *  pushed onto stack is even including RBP if used as frame pointer
 *
 *  Note that this excludes return address (PC) pushed by caller.  To know whether
 *  the SP offset after pushing integer registers is aligned, we need to take
 *  negation of this routine.
 */
bool Compiler::lvaIsCalleeSavedIntRegCountEven()
{
    unsigned regsPushed = compCalleeRegsPushed + (codeGen->isFramePointerUsed() ? 1 : 0);
    return (regsPushed % (16 / REGSIZE_BYTES)) == 0;
}
#endif // TARGET_AMD64

/*****************************************************************************