1e80
};
+ // Used to fill uninitialized stack variables with non-zero pattern in debug builds
+ [Conditional("DEBUG")]
+ private static unsafe void DebugPoison<T>(ref T s) where T: unmanaged
+ {
+ MemoryMarshal.AsBytes(MemoryMarshal.CreateSpan(ref s, 1)).Fill(0xCD);
+ }
+
#region Decimal Math Helpers
private static unsafe uint GetExponent(float f)
//
Buf24 bufNum;
_ = &bufNum; // workaround for CS0165
+ DebugPoison(ref bufNum);
+
bufNum.Low64 = low64;
bufNum.Mid64 = tmp64;
uint hiProd = 3;
uint hiProd;
Buf24 bufProd;
_ = &bufProd; // workaround for CS0165
+ DebugPoison(ref bufProd);
if ((d1.High | d1.Mid) == 0)
{
goto SkipScan;
}
}
- if ((uint)tmp != 0)
- {
- bufProd.U2 = (uint)tmp;
- hiProd = 2;
- goto SkipScan;
- }
- hiProd = 1;
+ bufProd.U2 = (uint)tmp;
+ hiProd = 2;
}
}
else if ((d2.High | d2.Mid) == 0)
goto SkipScan;
}
}
- if ((uint)tmp != 0)
- {
- bufProd.U2 = (uint)tmp;
- hiProd = 2;
- goto SkipScan;
- }
- hiProd = 1;
+ bufProd.U2 = (uint)tmp;
+ hiProd = 2;
}
else
{
hiProd = 5;
}
- else if (tmp != 0)
+ else
{
bufProd.Mid64 = tmp;
hiProd = 3;
}
- else
- hiProd = 1;
}
// Check for leading zero uints on the product
{
Buf12 bufQuo;
_ = &bufQuo; // workaround for CS0165
+ DebugPoison(ref bufQuo);
+
uint power;
int curScale;
//
Buf16 bufRem;
_ = &bufRem; // workaround for CS0165
+ DebugPoison(ref bufRem);
+
bufRem.Low64 = d1.Low64 << curScale;
bufRem.High64 = (d1.Mid + ((ulong)d1.High << 32)) >> (32 - curScale);
// Have a 64-bit divisor in sdlDivisor. The remainder
// (currently 96 bits spread over 4 uints) will be < divisor.
//
-
+ bufQuo.U2 = 0;
bufQuo.U1 = Div96By64(ref *(Buf12*)&bufRem.U1, divisor);
bufQuo.U0 = Div96By64(ref *(Buf12*)&bufRem, divisor);
//
Buf12 bufDivisor;
_ = &bufDivisor; // workaround for CS0165
+ DebugPoison(ref bufDivisor);
+
bufDivisor.Low64 = divisor;
bufDivisor.U2 = (uint)((d2.Mid + ((ulong)d2.High << 32)) >> (32 - curScale));
// The remainder (currently 96 bits spread over 4 uints) will be < divisor.
//
bufQuo.Low64 = Div128By96(ref bufRem, ref bufDivisor);
+ bufQuo.U2 = 0;
for (;;)
{
d1.uflags = d2.uflags;
// Try to scale up dividend to match divisor.
Buf12 bufQuo;
- unsafe
- { _ = &bufQuo; } // workaround for CS0165
+ unsafe { _ = &bufQuo; } // workaround for CS0165
+ DebugPoison(ref bufQuo);
+
bufQuo.Low64 = d1.Low64;
bufQuo.U2 = d1.High;
do
Buf28 b;
_ = &b; // workaround for CS0165
+ DebugPoison(ref b);
+
b.Buf24.Low64 = d1.Low64 << shift;
b.Buf24.Mid64 = (d1.Mid + ((ulong)d1.High << 32)) >> (32 - shift);
{
Buf12 bufDivisor;
_ = &bufDivisor; // workaround for CS0165
+ DebugPoison(ref bufDivisor);
+
bufDivisor.Low64 = d2.Low64 << shift;
bufDivisor.U2 = (uint)((d2.Mid + ((ulong)d2.High << 32)) >> (32 - shift));