Exemple #1
0
        public override ICompilation ToCompilation()
        {
            ArrayBuilder <CorJitFlag> jitFlagBuilder = new ArrayBuilder <CorJitFlag>();

            switch (_optimizationMode)
            {
            case OptimizationMode.None:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_CODE);
                break;

            case OptimizationMode.PreferSize:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_SIZE_OPT);
                break;

            case OptimizationMode.PreferSpeed:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_SPEED_OPT);
                break;

            default:
                // Not setting a flag results in BLENDED_CODE.
                break;
            }

            if (_generateDebugInfo)
            {
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_INFO);
            }

            var factory = new RyuJitNodeFactory(_context, _compilationGroup, _metadataManager, _nameMangler);

            var jitConfig = new JitConfigProvider(jitFlagBuilder.ToArray(), _ryujitOptions);
            DependencyAnalyzerBase <NodeFactory> graph = CreateDependencyGraph(factory);

            return(new RyuJitCompilation(graph, factory, _compilationRoots, _logger, jitConfig));
        }
        public override ICompilation ToCompilation()
        {
            ArrayBuilder <CorJitFlag> jitFlagBuilder = new ArrayBuilder <CorJitFlag>();

            switch (_optimizationMode)
            {
            case OptimizationMode.None:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_CODE);
                break;

            case OptimizationMode.PreferSize:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_SIZE_OPT);
                break;

            case OptimizationMode.PreferSpeed:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_SPEED_OPT);
                break;

            default:
                // Not setting a flag results in BLENDED_CODE.
                break;
            }

            if (_optimizationMode != OptimizationMode.None && _profileDataManager != null)
            {
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_BBOPT);
            }

            // Do not bother with debug information if the debug info provider never gives anything.
            if (!(_debugInformationProvider is NullDebugInformationProvider))
            {
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_INFO);
            }

            RyuJitCompilationOptions options = 0;

            if (_methodBodyFolding)
            {
                options |= RyuJitCompilationOptions.MethodBodyFolding;
            }

            if (_singleThreaded)
            {
                options |= RyuJitCompilationOptions.SingleThreadedCompilation;
            }

            if ((_mitigationOptions & SecurityMitigationOptions.ControlFlowGuardAnnotations) != 0)
            {
                options |= RyuJitCompilationOptions.ControlFlowGuardAnnotations;
            }

            var factory = new RyuJitNodeFactory(_context, _compilationGroup, _metadataManager, _interopStubManager, _nameMangler, _vtableSliceProvider, _dictionaryLayoutProvider, GetPreinitializationManager());

            JitConfigProvider.Initialize(_context.Target, jitFlagBuilder.ToArray(), _ryujitOptions);
            DependencyAnalyzerBase <NodeFactory> graph = CreateDependencyGraph(factory, new ObjectNode.ObjectNodeComparer(new CompilerComparer()));

            return(new RyuJitCompilation(graph, factory, _compilationRoots, _ilProvider, _debugInformationProvider, _logger, _devirtualizationManager, _inliningPolicy ?? _compilationGroup, _instructionSetSupport, _profileDataManager, _methodImportationErrorProvider, options));
        }
        public override ICompilation ToCompilation()
        {
            ArrayBuilder <CorJitFlag> jitFlagBuilder = new ArrayBuilder <CorJitFlag>();

            switch (_optimizationMode)
            {
            case OptimizationMode.None:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_CODE);
                break;

            case OptimizationMode.PreferSize:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_SIZE_OPT);
                break;

            case OptimizationMode.PreferSpeed:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_SPEED_OPT);
                break;

            default:
                // Not setting a flag results in BLENDED_CODE.
                break;
            }

            // Do not bother with debug information if the debug info provider never gives anything.
            if (!(_debugInformationProvider is NullDebugInformationProvider))
            {
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_INFO);
            }

            if (_context.Target.MaximumSimdVectorLength != SimdVectorLength.None)
            {
                // TODO: AVX
                Debug.Assert(_context.Target.MaximumSimdVectorLength == SimdVectorLength.Vector128Bit);
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_FEATURE_SIMD);
            }

            RyuJitCompilationOptions options = 0;

            if (_methodBodyFolding)
            {
                options |= RyuJitCompilationOptions.MethodBodyFolding;
            }

            if (_singleThreaded)
            {
                options |= RyuJitCompilationOptions.SingleThreadedCompilation;
            }

            var factory = new RyuJitNodeFactory(_context, _compilationGroup, _metadataManager, _interopStubManager, _nameMangler, _vtableSliceProvider, _dictionaryLayoutProvider);

            var jitConfig = new JitConfigProvider(jitFlagBuilder.ToArray(), _ryujitOptions);
            DependencyAnalyzerBase <NodeFactory> graph = CreateDependencyGraph(factory, new ObjectNode.ObjectNodeComparer(new CompilerComparer()));

            return(new RyuJitCompilation(graph, factory, _compilationRoots, _ilProvider, _debugInformationProvider, _logger, _devirtualizationManager, jitConfig, options));
        }
        public override ICompilation ToCompilation()
        {
            ArrayBuilder <CorJitFlag> jitFlagBuilder = new ArrayBuilder <CorJitFlag>();

            switch (_optimizationMode)
            {
            case OptimizationMode.None:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_CODE);
                break;

            case OptimizationMode.PreferSize:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_SIZE_OPT);
                break;

            case OptimizationMode.PreferSpeed:
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_SPEED_OPT);
                break;

            default:
                // Not setting a flag results in BLENDED_CODE.
                break;
            }

            if (_generateDebugInfo)
            {
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_DEBUG_INFO);
            }

            if (_context.Target.MaximumSimdVectorLength != SimdVectorLength.None)
            {
                // TODO: AVX
                Debug.Assert(_context.Target.MaximumSimdVectorLength == SimdVectorLength.Vector128Bit);
                jitFlagBuilder.Add(CorJitFlag.CORJIT_FLAG_FEATURE_SIMD);
            }

            var interopStubManager = new CompilerGeneratedInteropStubManager(_compilationGroup, _context, new InteropStateManager(_compilationGroup.GeneratedAssembly));
            var factory            = new RyuJitNodeFactory(_context, _compilationGroup, _metadataManager, interopStubManager, _nameMangler, _vtableSliceProvider, _dictionaryLayoutProvider);

            var jitConfig = new JitConfigProvider(jitFlagBuilder.ToArray(), _ryujitOptions);
            DependencyAnalyzerBase <NodeFactory> graph = CreateDependencyGraph(factory);

            return(new RyuJitCompilation(graph, factory, _compilationRoots, _logger, jitConfig));
        }