Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 internal RyuJitCompilation(
     DependencyAnalyzerBase<NodeFactory> dependencyGraph,
     NodeFactory nodeFactory,
     IEnumerable<ICompilationRootProvider> roots,
     Logger logger,
     JitConfigProvider configProvider)
     : base(dependencyGraph, nodeFactory, roots, new NameMangler(false), logger)
 {
     _jitConfigProvider = configProvider;
 }
Esempio n. 3
0
        public CorInfoImpl(Compilation compilation, JitConfigProvider jitConfig)
        {
            //
            // Global initialization
            //
            _compilation = compilation;
            _jitConfig = jitConfig;

            jitStartup(GetJitHost(_jitConfig.UnmanagedInstance));

            _jit = getJit();
            if (_jit == IntPtr.Zero)
            {
                throw new IOException("Failed to initialize JIT");
            }

            _unmanagedCallbacks = GetUnmanagedCallbacks(out _keepAlive);
        }
        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();
        }
Esempio n. 5
0
 public CorInfoImpl(ReadyToRunCodegenCompilation compilation, EcmaModule tokenContext, JitConfigProvider jitConfig)
     : this(jitConfig)
 {
     _compilation      = compilation;
     _tokenContext     = tokenContext;
     _signatureContext = new SignatureContext(_compilation.NodeFactory.Resolver);
 }
Esempio n. 6
0
 public CorInfoImpl(Compilation compilation, JitConfigProvider jitConfig)
     : this(jitConfig)
 {
     _compilation = compilation;
 }
 public override CompilationBuilder UseBackendOptions(IEnumerable<string> options)
 {
     _jitConfig = new JitConfigProvider(options);
     return this;
 }