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

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

Issue 1300853006: Functions are objects too! (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: update tests Created 5 years, 4 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 0426b5d96dc635824505ed2156633436c757d300..396d5d94ee3d404ab45a88dae8e50443569e5762 100644
--- a/runtime/observatory/lib/src/service/object.dart
+++ b/runtime/observatory/lib/src/service/object.dart
@@ -365,6 +365,19 @@ abstract class HeapObject extends ServiceObject {
@observable int retainedSize;
HeapObject._empty(ServiceObjectOwner owner) : super._empty(owner);
+
+ void _update(ObservableMap map, bool mapIsRef) {
+ if (map['class'] != null) {
+ // Sent with refs for some types. Load it if available, but don't clobber
+ // it with null for kinds that only send if for full responses.
+ clazz = map['class'];
+ }
+
+ if (mapIsRef) {
+ return;
+ }
+ size = map['size'];
+ }
}
abstract class Coverage {
@@ -1624,7 +1637,7 @@ class ServiceMap extends ServiceObject implements ObservableMap {
_map.addAll(map);
name = _map['name'];
- vmName = (_map.containsKey('vmName') ? _map['vmName'] : name);
+ vmName = (_map.containsKey('_vmName') ? _map['_vmName'] : name);
}
// TODO(turnidge): These are temporary until we have a proper root
@@ -1909,7 +1922,7 @@ class LibraryDependency {
}
-class Library extends ServiceObject with Coverage {
+class Library extends HeapObject with Coverage {
@observable String uri;
@reflectable final dependencies = new ObservableList<LibraryDependency>();
@reflectable final scripts = new ObservableList<Script>();
@@ -1923,6 +1936,9 @@ class Library extends ServiceObject with Coverage {
Library._empty(ServiceObjectOwner owner) : super._empty(owner);
void _update(ObservableMap map, bool mapIsRef) {
+ _upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
+
uri = map['uri'];
var shortUri = uri;
if (uri.startsWith('file://') ||
@@ -1934,12 +1950,11 @@ class Library extends ServiceObject with Coverage {
// When there is no name for a library, use the shortUri.
name = shortUri;
}
- vmName = (map.containsKey('vmName') ? map['vmName'] : name);
+ vmName = (map.containsKey('_vmName') ? map['_vmName'] : name);
if (mapIsRef) {
return;
}
_loaded = true;
- _upgradeCollection(map, isolate);
dependencies.clear();
dependencies.addAll(map["dependencies"].map(LibraryDependency._fromMap));
scripts.clear();
@@ -2005,7 +2020,7 @@ class Allocations {
bool get empty => accumulated.empty && current.empty;
}
-class Class extends ServiceObject with Coverage {
+class Class extends HeapObject with Coverage {
@observable Library library;
@observable bool isAbstract;
@@ -2038,8 +2053,14 @@ class Class extends ServiceObject with Coverage {
Class._empty(ServiceObjectOwner owner) : super._empty(owner);
void _update(ObservableMap map, bool mapIsRef) {
+ _upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
+
name = map['name'];
- vmName = (map.containsKey('vmName') ? map['vmName'] : name);
+ vmName = (map.containsKey('_vmName') ? map['_vmName'] : name);
+ if (vmName == '::') {
+ name = 'top-level-class'; // Better than ''
+ }
var idPrefix = "classes/";
assert(id.startsWith(idPrefix));
vmCid = int.parse(id.substring(idPrefix.length));
@@ -2132,11 +2153,8 @@ class Class extends ServiceObject with Coverage {
String toString() => 'Class($vmName)';
}
-class Instance extends ServiceObject {
+class Instance extends HeapObject {
@observable String kind;
- @observable Class clazz;
- @observable int size;
- @observable int retainedSize;
@observable String valueAsString; // If primitive.
@observable bool valueAsStringIsTruncated;
@observable ServiceFunction function; // If a closure.
@@ -2203,9 +2221,9 @@ class Instance extends ServiceObject {
void _update(ObservableMap map, bool mapIsRef) {
// Extract full properties.
_upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
kind = map['kind'];
- clazz = map['class'];
valueAsString = map['valueAsString'];
// Coerce absence to false.
valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true;
@@ -2219,8 +2237,6 @@ class Instance extends ServiceObject {
return;
}
- size = map['size'];
-
isCaseSensitive = map['isCaseSensitive'];
isMultiLine = map['isMultiLine'];
oneByteFunction = map['_oneByteFunction'];
@@ -2293,10 +2309,7 @@ class Instance extends ServiceObject {
}
-class Context extends ServiceObject {
- @observable Class clazz;
- @observable int size;
-
+class Context extends HeapObject {
@observable var parentContext;
@observable int length;
@observable var variables;
@@ -2306,6 +2319,7 @@ class Context extends ServiceObject {
void _update(ObservableMap map, bool mapIsRef) {
// Extract full properties.
_upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
length = map['length'];
parentContext = map['parent'];
@@ -2314,8 +2328,6 @@ class Context extends ServiceObject {
return;
}
- size = map['size'];
- clazz = map['class'];
variables = map['variables'];
// We are fully loaded.
@@ -2354,6 +2366,7 @@ class FunctionKind {
case 'Native': return kNative;
case 'Stub': return kStub;
case 'Tag': return kTag;
+ case 'SignatureFunction': return kSignatureFunction;
}
Logger.root.severe('Unrecognized function kind: $value');
throw new FallThroughError();
@@ -2376,10 +2389,11 @@ class FunctionKind {
static FunctionKind kNative = new FunctionKind._internal('Native');
static FunctionKind kTag = new FunctionKind._internal('Tag');
static FunctionKind kStub = new FunctionKind._internal('Stub');
+ static FunctionKind kSignatureFunction = new FunctionKind._internal('SignatureFunction');
static FunctionKind kUNKNOWN = new FunctionKind._internal('UNKNOWN');
}
-class ServiceFunction extends ServiceObject with Coverage {
+class ServiceFunction extends HeapObject with Coverage {
// owner is a Library, Class, or ServiceFunction.
@observable ServiceObject dartOwner;
@observable Library library;
@@ -2404,10 +2418,11 @@ class ServiceFunction extends ServiceObject with Coverage {
ServiceFunction._empty(ServiceObject owner) : super._empty(owner);
void _update(ObservableMap map, bool mapIsRef) {
- name = map['name'];
- vmName = (map.containsKey('vmName') ? map['vmName'] : name);
-
_upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
+
+ name = map['name'];
+ vmName = (map.containsKey('_vmName') ? map['_vmName'] : name);
dartOwner = map['owner'];
kind = FunctionKind.fromJSON(map['_kind']);
@@ -2447,7 +2462,7 @@ class ServiceFunction extends ServiceObject with Coverage {
}
-class Field extends ServiceObject {
+class Field extends HeapObject {
// Library or Class.
@observable ServiceObject dartOwner;
@observable Library library;
@@ -2469,9 +2484,10 @@ class Field extends ServiceObject {
void _update(ObservableMap map, bool mapIsRef) {
// Extract full properties.
_upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
name = map['name'];
- vmName = (map.containsKey('vmName') ? map['vmName'] : name);
+ vmName = (map.containsKey('_vmName') ? map['_vmName'] : name);
dartOwner = map['owner'];
declaredType = map['declaredType'];
isStatic = map['static'];
@@ -2641,7 +2657,7 @@ class LocalVarLocation {
LocalVarLocation(this.line, this.column, this.endColumn);
}
-class Script extends ServiceObject with Coverage {
+class Script extends HeapObject with Coverage {
Set<CallSite> callSites = new Set<CallSite>();
final lines = new ObservableList<ScriptLine>();
final _hits = new Map<int, int>();
@@ -2675,6 +2691,8 @@ class Script extends ServiceObject with Coverage {
void _update(ObservableMap map, bool mapIsRef) {
_upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
+
uri = map['uri'];
kind = map['_kind'];
_shortUri = uri.substring(uri.lastIndexOf('/') + 1);
@@ -3046,15 +3064,15 @@ class ObjectPool extends HeapObject {
ObjectPool._empty(ServiceObjectOwner owner) : super._empty(owner);
- void _update(ObservableMap m, bool mapIsRef) {
- _upgradeCollection(m, isolate);
- clazz = m['class'];
- length = m['length'];
+ void _update(ObservableMap map, bool mapIsRef) {
+ _upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
+
+ length = map['length'];
if (mapIsRef) {
return;
}
- size = m['size'];
- entries = m['_entries'];
+ entries = map['_entries'];
}
}
@@ -3069,17 +3087,17 @@ class ICData extends HeapObject {
ICData._empty(ServiceObjectOwner owner) : super._empty(owner);
- void _update(ObservableMap m, bool mapIsRef) {
- _upgradeCollection(m, isolate);
- clazz = m['class'];
- dartOwner = m['_owner'];
- selector = m['_selector'];
+ void _update(ObservableMap map, bool mapIsRef) {
+ _upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
+
+ dartOwner = map['_owner'];
+ selector = map['_selector'];
if (mapIsRef) {
return;
}
- size = m['size'];
- argumentsDescriptor = m['_argumentsDescriptor'];
- entries = m['_entries'];
+ argumentsDescriptor = map['_argumentsDescriptor'];
+ entries = map['_entries'];
}
}
@@ -3092,15 +3110,15 @@ class Instructions extends HeapObject {
Instructions._empty(ServiceObjectOwner owner) : super._empty(owner);
- void _update(ObservableMap m, bool mapIsRef) {
- _upgradeCollection(m, isolate);
- clazz = m['class'];
- code = m['_code'];
+ void _update(ObservableMap map, bool mapIsRef) {
+ _upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
+
+ code = map['_code'];
if (mapIsRef) {
return;
}
- size = m['size'];
- objectPool = m['_objectPool'];
+ objectPool = map['_objectPool'];
}
}
@@ -3112,14 +3130,14 @@ class TokenStream extends HeapObject {
TokenStream._empty(ServiceObjectOwner owner) : super._empty(owner);
- void _update(ObservableMap m, bool mapIsRef) {
+ void _update(ObservableMap map, bool mapIsRef) {
+ _upgradeCollection(map, isolate);
+ super._update(map, mapIsRef);
+
if (mapIsRef) {
return;
}
- _upgradeCollection(m, isolate);
- clazz = m['class'];
- size = m['size'];
- privateKey = m['privateKey'];
+ privateKey = map['privateKey'];
}
}
@@ -3290,14 +3308,13 @@ class Code extends HeapObject {
void _update(ObservableMap m, bool mapIsRef) {
name = m['name'];
- vmName = (m.containsKey('vmName') ? m['vmName'] : name);
+ vmName = (m.containsKey('_vmName') ? m['_vmName'] : name);
isOptimized = m['_optimized'];
kind = CodeKind.fromString(m['kind']);
if (mapIsRef) {
return;
}
_loaded = true;
- size = m['size'];
startAddress = int.parse(m['_startAddress'], radix:16);
endAddress = int.parse(m['_endAddress'], radix:16);
function = isolate.getFromMap(m['function']);
@@ -3332,6 +3349,9 @@ class Code extends HeapObject {
return;
}
_processInline(inlinedFunctionsTable, inlinedIntervals);
+
+ _upgradeCollection(m, isolate);
+ super._update(m, mapIsRef);
}
CodeInlineInterval findInterval(int pc) {
« no previous file with comments | « runtime/observatory/lib/src/elements/script_view.html ('k') | runtime/observatory/tests/service/inbound_references_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698