Exemple #1
0
 private APCMap <int> LocalStackMap(Subroutine subroutine)
 {
     if (this.local_stack_depth_cache == null || this.cached_subroutine != subroutine.Id)
     {
         this.local_stack_depth_cache = GetStackDepthMap(subroutine);
         this.cached_subroutine       = subroutine.Id;
     }
     return(this.local_stack_depth_cache);
 }
Exemple #2
0
        private APCMap <int> ComputeStackDepthMap(Subroutine subroutine)
        {
            var          startDepths = new Dictionary <int, StackInfo> (subroutine.BlockCount);
            APCMap <int> apcMap      = this.stack_depth_mirror_for_end_old = new APCMap <int> (subroutine);

            foreach (CFGBlock block in subroutine.Blocks)
            {
                StackInfo stackInfo;
                if (!startDepths.TryGetValue(block.Index, out stackInfo))
                {
                    stackInfo = ComputeBlockStartDepth(block);
                }
                foreach (APC apc in block.APCs())
                {
                    apcMap.Add(apc, stackInfo.Depth);
                    stackInfo = this.il_decoder.ForwardDecode <StackInfo, StackInfo, IILVisitor <APC, Dummy, Dummy, StackInfo, StackInfo> > (apc, this, stackInfo);
                }
                if (!apcMap.ContainsKey(block.Last))
                {
                    apcMap.Add(block.Last, stackInfo.Depth);
                }
                foreach (CFGBlock successor in subroutine.SuccessorBlocks(block))
                {
                    bool oldRecursionGuard = this.recursion_guard;
                    this.recursion_guard = true;
                    try {
                        bool isExceptionHandlerEdge;
                        foreach (var info in subroutine.EdgeSubroutinesOuterToInner(block, successor, out isExceptionHandlerEdge, null).AsEnumerable())
                        {
                            stackInfo.Adjust(info.Value.StackDelta);
                        }
                    } finally {
                        this.recursion_guard = oldRecursionGuard;
                    }
                    AddStartDepth(startDepths, successor, stackInfo);
                }
            }
            return(apcMap);
        }