コード例 #1
0
        public override void OptimizeOperations(CilMethodInterpreter interpreter)
        {
            var midRepresentation = interpreter.MidRepresentation;
            var useDef            = midRepresentation.UseDef;
            var loopStarts        = LoopDetection.FindLoops(midRepresentation);

            foreach (var loopStart in loopStarts)
            {
                var loopEnd                  = LoopDetection.GetEndLoop(useDef.GetLocalOperations(), loopStart);
                var allDefinedVariables      = GetAllDefinedVariables(midRepresentation, loopStart, loopEnd);
                var allInvariantInstructions = GetAllInvariantInstructions(midRepresentation, loopStart, loopEnd,
                                                                           allDefinedVariables);
                if (allInvariantInstructions.Count == 0)
                {
                    continue;
                }
                PerformMoveInstructions(midRepresentation, loopStart, allInvariantInstructions);
                Result = true;
                return;
            }
        }
コード例 #2
0
        public override bool CheckPreconditions(CilMethodInterpreter midRepresentation, ClosureEntities closure)
        {
            var loopStarts = LoopDetection.FindLoops(midRepresentation.MidRepresentation);

            return(loopStarts.Count != 0);
        }