Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Unified Diff: runtime/observatory/lib/src/service/object.dart

Issue 977283002: Display call site data for functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/service/object.dart
diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart
index 925e0e75eba7d5cfaaadc88d4d4a2ee261ccb130..2e67a5979831ae569c400a22128cac48d9320672 100644
--- a/runtime/observatory/lib/src/service/object.dart
+++ b/runtime/observatory/lib/src/service/object.dart
@@ -1913,6 +1913,31 @@ class ServiceFunction extends ServiceObject with Coverage {
deoptimizations = map['deoptimizations'];
usageCounter = map['usageCounter'];
}
+
+ // TODO(rmacnak): Generalize and move to Coverage.
+ void processCallSiteData(List callSiteMaps) {
+ var callSites = new List();
+ for (var callSiteMap in callSiteMaps) {
+ callSites.add(new CallSite.fromMap(callSiteMap));
+ }
+ script._processCallSites(callSites);
+ }
+
+ Future refreshCallSiteData() {
+ Map params = {};
+ if (this is! Isolate) {
+ params['targetId'] = id;
+ }
+ return isolate.invokeRpcNoUpgrade('getCallSiteData', params).then(
+ (ObservableMap map) {
+ var data = new ServiceObject._fromMap(isolate, map);
+ assert(data.type == '_CallSiteData');
+ var callSites = data['callSites'];
+ assert(callSites != null);
+ processCallSiteData(callSites);
+ return this;
+ });
+ }
}
@@ -2026,7 +2051,49 @@ class ScriptLine extends Observable {
}
}
+class CallSite {
+ final String name;
+ final int line;
+ final int column;
Cutch 2015/03/09 18:22:42 Can we store tokenPos and script instead?
rmacnak 2015/03/09 23:16:02 Done.
+ final List<CallSiteEntry> entries;
+
+ CallSite(this.name, this.line, this.column, this.entries);
+
+ factory CallSite.fromMap(Map siteMap) {
+ var name = siteMap['name'];
+ var line = siteMap['line'];
+ var column = siteMap['column'];
+ var entries = new List<CallSiteEntry>();
+ for (var entryMap in siteMap['cacheEntries']) {
+ entries.add(new CallSiteEntry.fromMap(entryMap));
+ }
+ return new CallSite(name, line, column, entries);
+ }
+
+ operator ==(other) {
+ return line == other.line && column == other.column;
+ }
+ int get hashCode => (line << 8) | column;
+
+ String toString() => "CallSite($name, $line:$column)";
+}
+
+class CallSiteEntry {
Cutch 2015/03/09 18:22:42 Maybe rename to InstanceCall? abstract class Call
+ final Class receiverClass;
+ final int count;
+
+ CallSiteEntry(this.receiverClass, this.count);
+
+ factory CallSiteEntry.fromMap(Map entryMap) {
+ return new CallSiteEntry(entryMap['receiverClass'],
+ entryMap['count']);
+ }
+
+ String toString() => "CallSiteEntry(${receiverClass.name}, $count)";
+}
+
class Script extends ServiceObject with Coverage {
+ Set callSites = new Set();
final lines = new ObservableList<ScriptLine>();
final _hits = new Map<int, int>();
@observable String kind;
@@ -2111,6 +2178,15 @@ class Script extends ServiceObject with Coverage {
}
}
+ void _processCallSites(List newCallSites) {
+ var mergedCallSites = new Set();
+ mergedCallSites.addAll(newCallSites);
+ mergedCallSites.addAll(callSites);
+ callSites = mergedCallSites;
+ // Notify any Observers that this Script's state has changed.
+ notifyChange(null);
+ }
+
void _processHits(List scriptHits) {
// Update hits table.
for (var i = 0; i < scriptHits.length; i += 2) {

Powered by Google App Engine
This is Rietveld 408576698