static void Evaluate() { WhiteList whiteList = new WhiteList(); whiteList.AddFromXml("wlist.xml"); if (showProgress) Console.WriteLine("White list reading - OK"); Assembly assembly = Assembly.LoadFrom(sourceAssemblyName); AssemblyHolder srcHolder = new AssemblyHolder(assembly); if (showProgress) Console.WriteLine("Source assembly reading - OK"); if (showSourceCFG) { Console.WriteLine("\nSource CFG:\n----------\n"); Console.Write(srcHolder); } markTime(); AnnotatedAssemblyHolder btaHolder = new AnnotatedAssemblyHolder(srcHolder, whiteList); btaTime = getSpan(); if (showProgress) Console.WriteLine("Assembly annotation - OK"); if (showAnnotatedCFG) { Console.WriteLine("\nAnnotated CFG:\n-------------\n"); Console.Write(btaHolder.ToString("CSharp",ReflectionFormatter.formatter,new string[] { Annotation.BTTypeOption, Annotation.MethodBTTypeOption })); } markTime(); ResidualAssemblyHolder resHolder = new ResidualAssemblyHolder(btaHolder); specTime = getSpan(); if (showProgress) Console.WriteLine("Assembly specialization - OK"); if (showResidualCFG) { Console.WriteLine("\nResidual CFG:\n-------------\n"); Console.Write(resHolder.ToString("CSharp",ReflectionFormatter.formatter)); } if (enablePostprocessing) { markTime(); resHolder.Optimize(); pprocTime = getSpan(); if (showProgress) Console.WriteLine("Assembly postprocessing - OK"); if (showPostprocessedCFG) { Console.WriteLine("\nPostprocessed CFG:\n-----------------\n"); Console.Write(resHolder.ToString("CSharp",ReflectionFormatter.formatter)); } } Exporter.Export(resHolder, targetAssemblyName); if (showProgress) Console.WriteLine("Assembly export - OK"); if (enableClock) { Console.WriteLine("Timings:"); Console.WriteLine(" BTA - " + btaTime); Console.WriteLine(" Specializer - " + specTime); if (enablePostprocessing) Console.WriteLine(" Postprocessing - " + pprocTime); } }
internal static MethodBodyBlock AnnotateMethod(AnnotatedAssemblyHolder holder, AnnotatedMethod method) { MethodBodyBlock mbbDown = holder.SourceHolder[method.SourceMethod]; MethodBodyBlock mbbUp = mbbDown.Clone() as MethodBodyBlock; UpAndDownNodes upDownNodes = new UpAndDownNodes(); State state = new State(mbbUp.Variables.Count); for(int i = 0; i < mbbUp.Variables.ParameterMapper.Count; i++) { Variable var = mbbUp.Variables.ParameterMapper[i]; state.Pool[var] = new Location(var.Type); state.Pool[var].Val = (method.ParamVals[i].Val as ReferenceBTValue).ToStack(var.Type); } upDownNodes.SetUpAndDownNode(mbbDown, state, mbbUp); AnnotatingVisitor aVisitor; LiftingVisitor lVisitor; ControllingVisitor cVisitor = new ControllingVisitor(holder, method, upDownNodes, mbbUp, out aVisitor, out lVisitor); aVisitor.AddTask(mbbUp, state); return mbbUp; }
internal AnnotatingVisitor(AnnotatedAssemblyHolder holder, AnnotatedMethod method, ControllingVisitor cVisitor, UpAndDownNodes upDownNodes) : base(holder.GraphProcessor, 0) { this.holder = holder; this.cVisitor = cVisitor; this.upDownNodes = upDownNodes; this.ret = method.ReturnValue; }
internal ControllingVisitor(AnnotatedAssemblyHolder holder, AnnotatedMethod method, UpAndDownNodes upDownNodes, MethodBodyBlock mbbUp, out AnnotatingVisitor aVisitor, out LiftingVisitor lVisitor) : base(holder.GraphProcessor, 2) { this.holder = holder; this.method = method; this.method.ControllingVisitor = this; this.aVisitor = aVisitor = new AnnotatingVisitor(holder, method, this, upDownNodes); this.lVisitor = lVisitor = new LiftingVisitor(holder, this, aVisitor, upDownNodes); this.upDownNodes = upDownNodes; this.mbbUp = mbbUp; this.users = 0; }
internal LiftingVisitor(AnnotatedAssemblyHolder holder, ControllingVisitor cVisitor, AnnotatingVisitor aVisitor, UpAndDownNodes upDownNodes) : base(holder.GraphProcessor, 1) { this.cVisitor = cVisitor; this.aVisitor = aVisitor; this.upDownNodes = upDownNodes; }