debug assert fixes + cleanup
@@ -48,7 +48,7 @@ u32 GetTypeNumSlots (u8 i_type)
}
i16 GetStackTopIndex (IM3Compilation o)
-{ d_m3Assert (o->stackIndex > 0);
+{ d_m3Assert (o->stackIndex > 0 or IsStackPolymorphic (o));
return o->stackIndex - 1;
}
@@ -101,20 +101,38 @@ i16 GetNumBlockValues (IM3Compilation o)
bool IsStackIndexInRegister (IM3Compilation o, u16 i_stackIndex)
-{ d_m3Assert (i_stackIndex < o->stackIndex);
+{ d_m3Assert (i_stackIndex < o->stackIndex or IsStackPolymorphic (o));
+ if (i_stackIndex < o->stackIndex)
return (o->wasmStack [i_stackIndex] >= d_m3Reg0SlotAlias);
+ else
+ return false;
+}
+
+
+bool IsStackTopIndexInRegister (IM3Compilation o, i16 i_stackTopOffset)
+{ d_m3Assert (i_stackTopOffset >= 0 or IsStackPolymorphic (o));
+ if (i_stackTopOffset >= 0)
+ return IsStackIndexInRegister (o, (u16) i_stackTopOffset);
+ else
+ return false;
}
bool IsStackTopInRegister (IM3Compilation o)
{
- i16 i = GetStackTopIndex (o); d_m3Assert (i >= 0 or IsStackPolymorphic (o));
+ return IsStackTopIndexInRegister (o, GetStackTopIndex (o));
+}
- if (i >= 0)
+
+bool IsStackTopMinus1InRegister (IM3Compilation o)
{
- return IsStackIndexInRegister (o, (u16) i);
+ return IsStackTopIndexInRegister (o, GetStackTopIndex (o) - 1);
}
- else return false;
+
+
+bool IsStackTopMinus2InRegister (IM3Compilation o)
+{
+ return IsStackTopIndexInRegister (o, GetStackTopIndex (o) - 2);
}
@@ -145,29 +163,6 @@ bool IsValidSlot (u16 i_slot)
}
-bool IsStackTopMinus1InRegister (IM3Compilation o)
-{
- i16 i = GetStackTopIndex (o);
-
- if (i >= 1)
- {
- return (o->wasmStack [i - 1] >= d_m3Reg0SlotAlias);
- }
- else return false;
-}
-
-
-bool IsStackTopMinus2InRegister (IM3Compilation o)
-{
- i16 i = GetStackTopIndex (o);
-
- if (i > 1)
- {
- return (o->wasmStack [i - 2] >= d_m3Reg0SlotAlias);
- }
- else return false;
-}
-
void MarkSlotAllocated (IM3Compilation o, u16 i_slot)
{ d_m3Assert (o->m3Slots [i_slot] == 0); // shouldn't be already allocated
