Beispiel #1
0
        protected Compilation(
            DependencyAnalyzerBase <NodeFactory> dependencyGraph,
            NodeFactory nodeFactory,
            IEnumerable <ICompilationRootProvider> compilationRoots,
            ILProvider ilProvider,
            DebugInformationProvider debugInformationProvider,
            DevirtualizationManager devirtualizationManager,
            Logger logger)
        {
            _dependencyGraph          = dependencyGraph;
            _nodeFactory              = nodeFactory;
            _logger                   = logger;
            _debugInformationProvider = debugInformationProvider;
            _devirtualizationManager  = devirtualizationManager;

            _dependencyGraph.ComputeDependencyRoutine += ComputeDependencyNodeDependencies;
            NodeFactory.AttachToDependencyGraph(_dependencyGraph);

            var rootingService = new RootingServiceProvider(dependencyGraph, nodeFactory);

            foreach (var rootProvider in compilationRoots)
            {
                rootProvider.AddCompilationRoots(rootingService);
            }

            MetadataType globalModuleGeneratedType = nodeFactory.TypeSystemContext.GeneratedAssembly.GetGlobalModuleType();

            _typeGetTypeMethodThunks = new TypeGetTypeMethodThunkCache(globalModuleGeneratedType);
            _assemblyGetExecutingAssemblyMethodThunks = new AssemblyGetExecutingAssemblyMethodThunkCache(globalModuleGeneratedType);
            _methodBaseGetCurrentMethodThunks         = new MethodBaseGetCurrentMethodThunkCache();

            if (!(nodeFactory.InteropStubManager is EmptyInteropStubManager))
            {
                bool?forceLazyPInvokeResolution = null;
                // TODO: Workaround lazy PInvoke resolution not working with CppCodeGen yet
                // https://github.com/dotnet/corert/issues/2454
                // https://github.com/dotnet/corert/issues/2149
                if (nodeFactory.IsCppCodegenTemporaryWorkaround)
                {
                    forceLazyPInvokeResolution = false;
                }
                PInvokeILProvider = new PInvokeILProvider(new PInvokeILEmitterConfiguration(forceLazyPInvokeResolution), nodeFactory.InteropStubManager.InteropStateManager);

                ilProvider = new CombinedILProvider(ilProvider, PInvokeILProvider);
            }

            _methodILCache = new ILCache(ilProvider);
        }
Beispiel #2
0
        protected Compilation(
            DependencyAnalyzerBase <NodeFactory> dependencyGraph,
            NodeFactory nodeFactory,
            IEnumerable <ICompilationRootProvider> compilationRoots,
            ILProvider ilProvider,
            DebugInformationProvider debugInformationProvider,
            DevirtualizationManager devirtualizationManager,
            IInliningPolicy inliningPolicy,
            Logger logger)
        {
            _dependencyGraph          = dependencyGraph;
            _nodeFactory              = nodeFactory;
            _logger                   = logger;
            _debugInformationProvider = debugInformationProvider;
            _devirtualizationManager  = devirtualizationManager;
            _inliningPolicy           = inliningPolicy;

            _dependencyGraph.ComputeDependencyRoutine += ComputeDependencyNodeDependencies;
            NodeFactory.AttachToDependencyGraph(_dependencyGraph);

            var rootingService = new RootingServiceProvider(nodeFactory, _dependencyGraph.AddRoot);

            foreach (var rootProvider in compilationRoots)
            {
                rootProvider.AddCompilationRoots(rootingService);
            }

            MetadataType globalModuleGeneratedType = nodeFactory.TypeSystemContext.GeneratedAssembly.GetGlobalModuleType();

            _typeGetTypeMethodThunks = new TypeGetTypeMethodThunkCache(globalModuleGeneratedType);
            _assemblyGetExecutingAssemblyMethodThunks = new AssemblyGetExecutingAssemblyMethodThunkCache(globalModuleGeneratedType);
            _methodBaseGetCurrentMethodThunks         = new MethodBaseGetCurrentMethodThunkCache();

            PInvokeILProvider = _nodeFactory.InteropStubManager.CreatePInvokeILProvider();
            if (PInvokeILProvider != null)
            {
                ilProvider = new CombinedILProvider(ilProvider, PInvokeILProvider);
            }

            _methodILCache = new ILCache(ilProvider);
        }