Exemplo n.º 1
0
        public void CheckFailList(OptimizerContext context, MethodDefinition method)
        {
            CheckFailList(context, method.DeclaringType, method.FullName);

            var entry = context.GetMethodEntries(method)?.FirstOrDefault(m => m.Action == MethodAction.Warn || m.Action == MethodAction.Fail);

            if (entry == null)
            {
                return;
            }

            var message = $"Found fail-listed method `{method.FullName}`";

            context.LogMessage(MessageImportance.High, Environment.NewLine);
            context.LogMessage(MessageImportance.High, message + ":");
            DumpFailEntry(context, entry);
            var stack = context.DumpTracerStack();

            OptimizerReport.FailList.Add(new FailListEntry(method, entry, stack));
            context.LogMessage(MessageImportance.High, Environment.NewLine);
            if (entry.Action == MethodAction.Fail)
            {
                throw new OptimizerException(message + ".");
            }
        }
        protected override void DoAdditionalProcessing()
        {
            if (_methods.Count > 0)
            {
                return;
            }

            ProcessingConditionals = true;

            while (_conditional_methods.Count > 0)
            {
                var conditional = _conditional_methods.Dequeue();

                Tracer.Push(conditional);

                var scanner = _block_scanner_by_method [conditional];
                if (scanner.DebugLevel > 0)
                {
                    OptimizerContext.LogMessage(MessageImportance.Normal, $"CONDITIONAL METHOD: {conditional}");
                    OptimizerContext.Debug();
                }

                scanner.RewriteConditionals();
                base.MarkMethodBody(conditional.Body);

                Tracer.Pop();
            }
        }
Exemplo n.º 3
0
 static void DumpFailEntry(OptimizerContext context, Method method)
 {
     context.LogMessage(MessageImportance.High, "  " + method);
     if (method.Parent != null)
     {
         DumpFailEntry(context, method.Parent);
     }
 }
Exemplo n.º 4
0
 static void DumpFailEntry(OptimizerContext context, Type type)
 {
     context.LogMessage(MessageImportance.High, "  " + type);
     if (type.Parent != null)
     {
         DumpFailEntry(context, type.Parent);
     }
 }
Exemplo n.º 5
0
        public void CheckFailList(OptimizerContext context, TypeDefinition type, string original = null)
        {
            var entry = context.GetTypeEntries(type)?.FirstOrDefault(t => t.Action == TypeAction.Warn || t.Action == TypeAction.Fail);

            if (entry == null)
            {
                return;
            }

            var original_message = original != null ? $" while parsing `{original}`" : string.Empty;
            var message          = $"Found fail-listed type `{type.FullName}`";

            context.LogMessage(MessageImportance.High, Environment.NewLine);
            context.LogMessage(MessageImportance.High, message + ":");
            DumpFailEntry(context, entry);
            var stack = context.DumpTracerStack();

            OptimizerReport.FailList.Add(new FailListEntry(type, entry, original, stack));
            context.LogMessage(MessageImportance.High, Environment.NewLine);
            if (entry.Action == TypeAction.Fail)
            {
                throw new OptimizerException(message + original_message + ".");
            }
        }
        protected override TypeDefinition MarkType(TypeReference reference)
        {
            if (reference == null)
            {
                return(null);
            }

            reference = GetOriginalType(reference);

            if (reference is FunctionPointerType)
            {
                return(null);
            }

            if (reference is GenericParameter)
            {
                return(null);
            }

            var type = ResolveTypeDefinition(reference);

            if (type == null)
            {
                HandleUnresolvedType(reference);
                return(null);
            }

            if (Annotations.IsProcessed(type))
            {
                return(null);
            }

            if (OptimizerContext.Options.EnableDebugging(OptimizerContext, type))
            {
                OptimizerContext.LogMessage(MessageImportance.Normal, $"MARK TYPE: {type}");
                OptimizerContext.Debug();
            }

            OptimizerContext.Options.CheckFailList(OptimizerContext, type);

            if (ProcessingConditionals && OptimizerContext.IsConditionalTypeMarked(type))
            {
                OptimizerContext.AttemptingToRedefineConditional(type);
            }

            return(base.MarkType(reference));
        }
        protected override void EnqueueMethod(MethodDefinition method)
        {
            if (OptimizerContext.Options.EnableDebugging(OptimizerContext, method))
            {
                OptimizerContext.LogMessage(MessageImportance.Normal, $"ENQUEUE METHOD: {method}");
                OptimizerContext.Debug();
            }

            OptimizerContext.Options.CheckFailList(OptimizerContext, method);

            if (_conditional_methods.Contains(method))
            {
                return;
            }

            base.EnqueueMethod(method);
        }
        protected override void MarkMethodBody(MethodBody body)
        {
            if (!OptimizerContext.IsEnabled(body.Method))
            {
                base.MarkMethodBody(body);
                return;
            }

            var debug = OptimizerContext.GetDebugLevel(body.Method);

            if (debug > 0)
            {
                OptimizerContext.LogMessage(MessageImportance.Normal, $"MARK BODY: {body.Method}");
                OptimizerContext.Debug();
            }

            var scanner = BasicBlockScanner.Scan(OptimizerContext, body.Method);

            if (scanner == null)
            {
                OptimizerContext.LogDebug($"BB SCAN FAILED: {body.Method}");
                base.MarkMethodBody(body);
                return;
            }

            if (scanner == null || !scanner.FoundConditionals)
            {
                base.MarkMethodBody(body);
                return;
            }

            if (debug > 0)
            {
                OptimizerContext.LogDebug($"MARK BODY - CONDITIONAL: {body.Method}");
            }

            scanner.RewriteConditionals();

            base.MarkMethodBody(body);
        }