public static int Run(IHostApi hostApi, Benchmark benchmark, BenchmarkActionCodegen codegenMode) { bool isDiagnoserAttached = hostApi.IsDiagnoserAttached; // the first thing to do is to let diagnosers hook in before anything happens // so all jit-related diagnosers can catch first jit compilation! if (isDiagnoserAttached) { hostApi.BeforeAnythingElse(); } try { // we are not using Runnable here in any direct way in order to avoid strong dependency Main<=>Runnable // which could cause the jitting/assembly loading to happen before we do anything // we have some jitting diagnosers and we want them to catch all the informations!! var inProcessRunnableTypeName = $"{typeof(InProcessRunner).FullName}+{nameof(Runnable)}"; var type = typeof(InProcessRunner).GetTypeInfo().Assembly.GetType(inProcessRunnableTypeName); if (type == null) { throw new InvalidOperationException($"Bug: type {inProcessRunnableTypeName} not found."); } type.GetMethod(nameof(Runnable.RunCore), BindingFlags.Public | BindingFlags.Static) .Invoke(null, new object[] { hostApi, benchmark, codegenMode }); return(0); } catch (Exception ex) { hostApi.WriteLine(ex.ToString()); return(-1); } }