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

Code before:
            assert(call->IsR2ROrVirtualStubRelativeIndir());

            params.callType = EC_INDIR_R;
            // params.ireg     = targetAddrReg;
            genEmitCallWithCurrentGC(params);
        }
        else
        {
            // Generate a direct call to a non-virtual user defined or helper method
            assert(call->IsHelperCall() || (call->gtCallType == CT_USER_FUNC));

            if (call->gtEntryPoint.addr != NULL)
            {
                NYI_WASM("Call with statically known address");
            }
            else
            {
                if (call->IsHelperCall())
                {
                    NYI_WASM("Call helper statically without indirection cell");
                    CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(params.methHnd);
                    noway_assert(helperNum != CORINFO_HELP_UNDEF);

                    CORINFO_CONST_LOOKUP helperLookup = compiler->compGetHelperFtn(helperNum);
                    params.addr                       = helperLookup.addr;
                    assert(helperLookup.accessType == IAT_VALUE);
                }
                else
                {
                    // Direct call to a non-virtual user function.
                    params.addr = call->gtDirectCallAddress;
                }
            }

            params.callType = EC_FUNC_TOKEN;
            // params.ireg     = params.isJump ? rsGetRsvdReg() : REG_RA;

            genEmitCallWithCurrentGC(params);
        }
    }
}

/*****************************************************************************
 *  Emit a call to a helper function.
 */
void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg /*= REG_NA */)
{
    EmitCallParams params;

    CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
    params.ireg                         = callTargetReg;

Review comment (suggestion):
There is unreachable code following NYI_WASM. Lines 1519-1524 will never execute because NYI_WASM throws an exception. Either the NYI_WASM call should be removed if this functionality is intended to be implemented, or the unreachable code should be deleted.
```suggestion

```

Code after:

                CORINFO_CONST_LOOKUP helperLookup = compiler->compGetHelperFtn(helperNum);
                params.addr                       = helperLookup.addr;
                assert(helperLookup.accessType == IAT_VALUE);
            }
            else
            {
                // Direct call to a non-virtual user function.
                params.addr = call->gtDirectCallAddress;
            }

            params.callType = EC_FUNC_TOKEN;
            genEmitCallWithCurrentGC(params);
        }
    }
}

/*****************************************************************************
 *  Emit a call to a helper function.
 */
void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg /*= REG_NA */)
{
    EmitCallParams params;

    CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
    params.ireg                         = callTargetReg;

    if (helperFunction.accessType == IAT_VALUE)
    {
        params.callType = EC_FUNC_TOKEN;
        params.addr     = helperFunction.addr;
    }
    else
    {
        params.addr = nullptr;
        assert(helperFunction.accessType == IAT_PVALUE);
        void* pAddr = helperFunction.addr;

        // Push indirection cell address onto stack for genEmitCall to dereference
        GetEmitter()->emitIns_I(INS_i32_const, emitActualTypeSize(TYP_I_IMPL), (cnsval_ssize_t)pAddr);

        params.callType = EC_INDIR_R;
    }

    params.methHnd = compiler->eeFindHelper(helper);
    params.argSize = argSize;
    params.retSize = retSize;

    genEmitCallWithCurrentGC(params);
}