Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Mantione <massi@mono-cvs.ximian.com>2008-10-13 16:24:25 +0400
committerMassimiliano Mantione <massi@mono-cvs.ximian.com>2008-10-13 16:24:25 +0400
commit3af8e302685158afe93374bf12530301c9e2f9c3 (patch)
treeef9e55d2dfba64a4694136ff085b1c8db7f3696c /Mono.Profiler
parentca9b21f8dc83c7d9c4de3854119195dba398bb20 (diff)
Turn HeapObject class into generic BaseHeapObject class, and add a new IAllocatedObject interface (this will give more freedom when implementing HeapObject and AllocatedObject separately).
svn path=/trunk/mono-tools/; revision=115650
Diffstat (limited to 'Mono.Profiler')
-rw-r--r--Mono.Profiler/heap-snapshot-explorer/ChangeLog3
-rw-r--r--Mono.Profiler/heap-snapshot-explorer/HeapExplorerTreeModel.cs2
-rw-r--r--Mono.Profiler/profiler-decoder-library/BaseTypes.cs73
-rw-r--r--Mono.Profiler/profiler-decoder-library/ChangeLog9
-rw-r--r--Mono.Profiler/profiler-decoder-library/EventProcessor.cs6
-rw-r--r--Mono.Profiler/profiler-decoder-library/ObjectModel.cs56
6 files changed, 80 insertions, 69 deletions
diff --git a/Mono.Profiler/heap-snapshot-explorer/ChangeLog b/Mono.Profiler/heap-snapshot-explorer/ChangeLog
index 9d1037e0..948f1f88 100644
--- a/Mono.Profiler/heap-snapshot-explorer/ChangeLog
+++ b/Mono.Profiler/heap-snapshot-explorer/ChangeLog
@@ -1,3 +1,6 @@
+2008-10-13 Massimiliano Mantione <massi@ximian.com>
+ * HeapExplorerTreeModel.cs: Use new HeapObject non-generic class.
+
2008-08-12 Massimiliano Mantione <massi@ximian.com>
* Makefile.am: Fixed for integration into mono-tools;
diff --git a/Mono.Profiler/heap-snapshot-explorer/HeapExplorerTreeModel.cs b/Mono.Profiler/heap-snapshot-explorer/HeapExplorerTreeModel.cs
index 512ce0ed..a4be67ac 100644
--- a/Mono.Profiler/heap-snapshot-explorer/HeapExplorerTreeModel.cs
+++ b/Mono.Profiler/heap-snapshot-explorer/HeapExplorerTreeModel.cs
@@ -199,7 +199,7 @@ namespace Mono.Profiler
public override void HeapObjectUnreachable (LoadedClass c, uint size) {
lastHeapSnapshot.HeapObjectUnreachable (c, size);
}
- public override void HeapObjectReachable (HeapObject<LoadedClass> o) {
+ public override void HeapObjectReachable (HeapObject o) {
}
public override void HeapReportEnd (HeapSnapshot snapshot) {
lastHeapSnapshot.InitializeBackReferences ();
diff --git a/Mono.Profiler/profiler-decoder-library/BaseTypes.cs b/Mono.Profiler/profiler-decoder-library/BaseTypes.cs
index 9da15374..4f91f785 100644
--- a/Mono.Profiler/profiler-decoder-library/BaseTypes.cs
+++ b/Mono.Profiler/profiler-decoder-library/BaseTypes.cs
@@ -77,13 +77,16 @@ namespace Mono.Profiler {
UFR[] Functions {get;}
void SortFunctions ();
}
- public interface IHeapObject<HO,LC> where HO: IHeapObject<HO,LC> where LC : ILoadedClass {
+ public interface IAllocatedObject<LC> where LC : ILoadedClass {
ulong ID {get;}
LC Class {get;}
uint Size {get;}
+ }
+ public interface IHeapObject<HO,LC> : IAllocatedObject<LC> where HO: IHeapObject<HO,LC> where LC : ILoadedClass {
HO[] References {get;}
HO[] BackReferences {get;}
}
+ public delegate HO HeapObjectFactory<HO,LC> (ulong ID) where HO : IHeapObject<HO,LC> where LC : ILoadedClass;
public interface IHeapSnapshot<HO,LC> where HO: IHeapObject<HO,LC> where LC : ILoadedClass {
uint Collection {get;}
ulong StartCounter {get;}
@@ -298,7 +301,7 @@ namespace Mono.Profiler {
}
}
- public class HeapObject<LC> : IHeapObject<HeapObject<LC>,LC> where LC : ILoadedClass {
+ public class BaseHeapObject<HO,LC> : IHeapObject<HO,LC> where LC : ILoadedClass where HO : BaseHeapObject<HO,LC> {
ulong id;
public ulong ID {
get {
@@ -325,15 +328,15 @@ namespace Mono.Profiler {
}
}
- static HeapObject<LC>[] emptyReferences = new HeapObject<LC> [0];
- public static HeapObject<LC>[] EmptyReferences {
+ static HO[] emptyReferences = new HO [0];
+ public static HO[] EmptyReferences {
get {
return emptyReferences;
}
}
- HeapObject<LC>[] references;
- public HeapObject<LC>[] References {
+ HO[] references;
+ public HO[] References {
get {
return references;
}
@@ -342,8 +345,8 @@ namespace Mono.Profiler {
}
}
- HeapObject<LC>[] backReferences;
- public HeapObject<LC>[] BackReferences {
+ HO[] backReferences;
+ public HO[] BackReferences {
get {
return backReferences;
}
@@ -359,16 +362,16 @@ namespace Mono.Profiler {
internal void AllocateBackReferences () {
if (references != null) {
int referencesCount = 0;
- foreach (HeapObject<LC> reference in references) {
+ foreach (HO reference in references) {
if (reference != null) {
referencesCount ++;
}
}
if (referencesCount != references.Length) {
if (referencesCount > 0) {
- HeapObject<LC>[] newReferences = new HeapObject<LC> [referencesCount];
+ HO[] newReferences = new HO [referencesCount];
referencesCount = 0;
- foreach (HeapObject<LC> reference in references) {
+ foreach (HO reference in references) {
if (reference != null) {
newReferences [referencesCount] = reference;
referencesCount ++;
@@ -384,26 +387,18 @@ namespace Mono.Profiler {
}
if (backReferencesCounter > 0) {
- backReferences = new HeapObject<LC> [backReferencesCounter];
+ backReferences = new HO [backReferencesCounter];
backReferencesCounter = 0;
} else {
references = emptyReferences;
}
}
- internal void AddBackReference (HeapObject<LC> heapObject) {
+ internal void AddBackReference (HO heapObject) {
backReferences [backReferencesCounter] = heapObject;
backReferencesCounter ++;
}
- public HeapObject (ulong id, LC c, uint size, HeapObject<LC>[] references) {
- this.id = id;
- this.c = c;
- this.size = size;
- this.references = references;
- this.backReferences = null;
- this.backReferencesCounter = 0;
- }
- public HeapObject (ulong id) {
+ public BaseHeapObject (ulong id) {
this.id = id;
this.c = default(LC);
this.size = 0;
@@ -413,9 +408,10 @@ namespace Mono.Profiler {
}
}
- public abstract class BaseHeapSnapshot<HO,LC> : IHeapSnapshot<HeapObject<LC>,LC> where LC : ILoadedClass {
- Dictionary<ulong,HeapObject<LC>> heap;
+ public abstract class BaseHeapSnapshot<HO,LC> : IHeapSnapshot<HO,LC> where LC : ILoadedClass where HO : BaseHeapObject<HO,LC> {
+ Dictionary<ulong,HO> heap;
bool backReferencesInitialized;
+ HeapObjectFactory<HO,LC> heapObjectFactory;
uint collection;
public uint Collection {
@@ -449,14 +445,14 @@ namespace Mono.Profiler {
}
}
- public HeapObject<LC> NewHeapObject (ulong id, LC c, uint size, ulong[] referenceIds, int referencesCount) {
+ public HO NewHeapObject (ulong id, LC c, uint size, ulong[] referenceIds, int referencesCount) {
if (backReferencesInitialized) {
throw new Exception ("Cannot create heap objects after backReferencesInitialized is true");
}
if (recordSnapshot) {
- HeapObject<LC>[] references = new HeapObject<LC>[referencesCount];
- HeapObject<LC> result = GetOrCreateHeapObject (id);
+ HO[] references = new HO [referencesCount];
+ HO result = GetOrCreateHeapObject (id);
for (int i = 0; i < references.Length; i++) {
references [i] = GetOrCreateHeapObject (referenceIds [i]);
references [i].IncrementBackReferences ();
@@ -476,9 +472,9 @@ namespace Mono.Profiler {
}
//FIXME: Bad objects should not happen anymore...
- Dictionary<ulong,HeapObject<LC>> badObjects = new Dictionary<ulong,HeapObject<LC>> ();
+ Dictionary<ulong,HO> badObjects = new Dictionary<ulong,HO> ();
- foreach (HeapObject<LC> heapObject in heap.Values) {
+ foreach (HO heapObject in heap.Values) {
if (heapObject.Class != null) {
heapObject.AllocateBackReferences ();
} else {
@@ -490,8 +486,8 @@ namespace Mono.Profiler {
heap.Remove (id);
}
- foreach (HeapObject<LC> heapObject in heap.Values) {
- foreach (HeapObject<LC> reference in heapObject.References) {
+ foreach (HO heapObject in heap.Values) {
+ foreach (HO reference in heapObject.References) {
reference.AddBackReference (heapObject);
}
}
@@ -499,12 +495,12 @@ namespace Mono.Profiler {
backReferencesInitialized = true;
}
- HeapObject<LC> GetOrCreateHeapObject (ulong id) {
+ HO GetOrCreateHeapObject (ulong id) {
if (recordSnapshot) {
if (heap.ContainsKey (id)) {
return heap [id];
} else {
- HeapObject<LC> result = new HeapObject<LC> (id);
+ HO result = heapObjectFactory (id);
heap [id] = result;
return result;
}
@@ -513,13 +509,13 @@ namespace Mono.Profiler {
}
}
- public HeapObject<LC> GetHeapObject (ulong id) {
+ public HO GetHeapObject (ulong id) {
return heap [id];
}
- public HeapObject<LC>[] HeapObjects {
+ public HO[] HeapObjects {
get {
- HeapObject<LC>[] result = new HeapObject<LC> [heap.Values.Count];
+ HO[] result = new HO [heap.Values.Count];
heap.Values.CopyTo (result, 0);
return result;
}
@@ -532,14 +528,15 @@ namespace Mono.Profiler {
}
}
- public BaseHeapSnapshot (uint collection, ulong startCounter, DateTime startTime, ulong endCounter, DateTime endTime, bool recordSnapshot) {
+ public BaseHeapSnapshot (HeapObjectFactory<HO,LC> heapObjectFactory, uint collection, ulong startCounter, DateTime startTime, ulong endCounter, DateTime endTime, bool recordSnapshot) {
+ this.heapObjectFactory = heapObjectFactory;
this.collection = collection;
this.startCounter = startCounter;
this.startTime = startTime;
this.endCounter = endCounter;
this.endTime = endTime;
this.recordSnapshot = recordSnapshot;
- heap = new Dictionary<ulong,HeapObject<LC>> ();
+ heap = new Dictionary<ulong,HO> ();
backReferencesInitialized = false;
}
}
diff --git a/Mono.Profiler/profiler-decoder-library/ChangeLog b/Mono.Profiler/profiler-decoder-library/ChangeLog
index 744fca17..035295c3 100644
--- a/Mono.Profiler/profiler-decoder-library/ChangeLog
+++ b/Mono.Profiler/profiler-decoder-library/ChangeLog
@@ -1,6 +1,13 @@
+2008-10-13 Massimiliano Mantione <massi@ximian.com>
+ * BaseTypes.cs: Turn HeapObject class into generic BaseHeapObject class,
+ and add a new IAllocatedObject interface (this will give more freedom
+ when implementing HeapObject and AllocatedObject separately).
+ * ObjectModel.cs: Derive HeapObject from BaseHeapObject.
+ * EventProcessor.cs: Likewise.
+
2008-10-12 Massimiliano Mantione <massi@ximian.com>
* BaseTypes.cs: Added support for object ids in allocation events.
- * Decoder.cs: Likewise.
+ * ObjectModel.cs: Likewise.
* EventProcessor.cs: Likewise.
2008-10-10 Massimiliano Mantione <massi@ximian.com>
diff --git a/Mono.Profiler/profiler-decoder-library/EventProcessor.cs b/Mono.Profiler/profiler-decoder-library/EventProcessor.cs
index 454b7778..12e16e51 100644
--- a/Mono.Profiler/profiler-decoder-library/EventProcessor.cs
+++ b/Mono.Profiler/profiler-decoder-library/EventProcessor.cs
@@ -70,7 +70,7 @@ namespace Mono.Profiler {
}
}
- public class ProfilerEventHandler : BaseProfilerEventHandler<LoadedClass,LoadedMethod,UnmanagedFunctionFromRegion,UnmanagedFunctionFromID,ExecutableMemoryRegion,LoadedElementHandler<LoadedClass,LoadedMethod,UnmanagedFunctionFromRegion,UnmanagedFunctionFromID,ExecutableMemoryRegion,HeapObject<LoadedClass>,HeapSnapshot>,HeapObject<LoadedClass>,HeapSnapshot> {
+ public class ProfilerEventHandler : BaseProfilerEventHandler<LoadedClass,LoadedMethod,UnmanagedFunctionFromRegion,UnmanagedFunctionFromID,ExecutableMemoryRegion,LoadedElementHandler<LoadedClass,LoadedMethod,UnmanagedFunctionFromRegion,UnmanagedFunctionFromID,ExecutableMemoryRegion,HeapObject,HeapSnapshot>,HeapObject,HeapSnapshot> {
Dictionary<ulong,CallStack> perThreadStacks;
CallStack stack;
UnknownStatisticalHitsCollector unknownStatisticalHitsCollector;
@@ -544,7 +544,7 @@ namespace Mono.Profiler {
c.InstanceFreed (size);
currentHeapSnapshot.HeapObjectUnreachable (c, size);
}
- public override void HeapObjectReachable (HeapObject<LoadedClass> o) {
+ public override void HeapObjectReachable (HeapObject o) {
}
public override void HeapReportEnd (HeapSnapshot snapshot) {
snapshot.InitializeBackReferences ();
@@ -575,7 +575,7 @@ namespace Mono.Profiler {
}
}
- public ProfilerEventHandler () : base (new LoadedElementHandler<LoadedClass,LoadedMethod,UnmanagedFunctionFromRegion,UnmanagedFunctionFromID,ExecutableMemoryRegion,HeapObject<LoadedClass>,HeapSnapshot> (new LoadedElementFactory ())) {
+ public ProfilerEventHandler () : base (new LoadedElementHandler<LoadedClass,LoadedMethod,UnmanagedFunctionFromRegion,UnmanagedFunctionFromID,ExecutableMemoryRegion,HeapObject,HeapSnapshot> (new LoadedElementFactory ())) {
perThreadStacks = new Dictionary<ulong,CallStack> ();
stack = null;
unknownStatisticalHitsCollector = new UnknownStatisticalHitsCollector ();
diff --git a/Mono.Profiler/profiler-decoder-library/ObjectModel.cs b/Mono.Profiler/profiler-decoder-library/ObjectModel.cs
index badb09c1..fa2591e4 100644
--- a/Mono.Profiler/profiler-decoder-library/ObjectModel.cs
+++ b/Mono.Profiler/profiler-decoder-library/ObjectModel.cs
@@ -908,7 +908,11 @@ namespace Mono.Profiler {
}
}
- public class HeapSnapshot : BaseHeapSnapshot<HeapObject<LoadedClass>,LoadedClass> {
+ public class HeapObject : BaseHeapObject<HeapObject,LoadedClass> {
+ public HeapObject (ulong ID) : base (ID) {}
+ }
+
+ public class HeapSnapshot : BaseHeapSnapshot<HeapObject,LoadedClass> {
public class AllocationStatisticsPerClass {
LoadedClass c;
public LoadedClass Class {
@@ -974,7 +978,7 @@ namespace Mono.Profiler {
statisticsPerClass.BytesFreed (size);
}
- public HeapSnapshot (uint collection, ulong startCounter, DateTime startTime, ulong endCounter, DateTime endTime, LoadedClass[] initialAllocations, bool recordSnapshot) : base (collection, startCounter, startTime, endCounter, endTime, recordSnapshot) {
+ public HeapSnapshot (uint collection, ulong startCounter, DateTime startTime, ulong endCounter, DateTime endTime, LoadedClass[] initialAllocations, bool recordSnapshot) : base (delegate (ulong ID) {return new HeapObject (ID);}, collection, startCounter, startTime, endCounter, endTime, recordSnapshot) {
uint maxClassId = 0;
foreach (LoadedClass c in initialAllocations) {
if (c.ID > maxClassId) {
@@ -993,7 +997,7 @@ namespace Mono.Profiler {
string Description {
get;
}
- bool Filter (HeapObject<LoadedClass> heapObject);
+ bool Filter (HeapObject heapObject);
}
public abstract class FilterHeapObjectByClass : IHeapObjectFilter {
@@ -1004,7 +1008,7 @@ namespace Mono.Profiler {
}
}
- public abstract bool Filter (HeapObject<LoadedClass> heapObject);
+ public abstract bool Filter (HeapObject heapObject);
string description;
public string Description {
@@ -1024,7 +1028,7 @@ namespace Mono.Profiler {
return String.Format ("Object has class {0}", c.Name);
}
- public override bool Filter (HeapObject<LoadedClass> heapObject) {
+ public override bool Filter (HeapObject heapObject) {
return heapObject.Class == c;
}
@@ -1037,8 +1041,8 @@ namespace Mono.Profiler {
return String.Format ("Object references object of class {0}", c.Name);
}
- public override bool Filter (HeapObject<LoadedClass> heapObject) {
- foreach (HeapObject<LoadedClass> ho in heapObject.References) {
+ public override bool Filter (HeapObject heapObject) {
+ foreach (HeapObject ho in heapObject.References) {
if (ho.Class == c) {
return true;
}
@@ -1055,8 +1059,8 @@ namespace Mono.Profiler {
return String.Format ("Object is referenced by object of class {0}", c.Name);
}
- public override bool Filter (HeapObject<LoadedClass> heapObject) {
- foreach (HeapObject<LoadedClass> ho in heapObject.BackReferences) {
+ public override bool Filter (HeapObject heapObject) {
+ foreach (HeapObject ho in heapObject.BackReferences) {
if (ho.Class == c) {
return true;
}
@@ -1069,7 +1073,7 @@ namespace Mono.Profiler {
}
public abstract class HeapObjectSet {
- public static Comparison<HeapObject<LoadedClass>> CompareHeapObjectsByID = delegate (HeapObject<LoadedClass> a, HeapObject<LoadedClass> b) {
+ public static Comparison<HeapObject> CompareHeapObjectsByID = delegate (HeapObject a, HeapObject b) {
return a.ID.CompareTo (b.ID);
};
@@ -1111,8 +1115,8 @@ namespace Mono.Profiler {
return longDescription;
}
}
- HeapObject<LoadedClass>[] heapObjects;
- public HeapObject<LoadedClass>[] HeapObjects {
+ HeapObject[] heapObjects;
+ public HeapObject[] HeapObjects {
get {
return heapObjects;
}
@@ -1130,7 +1134,7 @@ namespace Mono.Profiler {
}
}
- protected HeapObjectSet (string shortDescription, string longDescription, HeapObject<LoadedClass>[] heapObjects) {
+ protected HeapObjectSet (string shortDescription, string longDescription, HeapObject[] heapObjects) {
this.shortDescription = shortDescription;
this.longDescription = longDescription;
this.heapObjects = heapObjects;
@@ -1139,7 +1143,7 @@ namespace Mono.Profiler {
Array.Sort (this.heapObjects, CompareHeapObjectsByID);
Dictionary<ulong,HeapObjectSetClassStatistics> statistics = new Dictionary<ulong,HeapObjectSetClassStatistics> ();
- foreach (HeapObject<LoadedClass> ho in heapObjects) {
+ foreach (HeapObject ho in heapObjects) {
HeapObjectSetClassStatistics cs;
if (statistics.ContainsKey (ho.Class.ID)) {
cs = statistics [ho.Class.ID];
@@ -1188,14 +1192,14 @@ namespace Mono.Profiler {
}
}
- static HeapObject<LoadedClass>[] filterSet (HeapObjectSet baseSet, IHeapObjectFilter filter) {
- List<HeapObject<LoadedClass>> newSet = new List<HeapObject<LoadedClass>> ();
- foreach (HeapObject<LoadedClass> ho in baseSet.HeapObjects) {
+ static HeapObject[] filterSet (HeapObjectSet baseSet, IHeapObjectFilter filter) {
+ List<HeapObject> newSet = new List<HeapObject> ();
+ foreach (HeapObject ho in baseSet.HeapObjects) {
if (filter.Filter (ho)) {
newSet.Add (ho);
}
}
- HeapObject<LoadedClass>[] result = new HeapObject<LoadedClass> [newSet.Count];
+ HeapObject[] result = new HeapObject [newSet.Count];
newSet.CopyTo (result);
return result;
}
@@ -1230,13 +1234,13 @@ namespace Mono.Profiler {
}
public static void PerformComparison (HeapObjectSet firstSet, HeapObjectSet secondSet, out HeapObjectSet onlyInFirstSet, out HeapObjectSet onlyInSecondSet) {
- List<HeapObject<LoadedClass>> onlyInFirst = new List<HeapObject<LoadedClass>> ();
- List<HeapObject<LoadedClass>> onlyInSecond = new List<HeapObject<LoadedClass>> ();
+ List<HeapObject> onlyInFirst = new List<HeapObject> ();
+ List<HeapObject> onlyInSecond = new List<HeapObject> ();
int firstIndex = 0;
int secondIndex = 0;
- HeapObject<LoadedClass>[] firstObjects = firstSet.HeapObjects;
- HeapObject<LoadedClass>[] secondObjects = secondSet.HeapObjects;
+ HeapObject[] firstObjects = firstSet.HeapObjects;
+ HeapObject[] secondObjects = secondSet.HeapObjects;
while ((firstIndex < firstObjects.Length) || (secondIndex < secondObjects.Length)) {
if (firstIndex >= firstObjects.Length) {
@@ -1250,8 +1254,8 @@ namespace Mono.Profiler {
firstIndex ++;
}
} else {
- HeapObject<LoadedClass> firstObject = firstObjects [firstIndex];
- HeapObject<LoadedClass> secondObject = secondObjects [secondIndex];
+ HeapObject firstObject = firstObjects [firstIndex];
+ HeapObject secondObject = secondObjects [secondIndex];
if (firstObject.ID < secondObject.ID) {
onlyInFirst.Add (firstObject);
firstIndex ++;
@@ -1269,13 +1273,13 @@ namespace Mono.Profiler {
onlyInSecondSet = new HeapObjectSetFromComparison(secondSet, firstSet, onlyInSecond.ToArray ());
}
- HeapObjectSetFromComparison (HeapObjectSet baseSet, HeapObjectSet otherSet, HeapObject<LoadedClass>[] heapObjects): base (buildShortDescription (otherSet), buildLongDescription (otherSet), heapObjects) {
+ HeapObjectSetFromComparison (HeapObjectSet baseSet, HeapObjectSet otherSet, HeapObject[] heapObjects): base (buildShortDescription (otherSet), buildLongDescription (otherSet), heapObjects) {
this.baseSet = baseSet;
this.otherSet = otherSet;
}
}
- public class LoadedElementFactory : ILoadedElementFactory<LoadedClass,LoadedMethod,UnmanagedFunctionFromRegion,UnmanagedFunctionFromID,ExecutableMemoryRegion,HeapObject<LoadedClass>,HeapSnapshot> {
+ public class LoadedElementFactory : ILoadedElementFactory<LoadedClass,LoadedMethod,UnmanagedFunctionFromRegion,UnmanagedFunctionFromID,ExecutableMemoryRegion,HeapObject,HeapSnapshot> {
bool recordHeapSnapshots = true;
public bool RecordHeapSnapshots {
get {