Describe the bug
KoiVM does not have a dedicated instruction for pushing floating point constants. Instead, it reuses the PUSHI_DWORD or PUSHI_QWORD instructions, as they use the same amount of bits as a float or a double respectively. This is not taken into account in the recompiler. The recompiler always interprets constants pushed by these instructions as int32 or int64 values.
To Reproduce
using System;
namespace MyProgram
{
public static class Program
{
public static void Main()
{
TestFloat(1.0F);
TestDouble(2.0F);
}
public static void TestFloat(float x)
{
Console.WriteLine(x);
}
public static void TestDouble(double x)
{
Console.WriteLine(x);
}
}
}
Expected behavior
Old Rod should devirtualize back to the following code:
Describe the bug KoiVM does not have a dedicated instruction for pushing floating point constants. Instead, it reuses the PUSHI_DWORD or PUSHI_QWORD instructions, as they use the same amount of bits as a float or a double respectively. This is not taken into account in the recompiler. The recompiler always interprets constants pushed by these instructions as int32 or int64 values.
To Reproduce
Expected behavior Old Rod should devirtualize back to the following code:
but instead it produces:
Additional context Many Windows Forms and WPF applications depend on this, as they use floats to assign locations and/or sizes to controls.