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-08-21 14:25:26 +0400
committerMassimiliano Mantione <massi@mono-cvs.ximian.com>2008-08-21 14:25:26 +0400
commit6fcabb91700f6c38b5682d29f92658493b6f531b (patch)
tree174720960542d2d657a4446f128d64f67f446ab7 /Mono.Profiler/profiler-decoder-library
parente0c63420f91e43aed716889388ad0d222320c74c (diff)
Added support for correct accounting of allocations which happened at JIT time.
svn path=/trunk/mono-tools/; revision=111248
Diffstat (limited to 'Mono.Profiler/profiler-decoder-library')
-rw-r--r--Mono.Profiler/profiler-decoder-library/BaseTypes.cs4
-rw-r--r--Mono.Profiler/profiler-decoder-library/ChangeLog7
-rw-r--r--Mono.Profiler/profiler-decoder-library/Decoder.cs14
-rw-r--r--Mono.Profiler/profiler-decoder-library/EventProcessor.cs4
-rw-r--r--Mono.Profiler/profiler-decoder-library/ObjectModel.cs59
5 files changed, 74 insertions, 14 deletions
diff --git a/Mono.Profiler/profiler-decoder-library/BaseTypes.cs b/Mono.Profiler/profiler-decoder-library/BaseTypes.cs
index d183447d..c9c1c72b 100644
--- a/Mono.Profiler/profiler-decoder-library/BaseTypes.cs
+++ b/Mono.Profiler/profiler-decoder-library/BaseTypes.cs
@@ -124,7 +124,7 @@ namespace Mono.Profiler {
void ClassStartUnload (LC c, ulong counter);
void ClassEndUnload (LC c, ulong counter);
- void Allocation (LC c, uint size, LM caller, ulong counter);
+ void Allocation (LC c, uint size, LM caller, bool jitTime, ulong counter);
void Exception (LC c, ulong counter);
void MethodEnter (LM m, ulong counter);
@@ -690,7 +690,7 @@ namespace Mono.Profiler {
public virtual void ClassStartUnload (LC c, ulong counter) {}
public virtual void ClassEndUnload (LC c, ulong counter) {}
- public virtual void Allocation (LC c, uint size, LM caller, ulong counter) {}
+ public virtual void Allocation (LC c, uint size, LM caller, bool jitTime, ulong counter) {}
public virtual void Exception (LC c, ulong counter) {}
public virtual void MethodEnter (LM m, ulong counter) {}
diff --git a/Mono.Profiler/profiler-decoder-library/ChangeLog b/Mono.Profiler/profiler-decoder-library/ChangeLog
index 826cde72..74e35833 100644
--- a/Mono.Profiler/profiler-decoder-library/ChangeLog
+++ b/Mono.Profiler/profiler-decoder-library/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-21 Massimiliano Mantione <massi@ximian.com>
+ * BaseTypes.cs: Added support for correct accounting of allocations
+ which happened at JIT time.
+ * ObjectModel.cs: Likewise.
+ * Decoder.cs: Likewise.
+ * EventProcessor.cs: Likewise.
+
2008-08-20 Massimiliano Mantione <massi@ximian.com>
* BaseTypes.cs: Added support for directives in the log file.
* Decoder.cs: Likewise.
diff --git a/Mono.Profiler/profiler-decoder-library/Decoder.cs b/Mono.Profiler/profiler-decoder-library/Decoder.cs
index 3ac4ca3b..e6111fa7 100644
--- a/Mono.Profiler/profiler-decoder-library/Decoder.cs
+++ b/Mono.Profiler/profiler-decoder-library/Decoder.cs
@@ -248,6 +248,7 @@ namespace Mono.Profiler {
GC_RESIZE = 5,
GC_STOP_WORLD = 6,
GC_START_WORLD = 7,
+ JIT_TIME_ALLOCATION = 8,
MASK = 15
}
GenericEvent GenericEventFromEventCode (int eventCode) {
@@ -448,7 +449,7 @@ namespace Mono.Profiler {
callerId = ReadUint (ref offsetInBlock);
}
//LogLine ("BLOCK EVENTS (PACKED:CLASS_ALLOCATION): classId {0}, classSize {1}, callerId {2}", classId, classSize, callerId);
- handler.Allocation (handler.LoadedElements.GetClass (classId), classSize, (callerId != 0) ? handler.LoadedElements.GetMethod (callerId) : default (LM), 0);
+ handler.Allocation (handler.LoadedElements.GetClass (classId), classSize, (callerId != 0) ? handler.LoadedElements.GetMethod (callerId) : default (LM), false, 0);
break;
}
case PackedEventCode.CLASS_EVENT: {
@@ -648,6 +649,17 @@ namespace Mono.Profiler {
}
break;
}
+ case GenericEvent.JIT_TIME_ALLOCATION: {
+ uint classId = ReadUint (ref offsetInBlock);
+ uint classSize = ReadUint (ref offsetInBlock);
+ uint callerId = 0;
+ if (handler.Directives.AllocationsCarryCallerMethod) {
+ callerId = ReadUint (ref offsetInBlock);
+ }
+ //LogLine ("BLOCK EVENTS (OTHER:JIT_TIME_ALLOCATION): classId {0}, classSize {1}, callerId {2}", classId, classSize, callerId);
+ handler.Allocation (handler.LoadedElements.GetClass (classId), classSize, (callerId != 0) ? handler.LoadedElements.GetMethod (callerId) : default (LM), true, 0);
+ break;
+ }
default: {
throw new DecodingException (this, offsetInBlock, String.Format ("unknown generic event {0}", genericEventCode));
}
diff --git a/Mono.Profiler/profiler-decoder-library/EventProcessor.cs b/Mono.Profiler/profiler-decoder-library/EventProcessor.cs
index f865c005..c3eb08ed 100644
--- a/Mono.Profiler/profiler-decoder-library/EventProcessor.cs
+++ b/Mono.Profiler/profiler-decoder-library/EventProcessor.cs
@@ -207,13 +207,13 @@ namespace Mono.Profiler {
public override void ClassStartUnload (LoadedClass c, ulong counter) {}
public override void ClassEndUnload (LoadedClass c, ulong counter) {}
- public override void Allocation (LoadedClass c, uint size, LoadedMethod caller, ulong counter) {
+ public override void Allocation (LoadedClass c, uint size, LoadedMethod caller, bool jitTime, ulong counter) {
if (caller == null) {
if ((stack != null) && (stack.StackTop != null)) {
caller = stack.StackTop.Method;
}
}
- c.InstanceCreated (size, caller);
+ c.InstanceCreated (size, caller, jitTime);
}
public override void Exception (LoadedClass c, ulong counter) {}
diff --git a/Mono.Profiler/profiler-decoder-library/ObjectModel.cs b/Mono.Profiler/profiler-decoder-library/ObjectModel.cs
index 792710d9..737b5763 100644
--- a/Mono.Profiler/profiler-decoder-library/ObjectModel.cs
+++ b/Mono.Profiler/profiler-decoder-library/ObjectModel.cs
@@ -47,22 +47,31 @@ namespace Mono.Profiler {
return a.AllocatedBytes.CompareTo (b.AllocatedBytes);
};
- internal void InstanceCreated (uint size, LoadedMethod method) {
+ internal void InstanceCreated (uint size, LoadedMethod method, bool jitTime) {
allocatedBytes += size;
currentlyAllocatedBytes += size;
if (method != null) {
- if (allocationsPerMethod == null) {
- allocationsPerMethod = new Dictionary<uint,AllocationsPerMethod> ();
+ Dictionary<uint,AllocationsPerMethod> methods;
+ if (! jitTime) {
+ if (allocationsPerMethod == null) {
+ allocationsPerMethod = new Dictionary<uint,AllocationsPerMethod> ();
+ }
+ methods = allocationsPerMethod;
+ } else {
+ if (allocationsPerMethodAtJitTime == null) {
+ allocationsPerMethodAtJitTime = new Dictionary<uint,AllocationsPerMethod> ();
+ }
+ methods = allocationsPerMethodAtJitTime;
}
AllocationsPerMethod callerMethod;
- if (allocationsPerMethod.ContainsKey (method.ID)) {
- callerMethod = allocationsPerMethod [method.ID];
+ if (methods.ContainsKey (method.ID)) {
+ callerMethod = methods [method.ID];
} else {
callerMethod = new AllocationsPerMethod (method);
- allocationsPerMethod.Add (method.ID, callerMethod);
+ methods.Add (method.ID, callerMethod);
}
- callerMethod.AllocatedBytes += size;
+ callerMethod.Allocation (size);
}
}
@@ -83,13 +92,23 @@ namespace Mono.Profiler {
get {
return allocatedBytes;
}
- internal set {
- allocatedBytes = value;
+ }
+ uint allocatedInstances;
+ public uint AllocatedInstances {
+ get {
+ return allocatedInstances;
}
}
+ internal void Allocation (uint allocatedBytes) {
+ this.allocatedBytes += allocatedBytes;
+ this.allocatedInstances ++;
+ }
public static Comparison<AllocationsPerMethod> CompareByAllocatedBytes = delegate (AllocationsPerMethod a, AllocationsPerMethod b) {
return a.AllocatedBytes.CompareTo (b.AllocatedBytes);
};
+ public static Comparison<AllocationsPerMethod> CompareByAllocatedInstances = delegate (AllocationsPerMethod a, AllocationsPerMethod b) {
+ return a.AllocatedInstances.CompareTo (b.AllocatedInstances);
+ };
public AllocationsPerMethod (LoadedMethod method) {
this.method = method;
@@ -110,6 +129,28 @@ namespace Mono.Profiler {
}
}
+ Dictionary<uint,AllocationsPerMethod> allocationsPerMethodAtJitTime;
+ public AllocationsPerMethod[] MethodsAtJitTime {
+ get {
+ if (allocationsPerMethodAtJitTime != null) {
+ AllocationsPerMethod[] result = new AllocationsPerMethod [allocationsPerMethodAtJitTime.Count];
+ allocationsPerMethodAtJitTime.Values.CopyTo (result, 0);
+ return result;
+ } else {
+ return new AllocationsPerMethod [0];
+ }
+ }
+ }
+ public int MethodsAtJitTimeCount {
+ get {
+ if (allocationsPerMethodAtJitTime != null) {
+ return allocationsPerMethodAtJitTime.Values.Count;
+ } else {
+ return 0;
+ }
+ }
+ }
+
public LoadedClass (uint id, string name, uint size): base (id, name, size) {
allocatedBytes = 0;
currentlyAllocatedBytes = 0;