예제 #1
0
        internal ILToNativeMap[] GetILMap(ulong ip, HotColdRegions hotColdInfo)
        {
            List <ILToNativeMap> list = new List <ILToNativeMap>();

            foreach (ClrDataMethod method in _dacInterface.EnumerateMethodInstancesByAddress(ip))
            {
                ILToNativeMap[] map = method.GetILToNativeMap();
                if (map != null)
                {
                    for (int i = 0; i < map.Length; i++)
                    {
                        if (map[i].StartAddress > map[i].EndAddress)
                        {
                            if (i + 1 == map.Length)
                            {
                                map[i].EndAddress = FindEnd(hotColdInfo, map[i].StartAddress);
                            }
                            else
                            {
                                map[i].EndAddress = map[i + 1].StartAddress - 1;
                            }
                        }
                    }

                    list.AddRange(map);
                }

                method.Dispose();
            }

            return(list.ToArray());
        }
예제 #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="HotColdRegionsAdapter" /> class.
 /// </summary>
 /// <param name="hotColdRegions">The hot cold regions.</param>
 /// <exception cref="ArgumentNullException">hotColdRegions</exception>
 /// <inheritdoc />
 public HotColdRegionsAdapter(IConverter converter, HotColdRegions hotColdRegions) : base(converter)
 {
     HotColdRegions = hotColdRegions ?? throw new ArgumentNullException(nameof(hotColdRegions));
     ColdSize       = HotColdRegions.ColdSize;
     ColdStart      = HotColdRegions.ColdStart;
     HotSize        = HotColdRegions.HotSize;
     HotStart       = HotColdRegions.HotStart;
 }
예제 #3
0
        public ClrmdMethod(ClrType type, IMethodData data)
        {
            if (data is null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            _helpers = data.Helpers;

            Type            = type;
            MethodDesc      = data.MethodDesc;
            CompilationType = data.CompilationType;
            MetadataToken   = data.Token;
            _hotCold        = new HotColdRegions(data.HotStart, data.HotSize, data.ColdStart, data.ColdSize);
            _attrs          = type?.Module?.MetadataImport?.GetMethodAttributes(MetadataToken) ?? default;
        }
예제 #4
0
        public DesktopMethod(DesktopRuntimeBase runtime, ulong md, IMethodDescData mdData, MethodAttributes attrs)
        {
            _runtime        = runtime;
            _sig            = runtime.GetNameForMD(md);
            _ip             = mdData.NativeCodeAddr;
            CompilationType = mdData.JITType;
            _attrs          = attrs;
            _token          = mdData.MDToken;
            GCInfo          = mdData.GCInfo;
            ClrHeap heap = runtime.Heap;

            _type       = (DesktopHeapType)heap.GetTypeByMethodTable(mdData.MethodTable, 0);
            HotColdInfo = new HotColdRegions {
                HotStart = _ip, HotSize = mdData.HotSize, ColdStart = mdData.ColdStart, ColdSize = mdData.ColdSize
            };
        }
예제 #5
0
        private static ulong FindEnd(HotColdRegions reg, ulong address)
        {
            ulong hotEnd = reg.HotStart + reg.HotSize;

            if (reg.HotStart <= address && address < hotEnd)
            {
                return(hotEnd);
            }

            ulong coldEnd = reg.ColdStart + reg.ColdSize;

            if (reg.ColdStart <= address && address < coldEnd)
            {
                return(coldEnd);
            }

            // Shouldn't reach here, but give a sensible answer if we do.
            return(address + 0x20);
        }