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

Code before:
// lvaInitWasmStackPtr: set up the wasm stack pointer argument
//
// Arguments:
//   curVarNum - [in, out] the last used local var num
//
// Notes:
//   The managed calling convention for Wasm passes the stack pointer as the first arg.
//
void Compiler::lvaInitWasmStackPtr(unsigned* curVarNum)
{
    LclVarDsc* varDsc = lvaGetDesc(*curVarNum);
    varDsc->lvType    = TYP_I_IMPL;
    varDsc->lvIsParam = 1;
    varDsc->lvOnFrame = true;
    lvaWasmSpArg      = *curVarNum;
    (*curVarNum)++;
}

//-----------------------------------------------------------------------------
// lvaInitWasmPortableEntryPtr: set up the wasm portable entry pointer argument
//
// Arguments:
//   curVarNum - [in, out] the last used local var num
//
// Notes:
//   The managed calling convention for Wasm passes the stack pointer as the last arg.
//   This arg is currently unused in the JIT, and we may not need to model it.
//
void Compiler::lvaInitWasmPortableEntryPtr(unsigned* curVarNum)
{
    LclVarDsc* varDsc = lvaGetDesc(*curVarNum);
    varDsc->lvType    = TYP_I_IMPL;
    varDsc->lvIsParam = 1;
    varDsc->lvOnFrame = true;
    (*curVarNum)++;
}

#endif // defined(TARGET_WASM)

//-----------------------------------------------------------------------------
// lvaInitUserArgs:
//     Initialize local var descriptions for incoming user arguments
//
// Arguments:
//    curVarNum      - the current local
//    skipArgs       - the number of user args to skip processing.
//    takeArgs       - the number of user args to process (after skipping skipArgs number of args)
//
void Compiler::lvaInitUserArgs(unsigned* curVarNum, unsigned skipArgs, unsigned takeArgs)
{
    //-------------------------------------------------------------------------

Review comment (suggestion):
```suggestion
//   The managed calling convention for Wasm passes the entrypoint as the last arg.
```

Code after:
// lvaInitWasmStackPtr: set up the wasm stack pointer argument
//
// Arguments:
//   curVarNum - [in, out] the last used local var num
//
// Notes:
//   The managed calling convention for Wasm passes the stack pointer as the first arg.
//
void Compiler::lvaInitWasmStackPtr(unsigned* curVarNum)
{
    LclVarDsc* varDsc = lvaGetDesc(*curVarNum);
    varDsc->lvType    = TYP_I_IMPL;
    varDsc->lvIsParam = 1;
    varDsc->lvOnFrame = true;
    lvaWasmSpArg      = *curVarNum;
    (*curVarNum)++;
}

//-----------------------------------------------------------------------------
// lvaInitWasmPortableEntryPtr: set up the wasm portable entry pointer argument
//
// Arguments:
//   curVarNum - [in, out] the last used local var num
//
// Notes:
//   The managed calling convention for Wasm passes a pointer to the portable entry point as the last arg.
//   This arg is currently unused in the JIT, and we may not need to model it.
//
void Compiler::lvaInitWasmPortableEntryPtr(unsigned* curVarNum)
{
    LclVarDsc* varDsc = lvaGetDesc(*curVarNum);
    varDsc->lvType    = TYP_I_IMPL;
    varDsc->lvIsParam = 1;
    varDsc->lvOnFrame = true;
    (*curVarNum)++;
}

#endif // defined(TARGET_WASM)

//-----------------------------------------------------------------------------
// lvaInitUserArgs:
//     Initialize local var descriptions for incoming user arguments
//
// Arguments:
//    curVarNum      - the current local
//    skipArgs       - the number of user args to skip processing.
//    takeArgs       - the number of user args to process (after skipping skipArgs number of args)
//
void Compiler::lvaInitUserArgs(unsigned* curVarNum, unsigned skipArgs, unsigned takeArgs)
{
    //-------------------------------------------------------------------------