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

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 2742333007: Add Observatory support for UnlinkedCall, SingleTargetCache and SubtypeTestCache. (Closed)
Patch Set: . Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of service; 5 part of service;
6 6
7 // Some value smaller than the object ring, so requesting a large array 7 // Some value smaller than the object ring, so requesting a large array
8 // doesn't result in an expired ref because the elements lapped it in the 8 // doesn't result in an expired ref because the elements lapped it in the
9 // object ring. 9 // object ring.
10 const int kDefaultFieldLimit = 100; 10 const int kDefaultFieldLimit = 100;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 /// A NetworkRpcException is used to indicate that an rpc has 73 /// A NetworkRpcException is used to indicate that an rpc has
74 /// been canceled due to network error. 74 /// been canceled due to network error.
75 class NetworkRpcException extends RpcException 75 class NetworkRpcException extends RpcException
76 implements M.ConnectionException { 76 implements M.ConnectionException {
77 NetworkRpcException(String message) : super(message); 77 NetworkRpcException(String message) : super(message);
78 78
79 String toString() => 'NetworkRpcException(${message})'; 79 String toString() => 'NetworkRpcException(${message})';
80 } 80 }
81 81
82 Future<ServiceObject> ignoreNetworkErrors( 82 Future<ServiceObject> ignoreNetworkErrors(Object error,
83 Object error, [ServiceObject resultOnNetworkError = null]) { 83 [ServiceObject resultOnNetworkError = null]) {
84 if (error is NetworkRpcException) { 84 if (error is NetworkRpcException) {
85 return new Future.value(resultOnNetworkError); 85 return new Future.value(resultOnNetworkError);
86 } 86 }
87 return new Future.error(error); 87 return new Future.error(error);
88 } 88 }
89 89
90 class MalformedResponseRpcException extends RpcException { 90 class MalformedResponseRpcException extends RpcException {
91 MalformedResponseRpcException(String message, this.response) : super(message); 91 MalformedResponseRpcException(String message, this.response) : super(message);
92 92
93 Map response; 93 Map response;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 break; 254 break;
255 case 'MegamorphicCache': 255 case 'MegamorphicCache':
256 obj = new MegamorphicCache._empty(owner); 256 obj = new MegamorphicCache._empty(owner);
257 break; 257 break;
258 case 'ObjectPool': 258 case 'ObjectPool':
259 obj = new ObjectPool._empty(owner); 259 obj = new ObjectPool._empty(owner);
260 break; 260 break;
261 case 'PcDescriptors': 261 case 'PcDescriptors':
262 obj = new PcDescriptors._empty(owner); 262 obj = new PcDescriptors._empty(owner);
263 break; 263 break;
264 case 'SingleTargetCache':
265 obj = new SingleTargetCache._empty(owner);
266 break;
267 case 'SubtypeTestCache':
268 obj = new SubtypeTestCache._empty(owner);
269 break;
264 case 'TokenStream': 270 case 'TokenStream':
265 obj = new TokenStream._empty(owner); 271 obj = new TokenStream._empty(owner);
266 break; 272 break;
273 case 'UnlinkedCall':
274 obj = new UnlinkedCall._empty(owner);
275 break;
267 } 276 }
268 break; 277 break;
269 case 'Event': 278 case 'Event':
270 obj = new ServiceEvent._empty(owner); 279 obj = new ServiceEvent._empty(owner);
271 break; 280 break;
272 case 'Script': 281 case 'Script':
273 obj = new Script._empty(owner); 282 obj = new Script._empty(owner);
274 break; 283 break;
275 case 'Socket': 284 case 'Socket':
276 obj = new Socket._empty(owner); 285 obj = new Socket._empty(owner);
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 881
873 Future<ServiceObject> getFlagList() { 882 Future<ServiceObject> getFlagList() {
874 return invokeRpc('getFlagList', {}); 883 return invokeRpc('getFlagList', {});
875 } 884 }
876 885
877 Future<ServiceObject> _streamListen(String streamId) { 886 Future<ServiceObject> _streamListen(String streamId) {
878 Map params = { 887 Map params = {
879 'streamId': streamId, 888 'streamId': streamId,
880 }; 889 };
881 // Ignore network errors on stream listen. 890 // Ignore network errors on stream listen.
882 return invokeRpc('streamListen', params).catchError( 891 return invokeRpc('streamListen', params)
883 (e) => ignoreNetworkErrors(e)); 892 .catchError((e) => ignoreNetworkErrors(e));
884 } 893 }
885 894
886 Future<ServiceObject> _streamCancel(String streamId) { 895 Future<ServiceObject> _streamCancel(String streamId) {
887 Map params = { 896 Map params = {
888 'streamId': streamId, 897 'streamId': streamId,
889 }; 898 };
890 // Ignore network errors on stream cancel. 899 // Ignore network errors on stream cancel.
891 return invokeRpc('streamCancel', params).catchError( 900 return invokeRpc('streamCancel', params)
892 (e) => ignoreNetworkErrors(e)); 901 .catchError((e) => ignoreNetworkErrors(e));
893 } 902 }
894 903
895 // A map from stream id to event stream state. 904 // A map from stream id to event stream state.
896 Map<String, _EventStreamState> _eventStreams = {}; 905 Map<String, _EventStreamState> _eventStreams = {};
897 906
898 // Well-known stream ids. 907 // Well-known stream ids.
899 static const kVMStream = 'VM'; 908 static const kVMStream = 'VM';
900 static const kIsolateStream = 'Isolate'; 909 static const kIsolateStream = 'Isolate';
901 static const kTimelineStream = 'Timeline'; 910 static const kTimelineStream = 'Timeline';
902 static const kDebugStream = 'Debug'; 911 static const kDebugStream = 'Debug';
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 } 1351 }
1343 if (startPos != null) { 1352 if (startPos != null) {
1344 params['tokenPos'] = startPos; 1353 params['tokenPos'] = startPos;
1345 } 1354 }
1346 if (endPos != null) { 1355 if (endPos != null) {
1347 params['endTokenPos'] = endPos; 1356 params['endTokenPos'] = endPos;
1348 } 1357 }
1349 return invokeRpc('getSourceReport', params); 1358 return invokeRpc('getSourceReport', params);
1350 } 1359 }
1351 1360
1352 Future<ServiceMap> reloadSources( 1361 Future<ServiceMap> reloadSources({String rootLibUri, bool pause}) {
1353 {String rootLibUri,
1354 bool pause}) {
1355 Map<String, dynamic> params = <String, dynamic>{}; 1362 Map<String, dynamic> params = <String, dynamic>{};
1356 if (rootLibUri != null) { 1363 if (rootLibUri != null) {
1357 params['rootLibUri'] = rootLibUri; 1364 params['rootLibUri'] = rootLibUri;
1358 } 1365 }
1359 if (pause != null) { 1366 if (pause != null) {
1360 params['pause'] = pause; 1367 params['pause'] = pause;
1361 } 1368 }
1362 return invokeRpc('reloadSources', params).then((result) { 1369 return invokeRpc('reloadSources', params).then((result) {
1363 _cache.clear(); 1370 _cache.clear();
1364 return result; 1371 return result;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 _chunksInProgress = null; 1560 _chunksInProgress = null;
1554 1561
1555 if (_snapshotFetch != null) { 1562 if (_snapshotFetch != null) {
1556 _snapshotFetch.add(new RawHeapSnapshot(loadedChunks, event.nodeCount)); 1563 _snapshotFetch.add(new RawHeapSnapshot(loadedChunks, event.nodeCount));
1557 _snapshotFetch.close(); 1564 _snapshotFetch.close();
1558 } 1565 }
1559 } 1566 }
1560 1567
1561 static String _rootsToString(M.HeapSnapshotRoots roots) { 1568 static String _rootsToString(M.HeapSnapshotRoots roots) {
1562 switch (roots) { 1569 switch (roots) {
1563 case M.HeapSnapshotRoots.user: return "User"; 1570 case M.HeapSnapshotRoots.user:
1564 case M.HeapSnapshotRoots.vm: return "VM"; 1571 return "User";
1572 case M.HeapSnapshotRoots.vm:
1573 return "VM";
1565 } 1574 }
1566 return null; 1575 return null;
1567 } 1576 }
1568 1577
1569 Stream fetchHeapSnapshot(M.HeapSnapshotRoots roots, bool collectGarbage) { 1578 Stream fetchHeapSnapshot(M.HeapSnapshotRoots roots, bool collectGarbage) {
1570 if (_snapshotFetch == null || _snapshotFetch.isClosed) { 1579 if (_snapshotFetch == null || _snapshotFetch.isClosed) {
1571 _snapshotFetch = new StreamController.broadcast(); 1580 _snapshotFetch = new StreamController.broadcast();
1572 // isolate.vm.streamListen('_Graph'); 1581 // isolate.vm.streamListen('_Graph');
1573 isolate.invokeRpcNoUpgrade('_requestHeapSnapshot', 1582 isolate.invokeRpcNoUpgrade('_requestHeapSnapshot',
1574 {'roots': _rootsToString(roots), 1583 {'roots': _rootsToString(roots), 'collectGarbage': collectGarbage});
1575 'collectGarbage': collectGarbage});
1576 } 1584 }
1577 return _snapshotFetch.stream; 1585 return _snapshotFetch.stream;
1578 } 1586 }
1579 1587
1580 void updateHeapsFromMap(Map map) { 1588 void updateHeapsFromMap(Map map) {
1581 newSpace.update(map['new']); 1589 newSpace.update(map['new']);
1582 oldSpace.update(map['old']); 1590 oldSpace.update(map['old']);
1583 } 1591 }
1584 1592
1585 void _update(Map map, bool mapIsRef) { 1593 void _update(Map map, bool mapIsRef) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 if (savedStartTime == null) { 1654 if (savedStartTime == null) {
1647 vm._buildIsolateList(); 1655 vm._buildIsolateList();
1648 } 1656 }
1649 1657
1650 extensionRPCs.clear(); 1658 extensionRPCs.clear();
1651 if (map['extensionRPCs'] != null) { 1659 if (map['extensionRPCs'] != null) {
1652 extensionRPCs.addAll(map['extensionRPCs']); 1660 extensionRPCs.addAll(map['extensionRPCs']);
1653 } 1661 }
1654 1662
1655 threads.clear(); 1663 threads.clear();
1656 if(map['_threads'] != null) { 1664 if (map['_threads'] != null) {
1657 threads.addAll(map['_threads']); 1665 threads.addAll(map['_threads']);
1658 } 1666 }
1659 1667
1660 int currentMemoryHighWatermark = 0; 1668 int currentMemoryHighWatermark = 0;
1661 for (var i = 0; i < threads.length; i++) { 1669 for (var i = 0; i < threads.length; i++) {
1662 currentMemoryHighWatermark += threads[i].memoryHighWatermark; 1670 currentMemoryHighWatermark += threads[i].memoryHighWatermark;
1663 } 1671 }
1664 1672
1665 if (currentMemoryHighWatermark > _memoryHighWatermark) { 1673 if (currentMemoryHighWatermark > _memoryHighWatermark) {
1666 _memoryHighWatermark = currentMemoryHighWatermark; 1674 _memoryHighWatermark = currentMemoryHighWatermark;
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 3118
3111 // TODO(bkonyi): zones will always be empty. See issue #28885. 3119 // TODO(bkonyi): zones will always be empty. See issue #28885.
3112 List<Zone> get zones => _zones; 3120 List<Zone> get zones => _zones;
3113 final List<Zone> _zones = new List<Zone>(); 3121 final List<Zone> _zones = new List<Zone>();
3114 3122
3115 Thread._empty(ServiceObjectOwner owner) : super._empty(owner); 3123 Thread._empty(ServiceObjectOwner owner) : super._empty(owner);
3116 3124
3117 void _update(Map map, bool mapIsRef) { 3125 void _update(Map map, bool mapIsRef) {
3118 String rawKind = map['kind']; 3126 String rawKind = map['kind'];
3119 3127
3120 switch(rawKind) { 3128 switch (rawKind) {
3121 case "kUnknownTask": 3129 case "kUnknownTask":
3122 _kind = M.ThreadKind.unknownTask; 3130 _kind = M.ThreadKind.unknownTask;
3123 _kindString = 'unknown'; 3131 _kindString = 'unknown';
3124 break; 3132 break;
3125 case "kMutatorTask": 3133 case "kMutatorTask":
3126 _kind = M.ThreadKind.mutatorTask; 3134 _kind = M.ThreadKind.mutatorTask;
3127 _kindString = 'mutator'; 3135 _kindString = 'mutator';
3128 break; 3136 break;
3129 case "kCompilerTask": 3137 case "kCompilerTask":
3130 _kind = M.ThreadKind.compilerTask; 3138 _kind = M.ThreadKind.compilerTask;
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
3760 class LocalVarDescriptor implements M.LocalVarDescriptorsRef { 3768 class LocalVarDescriptor implements M.LocalVarDescriptorsRef {
3761 final String id; 3769 final String id;
3762 final String name; 3770 final String name;
3763 final int index; 3771 final int index;
3764 final int declarationPos; 3772 final int declarationPos;
3765 final int beginPos; 3773 final int beginPos;
3766 final int endPos; 3774 final int endPos;
3767 final int scopeId; 3775 final int scopeId;
3768 final String kind; 3776 final String kind;
3769 3777
3770 LocalVarDescriptor(this.id, 3778 LocalVarDescriptor(this.id, this.name, this.index, this.declarationPos,
3771 this.name, 3779 this.beginPos, this.endPos, this.scopeId, this.kind);
3772 this.index,
3773 this.declarationPos,
3774 this.beginPos,
3775 this.endPos,
3776 this.scopeId,
3777 this.kind);
3778 } 3780 }
3779 3781
3780 class LocalVarDescriptors extends ServiceObject { 3782 class LocalVarDescriptors extends ServiceObject {
3781 Class clazz; 3783 Class clazz;
3782 int size; 3784 int size;
3783 bool get immutable => true; 3785 bool get immutable => true;
3784 final List<LocalVarDescriptor> descriptors = <LocalVarDescriptor>[]; 3786 final List<LocalVarDescriptor> descriptors = <LocalVarDescriptor>[];
3785 LocalVarDescriptors._empty(ServiceObjectOwner owner) : super._empty(owner); 3787 LocalVarDescriptors._empty(ServiceObjectOwner owner) : super._empty(owner);
3786 3788
3787 void _update(Map m, bool mapIsRef) { 3789 void _update(Map m, bool mapIsRef) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3881 dartOwner = map['_owner']; 3883 dartOwner = map['_owner'];
3882 selector = map['_selector']; 3884 selector = map['_selector'];
3883 if (mapIsRef) { 3885 if (mapIsRef) {
3884 return; 3886 return;
3885 } 3887 }
3886 argumentsDescriptor = map['_argumentsDescriptor']; 3888 argumentsDescriptor = map['_argumentsDescriptor'];
3887 entries = map['_entries']; 3889 entries = map['_entries'];
3888 } 3890 }
3889 } 3891 }
3890 3892
3893 class UnlinkedCall extends HeapObject implements M.UnlinkedCall {
3894 String selector;
3895 Instance argumentsDescriptor;
3896
3897 bool get immutable => false;
3898
3899 UnlinkedCall._empty(ServiceObjectOwner owner) : super._empty(owner);
3900
3901 void _update(Map map, bool mapIsRef) {
3902 _upgradeCollection(map, isolate);
3903 super._update(map, mapIsRef);
3904
3905 selector = map['_selector'];
3906 if (mapIsRef) {
3907 return;
3908 }
3909 argumentsDescriptor = map['_argumentsDescriptor'];
3910 }
3911 }
3912
3913 class SingleTargetCache extends HeapObject implements M.SingleTargetCache {
3914 Code target;
3915 int lowerLimit;
3916 int upperLimit;
3917
3918 bool get immutable => false;
3919
3920 SingleTargetCache._empty(ServiceObjectOwner owner) : super._empty(owner);
3921
3922 void _update(Map map, bool mapIsRef) {
3923 _upgradeCollection(map, isolate);
3924 super._update(map, mapIsRef);
3925
3926 target = map['_target'];
3927 if (mapIsRef) {
3928 return;
3929 }
3930 lowerLimit = map['_lowerLimit'];
3931 upperLimit = map['_upperLimit'];
3932 }
3933 }
3934
3935 class SubtypeTestCache extends HeapObject implements M.SubtypeTestCache {
3936 Instance cache;
3937
3938 bool get immutable => false;
3939
3940 SubtypeTestCache._empty(ServiceObjectOwner owner) : super._empty(owner);
3941
3942 void _update(Map map, bool mapIsRef) {
3943 _upgradeCollection(map, isolate);
3944 super._update(map, mapIsRef);
3945
3946 if (mapIsRef) {
3947 return;
3948 }
3949 cache = map['_cache'];
3950 }
3951 }
3952
3891 class TypeArguments extends HeapObject implements M.TypeArguments { 3953 class TypeArguments extends HeapObject implements M.TypeArguments {
3892 HeapObject dartOwner; 3954 HeapObject dartOwner;
3893 String name; 3955 String name;
3894 Iterable<Instance> types; 3956 Iterable<Instance> types;
3895 3957
3896 TypeArguments._empty(ServiceObjectOwner owner) : super._empty(owner); 3958 TypeArguments._empty(ServiceObjectOwner owner) : super._empty(owner);
3897 3959
3898 void _update(Map map, bool mapIsRef) { 3960 void _update(Map map, bool mapIsRef) {
3899 _upgradeCollection(map, isolate); 3961 _upgradeCollection(map, isolate);
3900 super._update(map, mapIsRef); 3962 super._update(map, mapIsRef);
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
4428 this.location = map['location']; 4490 this.location = map['location'];
4429 this.code = map['code']; 4491 this.code = map['code'];
4430 this.variables = map['vars'] ?? []; 4492 this.variables = map['vars'] ?? [];
4431 } 4493 }
4432 4494
4433 M.FrameKind _fromString(String frameKind) { 4495 M.FrameKind _fromString(String frameKind) {
4434 if (frameKind == null) { 4496 if (frameKind == null) {
4435 return M.FrameKind.regular; 4497 return M.FrameKind.regular;
4436 } 4498 }
4437 switch (frameKind) { 4499 switch (frameKind) {
4438 case 'Regular': return M.FrameKind.regular; 4500 case 'Regular':
4439 case 'AsyncCausal': return M.FrameKind.asyncCausal; 4501 return M.FrameKind.regular;
4440 case 'AsyncSuspensionMarker': return M.FrameKind.asyncSuspensionMarker; 4502 case 'AsyncCausal':
4503 return M.FrameKind.asyncCausal;
4504 case 'AsyncSuspensionMarker':
4505 return M.FrameKind.asyncSuspensionMarker;
4441 default: 4506 default:
4442 throw new UnsupportedError('Unknown FrameKind: $frameKind'); 4507 throw new UnsupportedError('Unknown FrameKind: $frameKind');
4443 } 4508 }
4444 } 4509 }
4445 4510
4446 String toString() { 4511 String toString() {
4447 if (function != null) { 4512 if (function != null) {
4448 return "Frame([$kind] ${function.qualifiedName} $location)"; 4513 return "Frame([$kind] ${function.qualifiedName} $location)";
4449 } else if (location != null) { 4514 } else if (location != null) {
4450 return "Frame([$kind] $location)"; 4515 return "Frame([$kind] $location)";
4451 } else { 4516 } else {
4452 return "Frame([$kind])"; 4517 return "Frame([$kind])";
4453 } 4518 }
4454 } 4519 }
4455 4520
4456 Future<String> toUserString() async { 4521 Future<String> toUserString() async {
4457 if (function != null) { 4522 if (function != null) {
4458 return "Frame([$kind] ${function.qualifiedName} " 4523 return "Frame([$kind] ${function.qualifiedName} "
4459 "${await location.toUserString()})"; 4524 "${await location.toUserString()})";
4460 } else if (location != null) { 4525 } else if (location != null) {
4461 return "Frame([$kind] ${await location.toUserString()}"; 4526 return "Frame([$kind] ${await location.toUserString()}";
4462 } else { 4527 } else {
4463 return "Frame([$kind])"; 4528 return "Frame([$kind])";
4464 } 4529 }
4465 } 4530 }
4466 } 4531 }
4467 4532
4468 class ServiceMessage extends ServiceObject { 4533 class ServiceMessage extends ServiceObject {
4469 int index; 4534 int index;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
4567 var v = list[i]; 4632 var v = list[i];
4568 if ((v is Map) && _isServiceMap(v)) { 4633 if ((v is Map) && _isServiceMap(v)) {
4569 list[i] = owner.getFromMap(v); 4634 list[i] = owner.getFromMap(v);
4570 } else if (v is List) { 4635 } else if (v is List) {
4571 _upgradeList(v, owner); 4636 _upgradeList(v, owner);
4572 } else if (v is Map) { 4637 } else if (v is Map) {
4573 _upgradeMap(v, owner); 4638 _upgradeMap(v, owner);
4574 } 4639 }
4575 } 4640 }
4576 } 4641 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/repositories/unlinked_call.dart ('k') | runtime/observatory/observatory_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698