private object _keepAlive; // Keeps callback delegates alive public static void Initialize(IEnumerable <CorJitFlag> jitFlags, IEnumerable <KeyValuePair <string, string> > parameters, string jitPath = null) { var config = new JitConfigProvider(jitFlags, parameters); // Make sure we didn't try to initialize two instances of JIT configuration. // RyuJIT doesn't support multiple hosts in a single process. if (Interlocked.CompareExchange(ref s_instance, config, null) != null) { throw new InvalidOperationException(); } #if READYTORUN if (jitPath != null) { NativeLibrary.SetDllImportResolver(typeof(CorInfoImpl).Assembly, (libName, assembly, searchPath) => { IntPtr libHandle = IntPtr.Zero; if (libName == CorInfoImpl.JitLibrary) { libHandle = NativeLibrary.Load(jitPath, assembly, searchPath); } return(libHandle); }); } #else Debug.Assert(jitPath == null); #endif CorInfoImpl.Startup(); }
public static void Initialize( TargetDetails target, IEnumerable <CorJitFlag> jitFlags, IEnumerable <KeyValuePair <string, string> > parameters, string jitPath = null) { var config = new JitConfigProvider(jitFlags, parameters); // Make sure we didn't try to initialize two instances of JIT configuration. // RyuJIT doesn't support multiple hosts in a single process. if (Interlocked.CompareExchange(ref s_instance, config, null) != null) { throw new InvalidOperationException(); } NativeLibrary.SetDllImportResolver(typeof(CorInfoImpl).Assembly, (libName, assembly, searchPath) => { IntPtr libHandle = IntPtr.Zero; #if READYTORUN if (libName == CorInfoImpl.JitLibrary) { if (!string.IsNullOrEmpty(jitPath)) { libHandle = NativeLibrary.Load(jitPath); } else { libHandle = NativeLibrary.Load("clrjit_" + GetTargetSpec(target), assembly, searchPath); } } #else Debug.Assert(jitPath == null); #endif if (libName == CorInfoImpl.JitSupportLibrary) { libHandle = NativeLibrary.Load("jitinterface_" + RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(), assembly, searchPath); } return(libHandle); }); CorInfoImpl.Startup(); }