From 006ad8c4f707662592f9a170191831d5a88a3ddc Mon Sep 17 00:00:00 2001 From: profan Date: Sat, 6 Jun 2026 20:55:45 +0100 Subject: [PATCH] hmm yes --- Program.cs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/Program.cs b/Program.cs index fca0f22..988e7ae 100644 --- a/Program.cs +++ b/Program.cs @@ -650,24 +650,7 @@ internal static class Compiler internal static class CompilerCache where T : unmanaged { - internal static readonly ConcurrentDictionary.EvaluateDelegate> CachedPrograms = - new ConcurrentDictionary.EvaluateDelegate>(); - } - - private static (AssemblyBuilder, MethodBuilder, TypeBuilder) CreateDynamicAssemblyWithMethodBuilder(string assemblyName, string moduleName, string typeName, string methodName) - where T : unmanaged - { - var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(assemblyName), AssemblyBuilderAccess.Run); - var moduleBuilder = assemblyBuilder.DefineDynamicModule(moduleName); - var typeBuilder = moduleBuilder.DefineType(typeName, TypeAttributes.Public); - var methodBuilder = - typeBuilder.DefineMethod( - methodName, - MethodAttributes.Public | MethodAttributes.Static, - typeof(void), - [typeof(Span), typeof(T), typeof(T)]); - - return (assemblyBuilder, methodBuilder, typeBuilder); + internal static readonly ConcurrentDictionary.EvaluateDelegate> CachedPrograms = new ConcurrentDictionary.EvaluateDelegate>(); } public static Delegates.EvaluateDelegate Compile(EvaluationInstructions evaluationInstructions) @@ -778,14 +761,14 @@ internal static class Compiler void EmitInvokeUnaryOperation(string methodName) { - // call with Span, pushed results of variables[a] and variables[b] reads + // call, but we're expecting only a single argument, this would be a good place to put validation methodGenerator.Emit(OpCodes.Call, typeof(Evaluation).GetMethod(methodName)!.MakeGenericMethod(typeof(T))); methodGenerator.Emit(OpCodes.Stloc_0); } void EmitInvokeBinaryOperation(string methodName) { - // call with Span, pushed results of variables[a] and variables[b] reads + // call, but we're expecting two arguments, this would be a good place to put validation methodGenerator.Emit(OpCodes.Call, typeof(Evaluation).GetMethod(methodName)!.MakeGenericMethod(typeof(T))); methodGenerator.Emit(OpCodes.Stloc_0); } @@ -967,6 +950,7 @@ internal static class Interpreter if (shouldCompileInnerLoop) { + // invoke the compilation before we go into the parallel context, considerably less fucked Compiler.Compile(evaluationInstructions); }