Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8672,6 +8672,14 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
}
}

#ifdef TARGET_64BIT
if (m_pStackPointer->GetStackType() == StackTypeI)
{
// Emit a saturating conversion from U8 to U4
EmitConv(m_pStackPointer, StackTypeI4, INTOP_CONV_U4_U8_SAT);
}
#endif // TARGET_64BIT

AddInsExplicit(INTOP_SWITCH, n + 3);
m_pLastNewIns->data[0] = n;
m_pLastNewIns->SetSVar(m_pStackPointer->var);
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/interpreter/inc/intops.def
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ OPDEF(INTOP_CONV_U2_R8, "conv.u2.r8", 3, 1, 1, InterpOpNoArgs)
OPDEF(INTOP_CONV_I4_R4, "conv.i4.r4", 3, 1, 1, InterpOpNoArgs)
OPDEF(INTOP_CONV_I4_R8, "conv.i4.r8", 3, 1, 1, InterpOpNoArgs)

OPDEF(INTOP_CONV_U4_U8_SAT, "conv.u4.u8.sat", 3, 1, 1, InterpOpNoArgs)
OPDEF(INTOP_CONV_U4_R4, "conv.u4.r4", 3, 1, 1, InterpOpNoArgs)
OPDEF(INTOP_CONV_U4_R8, "conv.u4.r8", 3, 1, 1, InterpOpNoArgs)

Expand Down
11 changes: 10 additions & 1 deletion src/coreclr/vm/interpexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,16 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
ConvOvfHelper<uint32_t, uint64_t>(stack, ip);
ip += 3;
break;

case INTOP_CONV_U4_U8_SAT:
{
uint64_t val = LOCAL_VAR(ip[2], uint64_t);
if (val > UINT32_MAX)
LOCAL_VAR(ip[1], uint32_t) = UINT32_MAX;
else
LOCAL_VAR(ip[1], uint32_t) = (uint32_t)val;
ip += 3;
break;
}
case INTOP_SWITCH:
{
uint32_t val = LOCAL_VAR(ip[1], uint32_t);
Expand Down
Loading