Esempio n. 1
0
        public void OptimizeClosure(ClosureEntities entities)
        {
            var level = new OptimizationLevels();

            var optimizations = level.BuildOptimizationPasses1();

            level.BuildOptimizationPasses2();
            OptimizationLevelBase.UpdateOptimizationsFromCategories(optimizations);

            var cilMethods = MethodImplementations.Values
                             .Where(m => m.Kind == MethodKind.CilInstructions)
                             .Cast <CilMethodInterpreter>()
                             .ToArray();

            ResultingOptimizationPass.Closure = this;
            var isOptimizationPossible = true;

            while (isOptimizationPossible)
            {
                isOptimizationPossible = false;

                foreach (var cilMethod in cilMethods)
                {
                    isOptimizationPossible |= MethodInterpreterCodeWriter.ApplyLocalOptimizations(optimizations,
                                                                                                  cilMethod, entities);
                }

                var programWideOptimizationsAvailable = ApplyProgramWideOptimizations();
                isOptimizationPossible |= programWideOptimizationsAvailable;
            }
        }
        protected static void AddMethodToClosure(ClosureEntities closureEntities, MethodBase method)
        {
            var interpreter = closureEntities.ResolveMethod(method) ?? new CilMethodInterpreter(method);
            var intepreter  = interpreter as CilMethodInterpreter;

            if (intepreter != null)
            {
                intepreter.Process(closureEntities);
            }
            closureEntities.UseMethod(method, interpreter);
        }
Esempio n. 3
0
        public static ClosureEntities BuildClosureEntities(MethodInfo definition, Assembly runtimeAssembly)
        {
            var closureEntities = new ClosureEntities {
                EntryPoint = definition
            };
            var resolveRuntimeMethod = new ResolveRuntimeMethod(runtimeAssembly, closureEntities);

            closureEntities.AddMethodResolver(resolveRuntimeMethod);

            closureEntities.AddMethodResolver(new ResolvePlatformInvokeMethod());

            var extensionsResolverMethod = new ResolveRuntimeMethodUsingExtensions(runtimeAssembly, closureEntities);

            closureEntities.AddMethodResolver(extensionsResolverMethod);

            closureEntities.EntitiesBuilder.AddTypeResolver(new ResolveRuntimeType(runtimeAssembly));

            closureEntities.ComputeFullClosure();
            closureEntities.OptimizeClosure();
            return(closureEntities);
        }
Esempio n. 4
0
 public ClosureEntitiesUtils(ClosureEntities getClosureEntities)
 {
     _getClosureEntities = getClosureEntities;
 }
 public abstract bool UpdateClosure(ClosureEntities closureEntities);