Exemplo 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;
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo 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);
        }
Exemplo n.º 4
0
 public ClosureEntitiesUtils(ClosureEntities getClosureEntities)
 {
     _getClosureEntities = getClosureEntities;
 }
Exemplo n.º 5
0
 public abstract bool UpdateClosure(ClosureEntities closureEntities);