claw back some time with skip locals init
This commit is contained in:
parent
b576f44fea
commit
88cea8be53
19
Program.cs
19
Program.cs
|
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
|
||||||
|
|
@ -43,21 +44,7 @@ void CreateOutputImage(int imageSize, float[] imageData, string imageOutputPath)
|
||||||
data.SaveTo(stream);
|
data.SaveTo(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum OpCode
|
enum OpCode { VarX, VarY, Const, Add, Sub, Mul, Max, Min, Neg, Square, Sqrt }
|
||||||
{
|
|
||||||
VarX,
|
|
||||||
VarY,
|
|
||||||
Const,
|
|
||||||
Add,
|
|
||||||
Sub,
|
|
||||||
Mul,
|
|
||||||
Max,
|
|
||||||
Min,
|
|
||||||
Neg,
|
|
||||||
Square,
|
|
||||||
Sqrt
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly record struct Instruction(int Out, OpCode OpCode, int A = -1, int B = -1, float V = float.MaxValue);
|
readonly record struct Instruction(int Out, OpCode OpCode, int A = -1, int B = -1, float V = float.MaxValue);
|
||||||
|
|
||||||
static class Parsing
|
static class Parsing
|
||||||
|
|
@ -179,8 +166,10 @@ static class Interpreter
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SkipLocalsInit]
|
||||||
public static Vector<float> Evaluate(Instruction[] instructions, Vector<float> xs, Vector<float> ys)
|
public static Vector<float> Evaluate(Instruction[] instructions, Vector<float> xs, Vector<float> ys)
|
||||||
{
|
{
|
||||||
|
// #TODO: this construction is just a little bit unhinged lol
|
||||||
Span<Vector<float>> variables = stackalloc Vector<float>[instructions.Length];
|
Span<Vector<float>> variables = stackalloc Vector<float>[instructions.Length];
|
||||||
|
|
||||||
foreach (ref Instruction instruction in instructions.AsSpan())
|
foreach (ref Instruction instruction in instructions.AsSpan())
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue