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

Code before:
            GetEmitter()->emitIns_I(INS_I_const, EA_PTRSIZE, 0);
        }
        else
        {
            // Add in the reserved space and round up.
            //
            amount = AlignUp(amount + reservedSpace, STACK_ALIGN);

            // Decrease the stack pointer by amount
            //
            GetEmitter()->emitIns_I(INS_local_get, EA_PTRSIZE, WasmRegToIndex(GetStackPointerReg()));
            GetEmitter()->emitIns_I(INS_I_const, EA_PTRSIZE, amount);
            GetEmitter()->emitIns(INS_I_sub);
            GetEmitter()->emitIns_I(INS_local_set, EA_PTRSIZE, WasmRegToIndex(GetStackPointerReg()));

            // Zero the newly allocated space if needed
            //
            if (needsZeroing)
            {
                GetEmitter()->emitIns_I(INS_local_get, EA_PTRSIZE, WasmRegToIndex(GetStackPointerReg()));
                GetEmitter()->emitIns_I(INS_I_const, EA_PTRSIZE, 0);
                GetEmitter()->emitIns_I(INS_I_const, EA_PTRSIZE, amount);

                // TODO-WASM-CQ: possibly do small fills directly
                //
                GetEmitter()->emitIns_I(INS_memory_fill, EA_4BYTE, 0);
            }

            // SP now points at the reserved space just below the allocation.
            // Save the frame pointer at sp[0].
            //
            GetEmitter()->emitIns_I(INS_local_get, EA_PTRSIZE, WasmRegToIndex(GetStackPointerReg()));
            GetEmitter()->emitIns_I(INS_local_get, EA_PTRSIZE, WasmRegToIndex(GetFramePointerReg()));
            GetEmitter()->emitIns_I(ins_Store(TYP_I_IMPL), EA_PTRSIZE, 0);

            // Leave the base address of the allocated region on the stack.
            //
            GetEmitter()->emitIns_I(INS_local_get, EA_PTRSIZE, WasmRegToIndex(GetStackPointerReg()));
            GetEmitter()->emitIns_I(INS_I_const, EA_PTRSIZE, reservedSpace);
            GetEmitter()->emitIns(INS_I_add);
        }
    }
    else
    {
        assert(size->TypeIs(TYP_I_IMPL));
        bool const is64Bit = (TARGET_POINTER_SIZE == 8);

        genConsumeReg(size);
        regNumber sizeReg = GetMultiUseOperandReg(size);

        // Check for zero-size.

Review comment (suggestion):
(This should rendezvous with the block store PR on using a named constant for the memory index)

Code after:
        case PackOperAndType(GT_LT, TYP_INT):
            ins = treeNode->IsUnsigned() ? INS_i32_lt_u : INS_i32_lt_s;
            break;
        case PackOperAndType(GT_LT, TYP_LONG):
            ins = treeNode->IsUnsigned() ? INS_i64_lt_u : INS_i64_lt_s;
            break;
        case PackOperAndType(GT_LE, TYP_INT):
            ins = treeNode->IsUnsigned() ? INS_i32_le_u : INS_i32_le_s;
            break;
        case PackOperAndType(GT_LE, TYP_LONG):
            ins = treeNode->IsUnsigned() ? INS_i64_le_u : INS_i64_le_s;
            break;
        case PackOperAndType(GT_GE, TYP_INT):
            ins = treeNode->IsUnsigned() ? INS_i32_ge_u : INS_i32_ge_s;
            break;
        case PackOperAndType(GT_GE, TYP_LONG):
            ins = treeNode->IsUnsigned() ? INS_i64_ge_u : INS_i64_ge_s;
            break;
        case PackOperAndType(GT_GT, TYP_INT):
            ins = treeNode->IsUnsigned() ? INS_i32_gt_u : INS_i32_gt_s;
            break;
        case PackOperAndType(GT_GT, TYP_LONG):
            ins = treeNode->IsUnsigned() ? INS_i64_gt_u : INS_i64_gt_s;
            break;
        default:
            unreached();
    }

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

//------------------------------------------------------------------------
// genCompareFloat: Generate code for comparing floats
//
// Arguments:
//    treeNode - the compare tree
//
void CodeGen::genCompareFloat(GenTreeOp* treeNode)
{
    assert(treeNode->OperIsCmpCompare());

    genTreeOps op          = treeNode->OperGet();
    bool       invertSense = false;

    if ((treeNode->gtFlags & GTF_RELOP_NAN_UN) != 0)
    {
        // We don't expect to see GT_EQ unordered,
        // since CIL doesn't have this mode.
        //
        assert(op != GT_EQ);