コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }