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

Code before:
        }
    };

    // The reference for the following style of display is wasm-objdump output.
    //
    switch (fmt)
    {
        case IF_OPCODE:
        case IF_BLOCK:
            break;

        case IF_LABEL:
        case IF_ULEB128:
        case IF_LOCAL_CNT:
        {
            cnsval_ssize_t imm = emitGetInsSC(id);
            printf(" %llu", (uint64_t)imm);
            dispJumpTargetIfAny();
        }
        break;

        case IF_LOCAL_DECL:
        {
            cnsval_ssize_t    imm     = emitGetLclVarDeclCount(id);
            WasmValueType  valType = emitGetLclVarDeclType(id);
            printf(" %llu %s", (uint64_t)imm, WasmValueTypeName(valType));
        }
        break;

        case IF_SLEB128:
        {
            cnsval_ssize_t imm = emitGetInsSC(id);
            printf(" %lli", (int64_t)imm);
        }
        break;

        case IF_F32:
        case IF_F64:
        {
            cnsval_ssize_t bits = emitGetInsSC(id);
            double         value;
            memcpy(&value, &bits, sizeof(double));
            printf(" %f", value);
        }
        break;

        case IF_MEMARG:
        {
            // TODO-WASM: decide what our strategy for alignment hints is and display these accordingly.
            unsigned       log2align = emitGetAlignHintLog2(id) + 1;
            cnsval_ssize_t offset    = emitGetInsSC(id);

Review comment (bug):
I've been trying to keep this disasm format the same as wasm-objdump; the wasm-objdump way to display this would be like so:
```
 1c08cc: 14 7f                      | local[6..25] type=i32
 1c08ce: 01 7e                      | local[26] type=i64
 1c08d0: 01 7f                      | local[27] type=i32
```
It is useful since it also lists the indices instead of the raw encoding. However, here we only have counts. The easiest way to fix that would be to add another field to `idDebugOnlyInfo` that'd store the "base" index.

Code after:
    insFormat   fmt = id->idInsFmt();

    emitDispInst(ins);

    auto dispJumpTargetIfAny = [this, id]() {
        if (m_debugInfoSize > 0)
        {
            BasicBlock* const targetBlock = id->idDebugOnlyInfo()->idTargetBlock;
            if (targetBlock != nullptr)
            {
                printf(" ;; ");
                insGroup* const targetGroup = (insGroup*)emitCodeGetCookie(targetBlock);
                assert(targetGroup != nullptr);
                emitPrintLabel(targetGroup);
            }
        }
    };

    // The reference for the following style of display is wasm-objdump output.
    //
    switch (fmt)
    {
        case IF_OPCODE:
        case IF_BLOCK:
            break;

        case IF_RAW_ULEB128:
        case IF_ULEB128:
        {
            cnsval_ssize_t imm = emitGetInsSC(id);
            printf(" %llu", (uint64_t)imm);
            dispJumpTargetIfAny();
        }
        break;

        case IF_LOCAL_DECL:
        {
            unsigned int  count   = emitGetLclVarDeclCount(id);
            WasmValueType valType = emitGetLclVarDeclType(id);
            assert(count > 0); // we should not be declaring a local entry with zero count

            if (m_debugInfoSize > 0)
            {
                // With debug info: print the local offsets being declared
                int offs = id->idDebugOnlyInfo()->lclOffset;
                if (count > 1)
                {
                    printf("[%u..%u] type=%s", offs, offs + count - 1, WasmValueTypeName(valType));
                }
                else // single local case
                {