| OLD | NEW |
| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 String toString() => 'MalformedResponseRpcException(${message})'; | 86 String toString() => 'MalformedResponseRpcException(${message})'; |
| 87 } | 87 } |
| 88 | 88 |
| 89 class FakeVMRpcException extends RpcException { | 89 class FakeVMRpcException extends RpcException { |
| 90 FakeVMRpcException(String message) : super(message); | 90 FakeVMRpcException(String message) : super(message); |
| 91 | 91 |
| 92 String toString() => 'FakeVMRpcException(${message})'; | 92 String toString() => 'FakeVMRpcException(${message})'; |
| 93 } | 93 } |
| 94 | 94 |
| 95 /// A [ServiceObject] represents a persistent object within the vm. | 95 /// A [ServiceObject] represents a persistent object within the vm. |
| 96 abstract class ServiceObject extends Observable { | 96 abstract class ServiceObject { |
| 97 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { | 97 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { |
| 98 return o1.name.compareTo(o2.name); | 98 return o1.name.compareTo(o2.name); |
| 99 } | 99 } |
| 100 | 100 |
| 101 List removeDuplicatesAndSortLexical(List<ServiceObject> list) { | 101 List removeDuplicatesAndSortLexical(List<ServiceObject> list) { |
| 102 return list.toSet().toList()..sort(LexicalSortName); | 102 return list.toSet().toList()..sort(LexicalSortName); |
| 103 } | 103 } |
| 104 | 104 |
| 105 /// The owner of this [ServiceObject]. This can be an [Isolate], a | 105 /// The owner of this [ServiceObject]. This can be an [Isolate], a |
| 106 /// [VM], or null. | 106 /// [VM], or null. |
| 107 @reflectable ServiceObjectOwner get owner => _owner; | 107 ServiceObjectOwner get owner => _owner; |
| 108 ServiceObjectOwner _owner; | 108 ServiceObjectOwner _owner; |
| 109 | 109 |
| 110 /// The [VM] which owns this [ServiceObject]. | 110 /// The [VM] which owns this [ServiceObject]. |
| 111 @reflectable VM get vm => _owner.vm; | 111 VM get vm => _owner.vm; |
| 112 | 112 |
| 113 /// The [Isolate] which owns this [ServiceObject]. May be null. | 113 /// The [Isolate] which owns this [ServiceObject]. May be null. |
| 114 @reflectable Isolate get isolate => _owner.isolate; | 114 Isolate get isolate => _owner.isolate; |
| 115 | 115 |
| 116 /// The id of this object. | 116 /// The id of this object. |
| 117 @reflectable String get id => _id; | 117 String get id => _id; |
| 118 String _id; | 118 String _id; |
| 119 | 119 |
| 120 /// The user-level type of this object. | 120 /// The user-level type of this object. |
| 121 @reflectable String get type => _type; | 121 String get type => _type; |
| 122 String _type; | 122 String _type; |
| 123 | 123 |
| 124 /// The vm type of this object. | 124 /// The vm type of this object. |
| 125 @reflectable String get vmType => _vmType; | 125 String get vmType => _vmType; |
| 126 String _vmType; | 126 String _vmType; |
| 127 | 127 |
| 128 bool get isICData => vmType == 'ICData'; | 128 bool get isICData => vmType == 'ICData'; |
| 129 bool get isMegamorphicCache => vmType == 'MegamorphicCache'; | 129 bool get isMegamorphicCache => vmType == 'MegamorphicCache'; |
| 130 bool get isInstructions => vmType == 'Instructions'; | 130 bool get isInstructions => vmType == 'Instructions'; |
| 131 bool get isObjectPool => vmType == 'ObjectPool'; | 131 bool get isObjectPool => vmType == 'ObjectPool'; |
| 132 bool get isContext => type == 'Context'; | 132 bool get isContext => type == 'Context'; |
| 133 bool get isError => type == 'Error'; | 133 bool get isError => type == 'Error'; |
| 134 bool get isInstance => type == 'Instance'; | 134 bool get isInstance => type == 'Instance'; |
| 135 bool get isSentinel => type == 'Sentinel'; | 135 bool get isSentinel => type == 'Sentinel'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 160 // from Isolate. | 160 // from Isolate. |
| 161 | 161 |
| 162 /// Is this object cacheable? That is, is it impossible for the [id] | 162 /// Is this object cacheable? That is, is it impossible for the [id] |
| 163 /// of this object to change? | 163 /// of this object to change? |
| 164 bool _canCache; | 164 bool _canCache; |
| 165 bool get canCache => _canCache; | 165 bool get canCache => _canCache; |
| 166 | 166 |
| 167 /// Is this object immutable after it is [loaded]? | 167 /// Is this object immutable after it is [loaded]? |
| 168 bool get immutable => false; | 168 bool get immutable => false; |
| 169 | 169 |
| 170 @observable String name; | 170 String name; |
| 171 @observable String vmName; | 171 String vmName; |
| 172 | 172 |
| 173 /// Creates an empty [ServiceObject]. | 173 /// Creates an empty [ServiceObject]. |
| 174 ServiceObject._empty(this._owner); | 174 ServiceObject._empty(this._owner); |
| 175 | 175 |
| 176 /// Creates a [ServiceObject] initialized from [map]. | 176 /// Creates a [ServiceObject] initialized from [map]. |
| 177 factory ServiceObject._fromMap(ServiceObjectOwner owner, | 177 factory ServiceObject._fromMap(ServiceObjectOwner owner, |
| 178 ObservableMap map) { | 178 Map map) { |
| 179 if (map == null) { | 179 if (map == null) { |
| 180 return null; | 180 return null; |
| 181 } | 181 } |
| 182 if (!_isServiceMap(map)) { | 182 if (!_isServiceMap(map)) { |
| 183 Logger.root.severe('Malformed service object: $map'); | 183 Logger.root.severe('Malformed service object: $map'); |
| 184 } | 184 } |
| 185 assert(_isServiceMap(map)); | 185 assert(_isServiceMap(map)); |
| 186 var type = _stripRef(map['type']); | 186 var type = _stripRef(map['type']); |
| 187 var vmType = map['_vmType'] != null ? map['_vmType'] : type; | 187 var vmType = map['_vmType'] != null ? map['_vmType'] : type; |
| 188 var obj = null; | 188 var obj = null; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 Future<ServiceObject> load() { | 291 Future<ServiceObject> load() { |
| 292 if (loaded) { | 292 if (loaded) { |
| 293 return new Future.value(this); | 293 return new Future.value(this); |
| 294 } | 294 } |
| 295 // Call reload which will fill in the entire object. | 295 // Call reload which will fill in the entire object. |
| 296 return reload(); | 296 return reload(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 Future<ServiceObject> _inProgressReload; | 299 Future<ServiceObject> _inProgressReload; |
| 300 | 300 |
| 301 Future<ObservableMap> _fetchDirect({int count: kDefaultFieldLimit}) { | 301 Future<Map> _fetchDirect({int count: kDefaultFieldLimit}) { |
| 302 Map params = { | 302 Map params = { |
| 303 'objectId': id, | 303 'objectId': id, |
| 304 'count': count, | 304 'count': count, |
| 305 }; | 305 }; |
| 306 return isolate.invokeRpcNoUpgrade('getObject', params); | 306 return isolate.invokeRpcNoUpgrade('getObject', params); |
| 307 } | 307 } |
| 308 | 308 |
| 309 /// Reload [this]. Returns a future which completes to [this] or | 309 /// Reload [this]. Returns a future which completes to [this] or |
| 310 /// an exception. | 310 /// an exception. |
| 311 Future<ServiceObject> reload({int count: kDefaultFieldLimit}) { | 311 Future<ServiceObject> reload({int count: kDefaultFieldLimit}) { |
| 312 // TODO(turnidge): Checking for a null id should be part of the | 312 // TODO(turnidge): Checking for a null id should be part of the |
| 313 // "immmutable" check. | 313 // "immmutable" check. |
| 314 bool hasId = (id != null) && (id != ''); | 314 bool hasId = (id != null) && (id != ''); |
| 315 bool isVM = this is VM; | 315 bool isVM = this is VM; |
| 316 // We should always reload the VM. | 316 // We should always reload the VM. |
| 317 // We can't reload objects without an id. | 317 // We can't reload objects without an id. |
| 318 // We shouldn't reload an immutable and already loaded object. | 318 // We shouldn't reload an immutable and already loaded object. |
| 319 bool skipLoad = !isVM && (!hasId || (immutable && loaded)); | 319 bool skipLoad = !isVM && (!hasId || (immutable && loaded)); |
| 320 if (skipLoad) { | 320 if (skipLoad) { |
| 321 return new Future.value(this); | 321 return new Future.value(this); |
| 322 } | 322 } |
| 323 if (_inProgressReload == null) { | 323 if (_inProgressReload == null) { |
| 324 var completer = new Completer<ServiceObject>(); | 324 var completer = new Completer<ServiceObject>(); |
| 325 _inProgressReload = completer.future; | 325 _inProgressReload = completer.future; |
| 326 _fetchDirect(count: count).then((ObservableMap map) { | 326 _fetchDirect(count: count).then((Map map) { |
| 327 var mapType = _stripRef(map['type']); | 327 var mapType = _stripRef(map['type']); |
| 328 if (mapType == 'Sentinel') { | 328 if (mapType == 'Sentinel') { |
| 329 // An object may have been collected, etc. | 329 // An object may have been collected, etc. |
| 330 completer.complete(new ServiceObject._fromMap(owner, map)); | 330 completer.complete(new ServiceObject._fromMap(owner, map)); |
| 331 } else { | 331 } else { |
| 332 // TODO(turnidge): Check for vmType changing as well? | 332 // TODO(turnidge): Check for vmType changing as well? |
| 333 assert(mapType == _type); | 333 assert(mapType == _type); |
| 334 update(map); | 334 update(map); |
| 335 completer.complete(this); | 335 completer.complete(this); |
| 336 } | 336 } |
| 337 | 337 |
| 338 }).catchError((e, st) { | 338 }).catchError((e, st) { |
| 339 Logger.root.severe("Unable to reload object: $e\n$st"); | 339 Logger.root.severe("Unable to reload object: $e\n$st"); |
| 340 _inProgressReload = null; | 340 _inProgressReload = null; |
| 341 completer.completeError(e, st); | 341 completer.completeError(e, st); |
| 342 }).whenComplete(() { | 342 }).whenComplete(() { |
| 343 // This reload is complete. | 343 // This reload is complete. |
| 344 _inProgressReload = null; | 344 _inProgressReload = null; |
| 345 }); | 345 }); |
| 346 } | 346 } |
| 347 return _inProgressReload; | 347 return _inProgressReload; |
| 348 } | 348 } |
| 349 | 349 |
| 350 /// Update [this] using [map] as a source. [map] can be a reference. | 350 /// Update [this] using [map] as a source. [map] can be a reference. |
| 351 void update(ObservableMap map) { | 351 void update(Map map) { |
| 352 assert(_isServiceMap(map)); | 352 assert(_isServiceMap(map)); |
| 353 | 353 |
| 354 // Don't allow the type to change on an object update. | 354 // Don't allow the type to change on an object update. |
| 355 var mapIsRef = _hasRef(map['type']); | 355 var mapIsRef = _hasRef(map['type']); |
| 356 var mapType = _stripRef(map['type']); | 356 var mapType = _stripRef(map['type']); |
| 357 assert(_type == null || _type == mapType); | 357 assert(_type == null || _type == mapType); |
| 358 | 358 |
| 359 _canCache = map['fixedId'] == true; | 359 _canCache = map['fixedId'] == true; |
| 360 if (_id != null && _id != map['id']) { | 360 if (_id != null && _id != map['id']) { |
| 361 // It is only safe to change an id when the object isn't cacheable. | 361 // It is only safe to change an id when the object isn't cacheable. |
| 362 assert(!canCache); | 362 assert(!canCache); |
| 363 } | 363 } |
| 364 _id = map['id']; | 364 _id = map['id']; |
| 365 | 365 |
| 366 _type = mapType; | 366 _type = mapType; |
| 367 | 367 |
| 368 // When the response specifies a specific vmType, use it. | 368 // When the response specifies a specific vmType, use it. |
| 369 // Otherwise the vmType of the response is the same as the 'user' | 369 // Otherwise the vmType of the response is the same as the 'user' |
| 370 // type. | 370 // type. |
| 371 if (map.containsKey('_vmType')) { | 371 if (map.containsKey('_vmType')) { |
| 372 _vmType = _stripRef(map['_vmType']); | 372 _vmType = _stripRef(map['_vmType']); |
| 373 } else { | 373 } else { |
| 374 _vmType = _type; | 374 _vmType = _type; |
| 375 } | 375 } |
| 376 | 376 |
| 377 _update(map, mapIsRef); | 377 _update(map, mapIsRef); |
| 378 } | 378 } |
| 379 | 379 |
| 380 // Updates internal state from [map]. [map] can be a reference. | 380 // Updates internal state from [map]. [map] can be a reference. |
| 381 void _update(ObservableMap map, bool mapIsRef); | 381 void _update(Map map, bool mapIsRef); |
| 382 | 382 |
| 383 // Helper that can be passed to .catchError that ignores the error. | 383 // Helper that can be passed to .catchError that ignores the error. |
| 384 _ignoreError(error, stackTrace) { | 384 _ignoreError(error, stackTrace) { |
| 385 // do nothing. | 385 // do nothing. |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 | 388 |
| 389 abstract class HeapObject extends ServiceObject implements M.Object { | 389 abstract class HeapObject extends ServiceObject implements M.Object { |
| 390 @observable Class clazz; | 390 Class clazz; |
| 391 @observable int size; | 391 int size; |
| 392 @observable int retainedSize; | 392 int retainedSize; |
| 393 | 393 |
| 394 HeapObject._empty(ServiceObjectOwner owner) : super._empty(owner); | 394 HeapObject._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 395 | 395 |
| 396 void _update(ObservableMap map, bool mapIsRef) { | 396 void _update(Map map, bool mapIsRef) { |
| 397 if (map['class'] != null) { | 397 if (map['class'] != null) { |
| 398 // Sent with refs for some types. Load it if available, but don't clobber | 398 // Sent with refs for some types. Load it if available, but don't clobber |
| 399 // it with null for kinds that only send if for full responses. | 399 // it with null for kinds that only send if for full responses. |
| 400 clazz = map['class']; | 400 clazz = map['class']; |
| 401 } | 401 } |
| 402 | 402 |
| 403 // Load the full class object if the isolate is runnable. | 403 // Load the full class object if the isolate is runnable. |
| 404 if (clazz != null) { | 404 if (clazz != null) { |
| 405 if (clazz.isolate.runnable) { | 405 if (clazz.isolate.runnable) { |
| 406 clazz.load(); | 406 clazz.load(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 420 RetainingObject(this.object); | 420 RetainingObject(this.object); |
| 421 } | 421 } |
| 422 | 422 |
| 423 abstract class ServiceObjectOwner extends ServiceObject { | 423 abstract class ServiceObjectOwner extends ServiceObject { |
| 424 /// Creates an empty [ServiceObjectOwner]. | 424 /// Creates an empty [ServiceObjectOwner]. |
| 425 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner); | 425 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 426 | 426 |
| 427 /// Builds a [ServiceObject] corresponding to the [id] from [map]. | 427 /// Builds a [ServiceObject] corresponding to the [id] from [map]. |
| 428 /// The result may come from the cache. The result will not necessarily | 428 /// The result may come from the cache. The result will not necessarily |
| 429 /// be [loaded]. | 429 /// be [loaded]. |
| 430 ServiceObject getFromMap(ObservableMap map); | 430 ServiceObject getFromMap(Map map); |
| 431 } | 431 } |
| 432 | 432 |
| 433 abstract class Location implements M.Location { | 433 abstract class Location implements M.Location { |
| 434 Script get script; | 434 Script get script; |
| 435 int get tokenPos; | 435 int get tokenPos; |
| 436 } | 436 } |
| 437 | 437 |
| 438 /// A [SourceLocation] represents a location or range in the source code. | 438 /// A [SourceLocation] represents a location or range in the source code. |
| 439 class SourceLocation extends ServiceObject implements Location, | 439 class SourceLocation extends ServiceObject implements Location, |
| 440 M.SourceLocation { | 440 M.SourceLocation { |
| 441 Script script; | 441 Script script; |
| 442 int tokenPos; | 442 int tokenPos; |
| 443 int endTokenPos; | 443 int endTokenPos; |
| 444 | 444 |
| 445 Future<int> getLine() async { | 445 Future<int> getLine() async { |
| 446 await script.load(); | 446 await script.load(); |
| 447 return script.tokenToLine(tokenPos); | 447 return script.tokenToLine(tokenPos); |
| 448 } | 448 } |
| 449 | 449 |
| 450 Future<int> getColumn() async { | 450 Future<int> getColumn() async { |
| 451 await script.load(); | 451 await script.load(); |
| 452 return script.tokenToCol(tokenPos); | 452 return script.tokenToCol(tokenPos); |
| 453 } | 453 } |
| 454 | 454 |
| 455 SourceLocation._empty(ServiceObject owner) : super._empty(owner); | 455 SourceLocation._empty(ServiceObject owner) : super._empty(owner); |
| 456 | 456 |
| 457 void _update(ObservableMap map, bool mapIsRef) { | 457 void _update(Map map, bool mapIsRef) { |
| 458 assert(!mapIsRef); | 458 assert(!mapIsRef); |
| 459 _upgradeCollection(map, owner); | 459 _upgradeCollection(map, owner); |
| 460 script = map['script']; | 460 script = map['script']; |
| 461 tokenPos = map['tokenPos']; | 461 tokenPos = map['tokenPos']; |
| 462 endTokenPos = map['endTokenPos']; | 462 endTokenPos = map['endTokenPos']; |
| 463 | 463 |
| 464 assert(script != null && tokenPos != null); | 464 assert(script != null && tokenPos != null); |
| 465 } | 465 } |
| 466 | 466 |
| 467 Future<String> toUserString() async { | 467 Future<String> toUserString() async { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 if (tokenPos != null) { | 503 if (tokenPos != null) { |
| 504 await script.load(); | 504 await script.load(); |
| 505 return script.tokenToCol(tokenPos); | 505 return script.tokenToCol(tokenPos); |
| 506 } else { | 506 } else { |
| 507 return column; | 507 return column; |
| 508 } | 508 } |
| 509 } | 509 } |
| 510 | 510 |
| 511 UnresolvedSourceLocation._empty(ServiceObject owner) : super._empty(owner); | 511 UnresolvedSourceLocation._empty(ServiceObject owner) : super._empty(owner); |
| 512 | 512 |
| 513 void _update(ObservableMap map, bool mapIsRef) { | 513 void _update(Map map, bool mapIsRef) { |
| 514 assert(!mapIsRef); | 514 assert(!mapIsRef); |
| 515 _upgradeCollection(map, owner); | 515 _upgradeCollection(map, owner); |
| 516 script = map['script']; | 516 script = map['script']; |
| 517 scriptUri = map['scriptUri']; | 517 scriptUri = map['scriptUri']; |
| 518 line = map['line']; | 518 line = map['line']; |
| 519 column = map['column']; | 519 column = map['column']; |
| 520 tokenPos = map['tokenPos']; | 520 tokenPos = map['tokenPos']; |
| 521 | 521 |
| 522 assert(script != null || scriptUri != null); | 522 assert(script != null || scriptUri != null); |
| 523 assert(line != null || tokenPos != null); | 523 assert(line != null || tokenPos != null); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 612 |
| 613 void addEvent(ServiceEvent event) { | 613 void addEvent(ServiceEvent event) { |
| 614 for (var controller in _controllers) { | 614 for (var controller in _controllers) { |
| 615 controller.add(event); | 615 controller.add(event); |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 } | 618 } |
| 619 | 619 |
| 620 /// State for a VM being inspected. | 620 /// State for a VM being inspected. |
| 621 abstract class VM extends ServiceObjectOwner implements M.VM { | 621 abstract class VM extends ServiceObjectOwner implements M.VM { |
| 622 @reflectable VM get vm => this; | 622 VM get vm => this; |
| 623 @reflectable Isolate get isolate => null; | 623 Isolate get isolate => null; |
| 624 | 624 |
| 625 // TODO(turnidge): The connection should not be stored in the VM object. | 625 // TODO(turnidge): The connection should not be stored in the VM object. |
| 626 bool get isDisconnected; | 626 bool get isDisconnected; |
| 627 | 627 |
| 628 // Used for verbose logging. | 628 // Used for verbose logging. |
| 629 bool verbose = false; | 629 bool verbose = false; |
| 630 | 630 |
| 631 // TODO(johnmccutchan): Ensure that isolates do not end up in _cache. | 631 // TODO(johnmccutchan): Ensure that isolates do not end up in _cache. |
| 632 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>(); | 632 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>(); |
| 633 final ObservableMap<String,Isolate> _isolateCache = | 633 final Map<String,Isolate> _isolateCache = <String,Isolate>{}; |
| 634 new ObservableMap<String,Isolate>(); | |
| 635 | 634 |
| 636 // The list of live isolates, ordered by isolate start time. | 635 // The list of live isolates, ordered by isolate start time. |
| 637 final ObservableList<Isolate> isolates = new ObservableList<Isolate>(); | 636 final List<Isolate> isolates = <Isolate>[]; |
| 638 | 637 |
| 639 @observable String version = 'unknown'; | 638 String version = 'unknown'; |
| 640 @observable String hostCPU; | 639 String hostCPU; |
| 641 @observable String targetCPU; | 640 String targetCPU; |
| 642 @observable int architectureBits; | 641 int architectureBits; |
| 643 @observable bool assertsEnabled = false; | 642 bool assertsEnabled = false; |
| 644 @observable bool typeChecksEnabled = false; | 643 bool typeChecksEnabled = false; |
| 645 @observable int pid = 0; | 644 int pid = 0; |
| 646 @observable int maxRSS = 0; | 645 int maxRSS = 0; |
| 647 @observable bool profileVM = false; | 646 bool profileVM = false; |
| 648 @observable DateTime startTime; | 647 DateTime startTime; |
| 649 @observable DateTime refreshTime; | 648 DateTime refreshTime; |
| 650 @observable Duration get upTime { | 649 Duration get upTime { |
| 651 if (startTime == null) { | 650 if (startTime == null) { |
| 652 return null; | 651 return null; |
| 653 } | 652 } |
| 654 return (new DateTime.now().difference(startTime)); | 653 return (new DateTime.now().difference(startTime)); |
| 655 } | 654 } |
| 656 | 655 |
| 657 VM() : super._empty(null) { | 656 VM() : super._empty(null) { |
| 658 update(toObservable({'name':'vm', 'type':'@VM'})); | 657 update({'name':'vm', 'type':'@VM'}); |
| 659 } | 658 } |
| 660 | 659 |
| 661 void postServiceEvent(String streamId, Map response, ByteData data) { | 660 void postServiceEvent(String streamId, Map response, ByteData data) { |
| 662 var map = toObservable(response); | 661 var map = response; |
| 663 assert(!map.containsKey('_data')); | 662 assert(!map.containsKey('_data')); |
| 664 if (data != null) { | 663 if (data != null) { |
| 665 map['_data'] = data; | 664 map['_data'] = data; |
| 666 } | 665 } |
| 667 if (map['type'] != 'Event') { | 666 if (map['type'] != 'Event') { |
| 668 Logger.root.severe( | 667 Logger.root.severe( |
| 669 "Expected 'Event' but found '${map['type']}'"); | 668 "Expected 'Event' but found '${map['type']}'"); |
| 670 return; | 669 return; |
| 671 } | 670 } |
| 672 | 671 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 if (!newIsolateSet.contains(id)) { | 729 if (!newIsolateSet.contains(id)) { |
| 731 toRemove.add(id); | 730 toRemove.add(id); |
| 732 } | 731 } |
| 733 }); | 732 }); |
| 734 toRemove.forEach((id) => _isolateCache.remove(id)); | 733 toRemove.forEach((id) => _isolateCache.remove(id)); |
| 735 _buildIsolateList(); | 734 _buildIsolateList(); |
| 736 } | 735 } |
| 737 | 736 |
| 738 static final String _isolateIdPrefix = 'isolates/'; | 737 static final String _isolateIdPrefix = 'isolates/'; |
| 739 | 738 |
| 740 ServiceObject getFromMap(ObservableMap map) { | 739 ServiceObject getFromMap(Map map) { |
| 741 if (map == null) { | 740 if (map == null) { |
| 742 return null; | 741 return null; |
| 743 } | 742 } |
| 744 var type = _stripRef(map['type']); | 743 var type = _stripRef(map['type']); |
| 745 if (type == 'VM') { | 744 if (type == 'VM') { |
| 746 // Update this VM object. | 745 // Update this VM object. |
| 747 update(map); | 746 update(map); |
| 748 return this; | 747 return this; |
| 749 } | 748 } |
| 750 | 749 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 779 if (!loaded) { | 778 if (!loaded) { |
| 780 // Trigger a VM load, then get the isolate. | 779 // Trigger a VM load, then get the isolate. |
| 781 return load().then((_) => getIsolate(isolateId)).catchError(_ignoreError); | 780 return load().then((_) => getIsolate(isolateId)).catchError(_ignoreError); |
| 782 } | 781 } |
| 783 return new Future.value(_isolateCache[isolateId]); | 782 return new Future.value(_isolateCache[isolateId]); |
| 784 } | 783 } |
| 785 | 784 |
| 786 // Implemented in subclass. | 785 // Implemented in subclass. |
| 787 Future<Map> invokeRpcRaw(String method, Map params); | 786 Future<Map> invokeRpcRaw(String method, Map params); |
| 788 | 787 |
| 789 Future<ObservableMap> invokeRpcNoUpgrade(String method, Map params) { | 788 Future<Map> invokeRpcNoUpgrade(String method, Map params) { |
| 790 return invokeRpcRaw(method, params).then((Map response) { | 789 return invokeRpcRaw(method, params).then((Map response) { |
| 791 var map = toObservable(response); | 790 var map = response; |
| 792 if (Tracer.current != null) { | 791 if (Tracer.current != null) { |
| 793 Tracer.current.trace("Received response for ${method}/${params}}", | 792 Tracer.current.trace("Received response for ${method}/${params}}", |
| 794 map:map); | 793 map:map); |
| 795 } | 794 } |
| 796 if (!_isServiceMap(map)) { | 795 if (!_isServiceMap(map)) { |
| 797 var exception = | 796 var exception = |
| 798 new MalformedResponseRpcException( | 797 new MalformedResponseRpcException( |
| 799 "Response is missing the 'type' field", map); | 798 "Response is missing the 'type' field", map); |
| 800 return new Future.error(exception); | 799 return new Future.error(exception); |
| 801 } | 800 } |
| 802 return new Future.value(map); | 801 return new Future.value(map); |
| 803 }).catchError((e) { | 802 }).catchError((e) { |
| 804 // Errors pass through. | 803 // Errors pass through. |
| 805 return new Future.error(e); | 804 return new Future.error(e); |
| 806 }); | 805 }); |
| 807 } | 806 } |
| 808 | 807 |
| 809 Future<ServiceObject> invokeRpc(String method, Map params) { | 808 Future<ServiceObject> invokeRpc(String method, Map params) { |
| 810 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) { | 809 return invokeRpcNoUpgrade(method, params).then((Map response) { |
| 811 var obj = new ServiceObject._fromMap(this, response); | 810 var obj = new ServiceObject._fromMap(this, response); |
| 812 if ((obj != null) && obj.canCache) { | 811 if ((obj != null) && obj.canCache) { |
| 813 String objId = obj.id; | 812 String objId = obj.id; |
| 814 _cache.putIfAbsent(objId, () => obj); | 813 _cache.putIfAbsent(objId, () => obj); |
| 815 } | 814 } |
| 816 return obj; | 815 return obj; |
| 817 }); | 816 }); |
| 818 } | 817 } |
| 819 | 818 |
| 820 void _dispatchEventToIsolate(ServiceEvent event) { | 819 void _dispatchEventToIsolate(ServiceEvent event) { |
| 821 var isolate = event.isolate; | 820 var isolate = event.isolate; |
| 822 if (isolate != null) { | 821 if (isolate != null) { |
| 823 isolate._onEvent(event); | 822 isolate._onEvent(event); |
| 824 } | 823 } |
| 825 } | 824 } |
| 826 | 825 |
| 827 Future restart() { | 826 Future restart() { |
| 828 return invokeRpc('_restartVM', {}); | 827 return invokeRpc('_restartVM', {}); |
| 829 } | 828 } |
| 830 | 829 |
| 831 Future<ObservableMap> _fetchDirect({int count: kDefaultFieldLimit}) async { | 830 Future<Map> _fetchDirect({int count: kDefaultFieldLimit}) async { |
| 832 if (!loaded) { | 831 if (!loaded) { |
| 833 // The vm service relies on these events to keep the VM and | 832 // The vm service relies on these events to keep the VM and |
| 834 // Isolate types up to date. | 833 // Isolate types up to date. |
| 835 try { | 834 try { |
| 836 await listenEventStream(kVMStream, _dispatchEventToIsolate); | 835 await listenEventStream(kVMStream, _dispatchEventToIsolate); |
| 837 await listenEventStream(kIsolateStream, _dispatchEventToIsolate); | 836 await listenEventStream(kIsolateStream, _dispatchEventToIsolate); |
| 838 await listenEventStream(kDebugStream, _dispatchEventToIsolate); | 837 await listenEventStream(kDebugStream, _dispatchEventToIsolate); |
| 839 await listenEventStream(_kGraphStream, _dispatchEventToIsolate); | 838 await listenEventStream(_kGraphStream, _dispatchEventToIsolate); |
| 840 } on FakeVMRpcException catch (_) { | 839 } on FakeVMRpcException catch (_) { |
| 841 // ignore FakeVMRpcExceptions here. | 840 // ignore FakeVMRpcExceptions here. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 return stream.listen(function); | 893 return stream.listen(function); |
| 895 } | 894 } |
| 896 | 895 |
| 897 /// Force the VM to disconnect. | 896 /// Force the VM to disconnect. |
| 898 void disconnect(); | 897 void disconnect(); |
| 899 /// Completes when the VM first connects. | 898 /// Completes when the VM first connects. |
| 900 Future get onConnect; | 899 Future get onConnect; |
| 901 /// Completes when the VM disconnects or there was an error connecting. | 900 /// Completes when the VM disconnects or there was an error connecting. |
| 902 Future get onDisconnect; | 901 Future get onDisconnect; |
| 903 | 902 |
| 904 void _update(ObservableMap map, bool mapIsRef) { | 903 void _update(Map map, bool mapIsRef) { |
| 905 name = map['name']; | 904 name = map['name']; |
| 906 vmName = map.containsKey('_vmName') ? map['_vmName'] : name; | 905 vmName = map.containsKey('_vmName') ? map['_vmName'] : name; |
| 907 if (mapIsRef) { | 906 if (mapIsRef) { |
| 908 return; | 907 return; |
| 909 } | 908 } |
| 910 // Note that upgrading the collection creates any isolates in the | 909 // Note that upgrading the collection creates any isolates in the |
| 911 // isolate list which are new. | 910 // isolate list which are new. |
| 912 _upgradeCollection(map, vm); | 911 _upgradeCollection(map, vm); |
| 913 | 912 |
| 914 _loaded = true; | 913 _loaded = true; |
| 915 version = map['version']; | 914 version = map['version']; |
| 916 hostCPU = map['hostCPU']; | 915 hostCPU = map['hostCPU']; |
| 917 targetCPU = map['targetCPU']; | 916 targetCPU = map['targetCPU']; |
| 918 architectureBits = map['architectureBits']; | 917 architectureBits = map['architectureBits']; |
| 919 int startTimeMillis = map['startTime']; | 918 int startTimeMillis = map['startTime']; |
| 920 startTime = new DateTime.fromMillisecondsSinceEpoch(startTimeMillis); | 919 startTime = new DateTime.fromMillisecondsSinceEpoch(startTimeMillis); |
| 921 refreshTime = new DateTime.now(); | 920 refreshTime = new DateTime.now(); |
| 922 notifyPropertyChange(#upTime, 0, 1); | |
| 923 pid = map['pid']; | 921 pid = map['pid']; |
| 924 maxRSS = map['_maxRSS']; | 922 maxRSS = map['_maxRSS']; |
| 925 profileVM = map['_profilerMode'] == 'VM'; | 923 profileVM = map['_profilerMode'] == 'VM'; |
| 926 assertsEnabled = map['_assertsEnabled']; | 924 assertsEnabled = map['_assertsEnabled']; |
| 927 typeChecksEnabled = map['_typeChecksEnabled']; | 925 typeChecksEnabled = map['_typeChecksEnabled']; |
| 928 _removeDeadIsolates(map['isolates']); | 926 _removeDeadIsolates(map['isolates']); |
| 929 } | 927 } |
| 930 | 928 |
| 931 // Reload all isolates. | 929 // Reload all isolates. |
| 932 Future reloadIsolates() { | 930 Future reloadIsolates() { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 final List<String> names = new List<String>(); | 1053 final List<String> names = new List<String>(); |
| 1056 final List<TagProfileSnapshot> snapshots = new List<TagProfileSnapshot>(); | 1054 final List<TagProfileSnapshot> snapshots = new List<TagProfileSnapshot>(); |
| 1057 double get updatedAtSeconds => _seconds; | 1055 double get updatedAtSeconds => _seconds; |
| 1058 double _seconds; | 1056 double _seconds; |
| 1059 TagProfileSnapshot _maxSnapshot; | 1057 TagProfileSnapshot _maxSnapshot; |
| 1060 int _historySize; | 1058 int _historySize; |
| 1061 int _countersLength = 0; | 1059 int _countersLength = 0; |
| 1062 | 1060 |
| 1063 TagProfile(this._historySize); | 1061 TagProfile(this._historySize); |
| 1064 | 1062 |
| 1065 void _processTagProfile(double seconds, ObservableMap tagProfile) { | 1063 void _processTagProfile(double seconds, Map tagProfile) { |
| 1066 _seconds = seconds; | 1064 _seconds = seconds; |
| 1067 var counters = tagProfile['counters']; | 1065 var counters = tagProfile['counters']; |
| 1068 if (names.length == 0) { | 1066 if (names.length == 0) { |
| 1069 // Initialization. | 1067 // Initialization. |
| 1070 names.addAll(tagProfile['names']); | 1068 names.addAll(tagProfile['names']); |
| 1071 _countersLength = tagProfile['counters'].length; | 1069 _countersLength = tagProfile['counters'].length; |
| 1072 for (var i = 0; i < _historySize; i++) { | 1070 for (var i = 0; i < _historySize; i++) { |
| 1073 var snapshot = new TagProfileSnapshot(0.0, _countersLength); | 1071 var snapshot = new TagProfileSnapshot(0.0, _countersLength); |
| 1074 snapshot.zero(); | 1072 snapshot.zero(); |
| 1075 snapshots.add(snapshot); | 1073 snapshots.add(snapshot); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 final HeapObject object; | 1175 final HeapObject object; |
| 1178 | 1176 |
| 1179 WeakPersistentHandle(ServiceMap map) | 1177 WeakPersistentHandle(ServiceMap map) |
| 1180 : externalSize = int.parse(map['externalSize']), | 1178 : externalSize = int.parse(map['externalSize']), |
| 1181 peer = map['peer'], | 1179 peer = map['peer'], |
| 1182 callbackSymbolName = map['callbackSymbolName'], | 1180 callbackSymbolName = map['callbackSymbolName'], |
| 1183 callbackAddress = map['callbackAddress'], | 1181 callbackAddress = map['callbackAddress'], |
| 1184 object = map['object']; | 1182 object = map['object']; |
| 1185 } | 1183 } |
| 1186 | 1184 |
| 1187 class HeapSpace extends Observable implements M.HeapSpace { | 1185 class HeapSpace implements M.HeapSpace { |
| 1188 @observable int used = 0; | 1186 int used = 0; |
| 1189 @observable int capacity = 0; | 1187 int capacity = 0; |
| 1190 @observable int external = 0; | 1188 int external = 0; |
| 1191 @observable int collections = 0; | 1189 int collections = 0; |
| 1192 @observable double totalCollectionTimeInSeconds = 0.0; | 1190 double totalCollectionTimeInSeconds = 0.0; |
| 1193 @observable double averageCollectionPeriodInMillis = 0.0; | 1191 double averageCollectionPeriodInMillis = 0.0; |
| 1194 | 1192 |
| 1195 Duration get avgCollectionTime { | 1193 Duration get avgCollectionTime { |
| 1196 final mcs = totalCollectionTimeInSeconds * Duration.MICROSECONDS_PER_SECOND | 1194 final mcs = totalCollectionTimeInSeconds * Duration.MICROSECONDS_PER_SECOND |
| 1197 / math.max(collections, 1); | 1195 / math.max(collections, 1); |
| 1198 return new Duration(microseconds: mcs.ceil()); | 1196 return new Duration(microseconds: mcs.ceil()); |
| 1199 } | 1197 } |
| 1200 | 1198 |
| 1201 Duration get totalCollectionTime { | 1199 Duration get totalCollectionTime { |
| 1202 final mcs = totalCollectionTimeInSeconds * Duration.MICROSECONDS_PER_SECOND; | 1200 final mcs = totalCollectionTimeInSeconds * Duration.MICROSECONDS_PER_SECOND; |
| 1203 return new Duration(microseconds: mcs.ceil()); | 1201 return new Duration(microseconds: mcs.ceil()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1223 final chunks; | 1221 final chunks; |
| 1224 final count; | 1222 final count; |
| 1225 RawHeapSnapshot(this.chunks, this.count); | 1223 RawHeapSnapshot(this.chunks, this.count); |
| 1226 } | 1224 } |
| 1227 | 1225 |
| 1228 /// State for a running isolate. | 1226 /// State for a running isolate. |
| 1229 class Isolate extends ServiceObjectOwner implements M.Isolate { | 1227 class Isolate extends ServiceObjectOwner implements M.Isolate { |
| 1230 static const kLoggingStream = '_Logging'; | 1228 static const kLoggingStream = '_Logging'; |
| 1231 static const kExtensionStream = 'Extension'; | 1229 static const kExtensionStream = 'Extension'; |
| 1232 | 1230 |
| 1233 @reflectable VM get vm => owner; | 1231 VM get vm => owner; |
| 1234 @reflectable Isolate get isolate => this; | 1232 Isolate get isolate => this; |
| 1235 @observable int number; | 1233 int number; |
| 1236 @observable int originNumber; | 1234 int originNumber; |
| 1237 @observable DateTime startTime; | 1235 DateTime startTime; |
| 1238 @observable Duration get upTime { | 1236 Duration get upTime { |
| 1239 if (startTime == null) { | 1237 if (startTime == null) { |
| 1240 return null; | 1238 return null; |
| 1241 } | 1239 } |
| 1242 return (new DateTime.now().difference(startTime)); | 1240 return (new DateTime.now().difference(startTime)); |
| 1243 } | 1241 } |
| 1244 | 1242 |
| 1245 @observable Map counters = {}; | 1243 Map counters = {}; |
| 1246 | 1244 |
| 1247 void _updateRunState() { | 1245 void _updateRunState() { |
| 1248 topFrame = M.topFrame(pauseEvent); | 1246 topFrame = M.topFrame(pauseEvent); |
| 1249 paused = (pauseEvent != null && | 1247 paused = (pauseEvent != null && |
| 1250 !(pauseEvent is M.ResumeEvent)); | 1248 !(pauseEvent is M.ResumeEvent)); |
| 1251 running = (!paused && topFrame != null); | 1249 running = (!paused && topFrame != null); |
| 1252 idle = (!paused && topFrame == null); | 1250 idle = (!paused && topFrame == null); |
| 1253 notifyPropertyChange(#topFrame, 0, 1); | |
| 1254 notifyPropertyChange(#paused, 0, 1); | |
| 1255 notifyPropertyChange(#running, 0, 1); | |
| 1256 notifyPropertyChange(#idle, 0, 1); | |
| 1257 } | 1251 } |
| 1258 | 1252 |
| 1259 @observable M.DebugEvent pauseEvent = null; | 1253 M.DebugEvent pauseEvent = null; |
| 1260 @observable bool paused = false; | 1254 bool paused = false; |
| 1261 @observable bool running = false; | 1255 bool running = false; |
| 1262 @observable bool idle = false; | 1256 bool idle = false; |
| 1263 @observable bool loading = true; | 1257 bool loading = true; |
| 1264 @observable bool runnable = false; | 1258 bool runnable = false; |
| 1265 @observable bool ioEnabled = false; | 1259 bool ioEnabled = false; |
| 1266 @observable bool reloading = false; | 1260 bool reloading = false; |
| 1267 M.IsolateStatus get status { | 1261 M.IsolateStatus get status { |
| 1268 if (paused) { | 1262 if (paused) { |
| 1269 return M.IsolateStatus.paused; | 1263 return M.IsolateStatus.paused; |
| 1270 } | 1264 } |
| 1271 if (running) { | 1265 if (running) { |
| 1272 return M.IsolateStatus.running; | 1266 return M.IsolateStatus.running; |
| 1273 } | 1267 } |
| 1274 if (idle) { | 1268 if (idle) { |
| 1275 return M.IsolateStatus.idle; | 1269 return M.IsolateStatus.idle; |
| 1276 } | 1270 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 (cls.library.uri == 'dart:core')) { | 1386 (cls.library.uri == 'dart:core')) { |
| 1393 objectClass = cls; | 1387 objectClass = cls; |
| 1394 } | 1388 } |
| 1395 } | 1389 } |
| 1396 assert(objectClass != null); | 1390 assert(objectClass != null); |
| 1397 return new Future.value(objectClass); | 1391 return new Future.value(objectClass); |
| 1398 } | 1392 } |
| 1399 | 1393 |
| 1400 Class getClassByCid(int cid) => _classesByCid[cid]; | 1394 Class getClassByCid(int cid) => _classesByCid[cid]; |
| 1401 | 1395 |
| 1402 ServiceObject getFromMap(ObservableMap map) { | 1396 ServiceObject getFromMap(Map map) { |
| 1403 if (map == null) { | 1397 if (map == null) { |
| 1404 return null; | 1398 return null; |
| 1405 } | 1399 } |
| 1406 var mapType = _stripRef(map['type']); | 1400 var mapType = _stripRef(map['type']); |
| 1407 if (mapType == 'Isolate') { | 1401 if (mapType == 'Isolate') { |
| 1408 // There are sometimes isolate refs in ServiceEvents. | 1402 // There are sometimes isolate refs in ServiceEvents. |
| 1409 return vm.getFromMap(map); | 1403 return vm.getFromMap(map); |
| 1410 } | 1404 } |
| 1411 String mapId = map['id']; | 1405 String mapId = map['id']; |
| 1412 var obj = (mapId != null) ? _cache[mapId] : null; | 1406 var obj = (mapId != null) ? _cache[mapId] : null; |
| 1413 if (obj != null) { | 1407 if (obj != null) { |
| 1414 obj.update(map); | 1408 obj.update(map); |
| 1415 return obj; | 1409 return obj; |
| 1416 } | 1410 } |
| 1417 // Build the object from the map directly. | 1411 // Build the object from the map directly. |
| 1418 obj = new ServiceObject._fromMap(this, map); | 1412 obj = new ServiceObject._fromMap(this, map); |
| 1419 if ((obj != null) && obj.canCache) { | 1413 if ((obj != null) && obj.canCache) { |
| 1420 _cache[mapId] = obj; | 1414 _cache[mapId] = obj; |
| 1421 } | 1415 } |
| 1422 return obj; | 1416 return obj; |
| 1423 } | 1417 } |
| 1424 | 1418 |
| 1425 Future<ObservableMap> invokeRpcNoUpgrade(String method, Map params) { | 1419 Future<Map> invokeRpcNoUpgrade(String method, Map params) { |
| 1426 params['isolateId'] = id; | 1420 params['isolateId'] = id; |
| 1427 return vm.invokeRpcNoUpgrade(method, params); | 1421 return vm.invokeRpcNoUpgrade(method, params); |
| 1428 } | 1422 } |
| 1429 | 1423 |
| 1430 Future<ServiceObject> invokeRpc(String method, Map params) { | 1424 Future<ServiceObject> invokeRpc(String method, Map params) { |
| 1431 return invokeRpcNoUpgrade(method, params).then((ObservableMap response) { | 1425 return invokeRpcNoUpgrade(method, params).then((Map response) { |
| 1432 return getFromMap(response); | 1426 return getFromMap(response); |
| 1433 }); | 1427 }); |
| 1434 } | 1428 } |
| 1435 | 1429 |
| 1436 Future<ServiceObject> getObject(String objectId, | 1430 Future<ServiceObject> getObject(String objectId, |
| 1437 {bool reload: true, | 1431 {bool reload: true, |
| 1438 int count: kDefaultFieldLimit}) { | 1432 int count: kDefaultFieldLimit}) { |
| 1439 assert(objectId != null && objectId != ''); | 1433 assert(objectId != null && objectId != ''); |
| 1440 var obj = _cache[objectId]; | 1434 var obj = _cache[objectId]; |
| 1441 if (obj != null) { | 1435 if (obj != null) { |
| 1442 if (reload) { | 1436 if (reload) { |
| 1443 return obj.reload(count: count); | 1437 return obj.reload(count: count); |
| 1444 } | 1438 } |
| 1445 // Returned cached object. | 1439 // Returned cached object. |
| 1446 return new Future.value(obj); | 1440 return new Future.value(obj); |
| 1447 } | 1441 } |
| 1448 Map params = { | 1442 Map params = { |
| 1449 'objectId': objectId, | 1443 'objectId': objectId, |
| 1450 'count': count, | 1444 'count': count, |
| 1451 }; | 1445 }; |
| 1452 return isolate.invokeRpc('getObject', params); | 1446 return isolate.invokeRpc('getObject', params); |
| 1453 } | 1447 } |
| 1454 | 1448 |
| 1455 Future<ObservableMap> _fetchDirect({int count: kDefaultFieldLimit}) async { | 1449 Future<Map> _fetchDirect({int count: kDefaultFieldLimit}) async { |
| 1456 return invokeRpcNoUpgrade('getIsolate', {}); | 1450 return invokeRpcNoUpgrade('getIsolate', {}); |
| 1457 } | 1451 } |
| 1458 | 1452 |
| 1459 @observable Class objectClass; | 1453 Class objectClass; |
| 1460 @observable final rootClasses = new ObservableList<Class>(); | 1454 final rootClasses = <Class>[]; |
| 1461 Map<int, Class> _classesByCid = new Map<int, Class>(); | 1455 Map<int, Class> _classesByCid = new Map<int, Class>(); |
| 1462 | 1456 |
| 1463 @observable Library rootLibrary; | 1457 Library rootLibrary; |
| 1464 @observable ObservableList<Library> libraries = | 1458 List<Library> libraries = <Library>[]; |
| 1465 new ObservableList<Library>(); | 1459 Frame topFrame; |
| 1466 @observable Frame topFrame; | |
| 1467 | 1460 |
| 1468 @observable String name; | 1461 String name; |
| 1469 @observable String vmName; | 1462 String vmName; |
| 1470 @observable ServiceFunction entry; | 1463 ServiceFunction entry; |
| 1471 | 1464 |
| 1472 final HeapSpace newSpace = new HeapSpace(); | 1465 final HeapSpace newSpace = new HeapSpace(); |
| 1473 final HeapSpace oldSpace = new HeapSpace(); | 1466 final HeapSpace oldSpace = new HeapSpace(); |
| 1474 | 1467 |
| 1475 @observable String fileAndLine; | 1468 String fileAndLine; |
| 1476 | 1469 |
| 1477 @observable DartError error; | 1470 DartError error; |
| 1478 StreamController _snapshotFetch; | 1471 StreamController _snapshotFetch; |
| 1479 | 1472 |
| 1480 List<ByteData> _chunksInProgress; | 1473 List<ByteData> _chunksInProgress; |
| 1481 | 1474 |
| 1482 void _loadHeapSnapshot(ServiceEvent event) { | 1475 void _loadHeapSnapshot(ServiceEvent event) { |
| 1483 if (_snapshotFetch == null || _snapshotFetch.isClosed) { | 1476 if (_snapshotFetch == null || _snapshotFetch.isClosed) { |
| 1484 // No outstanding snapshot request. Presumably another client asked for a | 1477 // No outstanding snapshot request. Presumably another client asked for a |
| 1485 // snapshot. | 1478 // snapshot. |
| 1486 Logger.root.info("Dropping unsolicited heap snapshot chunk"); | 1479 Logger.root.info("Dropping unsolicited heap snapshot chunk"); |
| 1487 return; | 1480 return; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1513 Stream fetchHeapSnapshot(collectGarbage) { | 1506 Stream fetchHeapSnapshot(collectGarbage) { |
| 1514 if (_snapshotFetch == null || _snapshotFetch.isClosed) { | 1507 if (_snapshotFetch == null || _snapshotFetch.isClosed) { |
| 1515 _snapshotFetch = new StreamController.broadcast(); | 1508 _snapshotFetch = new StreamController.broadcast(); |
| 1516 // isolate.vm.streamListen('_Graph'); | 1509 // isolate.vm.streamListen('_Graph'); |
| 1517 isolate.invokeRpcNoUpgrade('_requestHeapSnapshot', | 1510 isolate.invokeRpcNoUpgrade('_requestHeapSnapshot', |
| 1518 {'collectGarbage': collectGarbage}); | 1511 {'collectGarbage': collectGarbage}); |
| 1519 } | 1512 } |
| 1520 return _snapshotFetch.stream; | 1513 return _snapshotFetch.stream; |
| 1521 } | 1514 } |
| 1522 | 1515 |
| 1523 void updateHeapsFromMap(ObservableMap map) { | 1516 void updateHeapsFromMap(Map map) { |
| 1524 newSpace.update(map['new']); | 1517 newSpace.update(map['new']); |
| 1525 oldSpace.update(map['old']); | 1518 oldSpace.update(map['old']); |
| 1526 } | 1519 } |
| 1527 | 1520 |
| 1528 void _update(ObservableMap map, bool mapIsRef) { | 1521 void _update(Map map, bool mapIsRef) { |
| 1529 name = map['name']; | 1522 name = map['name']; |
| 1530 vmName = map.containsKey('_vmName') ? map['_vmName'] : name; | 1523 vmName = map.containsKey('_vmName') ? map['_vmName'] : name; |
| 1531 number = int.parse(map['number'], onError:(_) => null); | 1524 number = int.parse(map['number'], onError:(_) => null); |
| 1532 if (mapIsRef) { | 1525 if (mapIsRef) { |
| 1533 return; | 1526 return; |
| 1534 } | 1527 } |
| 1535 _loaded = true; | 1528 _loaded = true; |
| 1536 loading = false; | 1529 loading = false; |
| 1537 runnable = map['runnable'] == true; | 1530 runnable = map['runnable'] == true; |
| 1538 _upgradeCollection(map, isolate); | 1531 _upgradeCollection(map, isolate); |
| 1539 originNumber = int.parse(map['_originNumber'], onError:(_) => null); | 1532 originNumber = int.parse(map['_originNumber'], onError:(_) => null); |
| 1540 rootLibrary = map['rootLib']; | 1533 rootLibrary = map['rootLib']; |
| 1541 if (map['entry'] != null) { | 1534 if (map['entry'] != null) { |
| 1542 entry = map['entry']; | 1535 entry = map['entry']; |
| 1543 } | 1536 } |
| 1544 var savedStartTime = startTime; | 1537 var savedStartTime = startTime; |
| 1545 int startTimeInMillis = map['startTime']; | 1538 int startTimeInMillis = map['startTime']; |
| 1546 startTime = new DateTime.fromMillisecondsSinceEpoch(startTimeInMillis); | 1539 startTime = new DateTime.fromMillisecondsSinceEpoch(startTimeInMillis); |
| 1547 notifyPropertyChange(#upTime, 0, 1); | |
| 1548 var countersMap = map['_tagCounters']; | 1540 var countersMap = map['_tagCounters']; |
| 1549 if (countersMap != null) { | 1541 if (countersMap != null) { |
| 1550 var names = countersMap['names']; | 1542 var names = countersMap['names']; |
| 1551 var counts = countersMap['counters']; | 1543 var counts = countersMap['counters']; |
| 1552 assert(names.length == counts.length); | 1544 assert(names.length == counts.length); |
| 1553 var sum = 0; | 1545 var sum = 0; |
| 1554 for (var i = 0; i < counts.length; i++) { | 1546 for (var i = 0; i < counts.length; i++) { |
| 1555 sum += counts[i]; | 1547 sum += counts[i]; |
| 1556 } | 1548 } |
| 1557 var _counters = {}; | 1549 var _counters = {}; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 } | 1584 } |
| 1593 | 1585 |
| 1594 extensionRPCs.clear(); | 1586 extensionRPCs.clear(); |
| 1595 if (map['extensionRPCs'] != null) { | 1587 if (map['extensionRPCs'] != null) { |
| 1596 extensionRPCs.addAll(map['extensionRPCs']); | 1588 extensionRPCs.addAll(map['extensionRPCs']); |
| 1597 } | 1589 } |
| 1598 } | 1590 } |
| 1599 | 1591 |
| 1600 Future<TagProfile> updateTagProfile() { | 1592 Future<TagProfile> updateTagProfile() { |
| 1601 return isolate.invokeRpcNoUpgrade('_getTagProfile', {}).then( | 1593 return isolate.invokeRpcNoUpgrade('_getTagProfile', {}).then( |
| 1602 (ObservableMap map) { | 1594 (Map map) { |
| 1603 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0; | 1595 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0; |
| 1604 tagProfile._processTagProfile(seconds, map); | 1596 tagProfile._processTagProfile(seconds, map); |
| 1605 return tagProfile; | 1597 return tagProfile; |
| 1606 }); | 1598 }); |
| 1607 } | 1599 } |
| 1608 | 1600 |
| 1609 ObservableMap<int, Breakpoint> breakpoints = new ObservableMap(); | 1601 Map<int, Breakpoint> breakpoints = <int, Breakpoint>{}; |
| 1610 String exceptionsPauseInfo; | 1602 String exceptionsPauseInfo; |
| 1611 | 1603 |
| 1612 void _updateBreakpoints(List newBpts) { | 1604 void _updateBreakpoints(List newBpts) { |
| 1613 // Build a set of new breakpoints. | 1605 // Build a set of new breakpoints. |
| 1614 var newBptSet = new Set(); | 1606 var newBptSet = new Set(); |
| 1615 newBpts.forEach((bpt) => newBptSet.add(bpt.number)); | 1607 newBpts.forEach((bpt) => newBptSet.add(bpt.number)); |
| 1616 | 1608 |
| 1617 // Remove any old breakpoints which no longer exist. | 1609 // Remove any old breakpoints which no longer exist. |
| 1618 List toRemove = []; | 1610 List toRemove = []; |
| 1619 breakpoints.forEach((key, _) { | 1611 breakpoints.forEach((key, _) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1835 } | 1827 } |
| 1836 | 1828 |
| 1837 Future<ServiceObject> getObjectByAddress(String address, [bool ref=true]) { | 1829 Future<ServiceObject> getObjectByAddress(String address, [bool ref=true]) { |
| 1838 Map params = { | 1830 Map params = { |
| 1839 'address': address, | 1831 'address': address, |
| 1840 'ref': ref, | 1832 'ref': ref, |
| 1841 }; | 1833 }; |
| 1842 return invokeRpc('_getObjectByAddress', params); | 1834 return invokeRpc('_getObjectByAddress', params); |
| 1843 } | 1835 } |
| 1844 | 1836 |
| 1845 final ObservableMap<String, ServiceMetric> dartMetrics = | 1837 final Map<String, ServiceMetric> dartMetrics = <String, ServiceMetric>{}; |
| 1846 new ObservableMap<String, ServiceMetric>(); | |
| 1847 | 1838 |
| 1848 final ObservableMap<String, ServiceMetric> nativeMetrics = | 1839 final Map<String, ServiceMetric> nativeMetrics = <String, ServiceMetric>{}; |
| 1849 new ObservableMap<String, ServiceMetric>(); | |
| 1850 | 1840 |
| 1851 Future<ObservableMap<String, ServiceMetric>> _refreshMetrics( | 1841 Future<Map<String, ServiceMetric>> _refreshMetrics( |
| 1852 String metricType, | 1842 String metricType, |
| 1853 ObservableMap<String, ServiceMetric> metricsMap) { | 1843 Map<String, ServiceMetric> metricsMap) { |
| 1854 return invokeRpc('_getIsolateMetricList', | 1844 return invokeRpc('_getIsolateMetricList', |
| 1855 { 'type': metricType }).then((result) { | 1845 { 'type': metricType }).then((result) { |
| 1856 // Clear metrics map. | 1846 // Clear metrics map. |
| 1857 metricsMap.clear(); | 1847 metricsMap.clear(); |
| 1858 // Repopulate metrics map. | 1848 // Repopulate metrics map. |
| 1859 var metrics = result['metrics']; | 1849 var metrics = result['metrics']; |
| 1860 for (var metric in metrics) { | 1850 for (var metric in metrics) { |
| 1861 metricsMap[metric.id] = metric; | 1851 metricsMap[metric.id] = metric; |
| 1862 } | 1852 } |
| 1863 return metricsMap; | 1853 return metricsMap; |
| 1864 }); | 1854 }); |
| 1865 } | 1855 } |
| 1866 | 1856 |
| 1867 Future<ObservableMap<String, ServiceMetric>> refreshDartMetrics() { | 1857 Future<Map<String, ServiceMetric>> refreshDartMetrics() { |
| 1868 return _refreshMetrics('Dart', dartMetrics); | 1858 return _refreshMetrics('Dart', dartMetrics); |
| 1869 } | 1859 } |
| 1870 | 1860 |
| 1871 Future<ObservableMap<String, ServiceMetric>> refreshNativeMetrics() { | 1861 Future<Map<String, ServiceMetric>> refreshNativeMetrics() { |
| 1872 return _refreshMetrics('Native', nativeMetrics); | 1862 return _refreshMetrics('Native', nativeMetrics); |
| 1873 } | 1863 } |
| 1874 | 1864 |
| 1875 Future refreshMetrics() { | 1865 Future refreshMetrics() { |
| 1876 return Future.wait([refreshDartMetrics(), refreshNativeMetrics()]); | 1866 return Future.wait([refreshDartMetrics(), refreshNativeMetrics()]); |
| 1877 } | 1867 } |
| 1878 | 1868 |
| 1879 String toString() => "Isolate($name)"; | 1869 String toString() => "Isolate($name)"; |
| 1880 } | 1870 } |
| 1881 | 1871 |
| 1882 | 1872 |
| 1883 class NamedField implements M.NamedField { | 1873 class NamedField implements M.NamedField { |
| 1884 final String name; | 1874 final String name; |
| 1885 final M.ObjectRef value; | 1875 final M.ObjectRef value; |
| 1886 NamedField(this.name, this.value); | 1876 NamedField(this.name, this.value); |
| 1887 } | 1877 } |
| 1888 | 1878 |
| 1889 | 1879 |
| 1890 class ObjectStore extends ServiceObject implements M.ObjectStore { | 1880 class ObjectStore extends ServiceObject implements M.ObjectStore { |
| 1891 @observable List<NamedField> fields = new List<NamedField>(); | 1881 List<NamedField> fields = new List<NamedField>(); |
| 1892 | 1882 |
| 1893 ObjectStore._empty(ServiceObjectOwner owner) : super._empty(owner); | 1883 ObjectStore._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 1894 | 1884 |
| 1895 void _update(ObservableMap map, bool mapIsRef) { | 1885 void _update(Map map, bool mapIsRef) { |
| 1896 // Extract full properties. | 1886 // Extract full properties. |
| 1897 _upgradeCollection(map, isolate); | 1887 _upgradeCollection(map, isolate); |
| 1898 | 1888 |
| 1899 if (mapIsRef) { | 1889 if (mapIsRef) { |
| 1900 return; | 1890 return; |
| 1901 } | 1891 } |
| 1902 | 1892 |
| 1903 fields.clear(); | 1893 fields.clear(); |
| 1904 map['fields'].forEach((key, value) { | 1894 map['fields'].forEach((key, value) { |
| 1905 fields.add(new NamedField(key, value)); | 1895 fields.add(new NamedField(key, value)); |
| 1906 }); | 1896 }); |
| 1907 _loaded = true; | 1897 _loaded = true; |
| 1908 } | 1898 } |
| 1909 } | 1899 } |
| 1910 | 1900 |
| 1911 | 1901 |
| 1912 /// A [ServiceObject] which implements [ObservableMap]. | 1902 /// A [ServiceObject] which implements [ObservableMap]. |
| 1913 class ServiceMap extends ServiceObject implements ObservableMap, | 1903 class ServiceMap extends ServiceObject implements M.UnknownObjectRef { |
| 1914 M.UnknownObjectRef { | 1904 final Map _map = {}; |
| 1915 final ObservableMap _map = new ObservableMap(); | |
| 1916 static String objectIdRingPrefix = 'objects/'; | 1905 static String objectIdRingPrefix = 'objects/'; |
| 1917 | 1906 |
| 1918 bool get immutable => false; | 1907 bool get immutable => false; |
| 1919 | 1908 |
| 1920 ServiceMap._empty(ServiceObjectOwner owner) : super._empty(owner); | 1909 ServiceMap._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 1921 | 1910 |
| 1922 void _update(ObservableMap map, bool mapIsRef) { | 1911 void _update(Map map, bool mapIsRef) { |
| 1923 _loaded = !mapIsRef; | 1912 _loaded = !mapIsRef; |
| 1924 | 1913 |
| 1925 _upgradeCollection(map, owner); | 1914 _upgradeCollection(map, owner); |
| 1926 // TODO(turnidge): Currently _map.clear() prevents us from | 1915 // TODO(turnidge): Currently _map.clear() prevents us from |
| 1927 // upgrading an already upgraded submap. Is clearing really the | 1916 // upgrading an already upgraded submap. Is clearing really the |
| 1928 // right thing to do here? | 1917 // right thing to do here? |
| 1929 _map.clear(); | 1918 _map.clear(); |
| 1930 _map.addAll(map); | 1919 _map.addAll(map); |
| 1931 | 1920 |
| 1932 name = _map['name']; | 1921 name = _map['name']; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1947 putIfAbsent(key, Function ifAbsent) => _map.putIfAbsent(key, ifAbsent); | 1936 putIfAbsent(key, Function ifAbsent) => _map.putIfAbsent(key, ifAbsent); |
| 1948 void remove(key) => _map.remove(key); | 1937 void remove(key) => _map.remove(key); |
| 1949 operator [](k) => _map[k]; | 1938 operator [](k) => _map[k]; |
| 1950 operator []=(k, v) => _map[k] = v; | 1939 operator []=(k, v) => _map[k] = v; |
| 1951 bool get isEmpty => _map.isEmpty; | 1940 bool get isEmpty => _map.isEmpty; |
| 1952 bool get isNotEmpty => _map.isNotEmpty; | 1941 bool get isNotEmpty => _map.isNotEmpty; |
| 1953 Iterable get keys => _map.keys; | 1942 Iterable get keys => _map.keys; |
| 1954 Iterable get values => _map.values; | 1943 Iterable get values => _map.values; |
| 1955 int get length => _map.length; | 1944 int get length => _map.length; |
| 1956 | 1945 |
| 1957 // Forward ChangeNotifier interface calls. | |
| 1958 bool deliverChanges() => _map.deliverChanges(); | |
| 1959 void notifyChange(ChangeRecord record) => _map.notifyChange(record); | |
| 1960 notifyPropertyChange(Symbol field, Object oldValue, Object newValue) => | |
| 1961 _map.notifyPropertyChange(field, oldValue, newValue); | |
| 1962 void observed() => _map.observed(); | |
| 1963 void unobserved() => _map.unobserved(); | |
| 1964 Stream<List<ChangeRecord>> get changes => _map.changes; | |
| 1965 bool get hasObservers => _map.hasObservers; | |
| 1966 | |
| 1967 String toString() => "ServiceMap($_map)"; | 1946 String toString() => "ServiceMap($_map)"; |
| 1968 } | 1947 } |
| 1969 | 1948 |
| 1970 M.ErrorKind stringToErrorKind(String value) { | 1949 M.ErrorKind stringToErrorKind(String value) { |
| 1971 switch(value) { | 1950 switch(value) { |
| 1972 case 'UnhandledException': return M.ErrorKind.unhandledException; | 1951 case 'UnhandledException': return M.ErrorKind.unhandledException; |
| 1973 case 'LanguageError': return M.ErrorKind.unhandledException; | 1952 case 'LanguageError': return M.ErrorKind.unhandledException; |
| 1974 case 'InternalError': return M.ErrorKind.internalError; | 1953 case 'InternalError': return M.ErrorKind.internalError; |
| 1975 case 'TerminationError': return M.ErrorKind.terminationError; | 1954 case 'TerminationError': return M.ErrorKind.terminationError; |
| 1976 } | 1955 } |
| 1977 Logger.root.severe('Unrecognized error kind: $value'); | 1956 Logger.root.severe('Unrecognized error kind: $value'); |
| 1978 throw new FallThroughError(); | 1957 throw new FallThroughError(); |
| 1979 } | 1958 } |
| 1980 | 1959 |
| 1981 /// A [DartError] is peered to a Dart Error object. | 1960 /// A [DartError] is peered to a Dart Error object. |
| 1982 class DartError extends ServiceObject implements M.Error { | 1961 class DartError extends ServiceObject implements M.Error { |
| 1983 DartError._empty(ServiceObject owner) : super._empty(owner); | 1962 DartError._empty(ServiceObject owner) : super._empty(owner); |
| 1984 | 1963 |
| 1985 M.ErrorKind kind; | 1964 M.ErrorKind kind; |
| 1986 final M.ClassRef clazz = null; | 1965 final M.ClassRef clazz = null; |
| 1987 final int size = null; | 1966 final int size = null; |
| 1988 @observable String message; | 1967 String message; |
| 1989 @observable Instance exception; | 1968 Instance exception; |
| 1990 @observable Instance stacktrace; | 1969 Instance stacktrace; |
| 1991 | 1970 |
| 1992 void _update(ObservableMap map, bool mapIsRef) { | 1971 void _update(Map map, bool mapIsRef) { |
| 1993 message = map['message']; | 1972 message = map['message']; |
| 1994 kind = stringToErrorKind(map['kind']); | 1973 kind = stringToErrorKind(map['kind']); |
| 1995 exception = new ServiceObject._fromMap(owner, map['exception']); | 1974 exception = new ServiceObject._fromMap(owner, map['exception']); |
| 1996 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']); | 1975 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']); |
| 1997 name = 'DartError($message)'; | 1976 name = 'DartError($message)'; |
| 1998 vmName = name; | 1977 vmName = name; |
| 1999 } | 1978 } |
| 2000 | 1979 |
| 2001 String toString() => 'DartError($message)'; | 1980 String toString() => 'DartError($message)'; |
| 2002 } | 1981 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 static const kConnectionClosed = 'ConnectionClosed'; | 2017 static const kConnectionClosed = 'ConnectionClosed'; |
| 2039 static const kLogging = '_Logging'; | 2018 static const kLogging = '_Logging'; |
| 2040 static const kExtension = 'Extension'; | 2019 static const kExtension = 'Extension'; |
| 2041 | 2020 |
| 2042 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); | 2021 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2043 | 2022 |
| 2044 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { | 2023 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { |
| 2045 kind = kConnectionClosed; | 2024 kind = kConnectionClosed; |
| 2046 } | 2025 } |
| 2047 | 2026 |
| 2048 @observable String kind; | 2027 String kind; |
| 2049 @observable DateTime timestamp; | 2028 DateTime timestamp; |
| 2050 List<M.Breakpoint> pauseBreakpoints; | 2029 List<M.Breakpoint> pauseBreakpoints; |
| 2051 @observable Breakpoint breakpoint; | 2030 Breakpoint breakpoint; |
| 2052 @observable Frame topFrame; | 2031 Frame topFrame; |
| 2053 @observable DartError error; | 2032 DartError error; |
| 2054 @observable String extensionRPC; | 2033 String extensionRPC; |
| 2055 @observable Instance exception; | 2034 Instance exception; |
| 2056 @observable Instance reloadError; | 2035 Instance reloadError; |
| 2057 @observable bool atAsyncSuspension; | 2036 bool atAsyncSuspension; |
| 2058 @observable Instance inspectee; | 2037 Instance inspectee; |
| 2059 @observable ByteData data; | 2038 ByteData data; |
| 2060 @observable int count; | 2039 int count; |
| 2061 @observable String reason; | 2040 String reason; |
| 2062 @observable String exceptions; | 2041 String exceptions; |
| 2063 @observable String bytesAsString; | 2042 String bytesAsString; |
| 2064 @observable Map logRecord; | 2043 Map logRecord; |
| 2065 @observable String extensionKind; | 2044 String extensionKind; |
| 2066 @observable Map extensionData; | 2045 Map extensionData; |
| 2067 @observable List timelineEvents; | 2046 List timelineEvents; |
| 2068 @observable String spawnToken; | 2047 String spawnToken; |
| 2069 @observable String spawnError; | 2048 String spawnError; |
| 2070 | 2049 |
| 2071 int chunkIndex, chunkCount, nodeCount; | 2050 int chunkIndex, chunkCount, nodeCount; |
| 2072 | 2051 |
| 2073 @observable bool get isPauseEvent { | 2052 bool get isPauseEvent { |
| 2074 return (kind == kPauseStart || | 2053 return (kind == kPauseStart || |
| 2075 kind == kPauseExit || | 2054 kind == kPauseExit || |
| 2076 kind == kPauseBreakpoint || | 2055 kind == kPauseBreakpoint || |
| 2077 kind == kPauseInterrupted || | 2056 kind == kPauseInterrupted || |
| 2078 kind == kPauseException || | 2057 kind == kPauseException || |
| 2079 kind == kNone); | 2058 kind == kNone); |
| 2080 } | 2059 } |
| 2081 | 2060 |
| 2082 void _update(ObservableMap map, bool mapIsRef) { | 2061 void _update(Map map, bool mapIsRef) { |
| 2083 _loaded = true; | 2062 _loaded = true; |
| 2084 _upgradeCollection(map, owner); | 2063 _upgradeCollection(map, owner); |
| 2085 | 2064 |
| 2086 assert(map['isolate'] == null || owner == map['isolate']); | 2065 assert(map['isolate'] == null || owner == map['isolate']); |
| 2087 timestamp = | 2066 timestamp = |
| 2088 new DateTime.fromMillisecondsSinceEpoch(map['timestamp']); | 2067 new DateTime.fromMillisecondsSinceEpoch(map['timestamp']); |
| 2089 kind = map['kind']; | 2068 kind = map['kind']; |
| 2090 notifyPropertyChange(#isPauseEvent, 0, 1); | |
| 2091 name = 'ServiceEvent $kind'; | 2069 name = 'ServiceEvent $kind'; |
| 2092 vmName = name; | 2070 vmName = name; |
| 2093 if (map['breakpoint'] != null) { | 2071 if (map['breakpoint'] != null) { |
| 2094 breakpoint = map['breakpoint']; | 2072 breakpoint = map['breakpoint']; |
| 2095 } | 2073 } |
| 2096 if (map['pauseBreakpoints'] != null) { | 2074 if (map['pauseBreakpoints'] != null) { |
| 2097 pauseBreakpoints = map['pauseBreakpoints']; | 2075 pauseBreakpoints = map['pauseBreakpoints']; |
| 2098 if (pauseBreakpoints.length > 0) { | 2076 if (pauseBreakpoints.length > 0) { |
| 2099 breakpoint = pauseBreakpoints[0]; | 2077 breakpoint = pauseBreakpoints[0]; |
| 2100 } | 2078 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 Breakpoint._empty(ServiceObjectOwner owner) : super._empty(owner); | 2154 Breakpoint._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2177 | 2155 |
| 2178 final M.ClassRef clazz = null; | 2156 final M.ClassRef clazz = null; |
| 2179 final int size = null; | 2157 final int size = null; |
| 2180 | 2158 |
| 2181 // TODO(turnidge): Add state to track if a breakpoint has been | 2159 // TODO(turnidge): Add state to track if a breakpoint has been |
| 2182 // removed from the program. Remove from the cache when deleted. | 2160 // removed from the program. Remove from the cache when deleted. |
| 2183 bool get immutable => false; | 2161 bool get immutable => false; |
| 2184 | 2162 |
| 2185 // A unique integer identifier for this breakpoint. | 2163 // A unique integer identifier for this breakpoint. |
| 2186 @observable int number; | 2164 int number; |
| 2187 | 2165 |
| 2188 // Either SourceLocation or UnresolvedSourceLocation. | 2166 // Either SourceLocation or UnresolvedSourceLocation. |
| 2189 @observable Location location; | 2167 Location location; |
| 2190 | 2168 |
| 2191 // The breakpoint is in a file which is not yet loaded. | 2169 // The breakpoint is in a file which is not yet loaded. |
| 2192 @observable bool latent; | 2170 bool latent; |
| 2193 | 2171 |
| 2194 // The breakpoint has been assigned to a final source location. | 2172 // The breakpoint has been assigned to a final source location. |
| 2195 @observable bool resolved; | 2173 bool resolved; |
| 2196 | 2174 |
| 2197 // The breakpoint was synthetically created as part of an | 2175 // The breakpoint was synthetically created as part of an |
| 2198 // 'OverAsyncContinuation' resume request. | 2176 // 'OverAsyncContinuation' resume request. |
| 2199 @observable bool isSyntheticAsyncContinuation; | 2177 bool isSyntheticAsyncContinuation; |
| 2200 | 2178 |
| 2201 void _update(ObservableMap map, bool mapIsRef) { | 2179 void _update(Map map, bool mapIsRef) { |
| 2202 _loaded = true; | 2180 _loaded = true; |
| 2203 _upgradeCollection(map, owner); | 2181 _upgradeCollection(map, owner); |
| 2204 | 2182 |
| 2205 var newNumber = map['breakpointNumber']; | 2183 var newNumber = map['breakpointNumber']; |
| 2206 // number never changes. | 2184 // number never changes. |
| 2207 assert((number == null) || (number == newNumber)); | 2185 assert((number == null) || (number == newNumber)); |
| 2208 number = newNumber; | 2186 number = newNumber; |
| 2209 resolved = map['resolved']; | 2187 resolved = map['resolved']; |
| 2210 | 2188 |
| 2211 var oldLocation = location; | 2189 var oldLocation = location; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2241 return 'Breakpoint ${number} at ${location}'; | 2219 return 'Breakpoint ${number} at ${location}'; |
| 2242 } | 2220 } |
| 2243 } else { | 2221 } else { |
| 2244 return 'Uninitialized breakpoint'; | 2222 return 'Uninitialized breakpoint'; |
| 2245 } | 2223 } |
| 2246 } | 2224 } |
| 2247 } | 2225 } |
| 2248 | 2226 |
| 2249 | 2227 |
| 2250 class LibraryDependency implements M.LibraryDependency { | 2228 class LibraryDependency implements M.LibraryDependency { |
| 2251 @reflectable final bool isImport; | 2229 final bool isImport; |
| 2252 @reflectable final bool isDeferred; | 2230 final bool isDeferred; |
| 2253 @reflectable final String prefix; | 2231 final String prefix; |
| 2254 @reflectable final Library target; | 2232 final Library target; |
| 2255 | 2233 |
| 2256 bool get isExport => !isImport; | 2234 bool get isExport => !isImport; |
| 2257 | 2235 |
| 2258 LibraryDependency._(this.isImport, this.isDeferred, this.prefix, this.target); | 2236 LibraryDependency._(this.isImport, this.isDeferred, this.prefix, this.target); |
| 2259 | 2237 |
| 2260 static _fromMap(map) => new LibraryDependency._(map["isImport"], | 2238 static _fromMap(map) => new LibraryDependency._(map["isImport"], |
| 2261 map["isDeferred"], | 2239 map["isDeferred"], |
| 2262 map["prefix"], | 2240 map["prefix"], |
| 2263 map["target"]); | 2241 map["target"]); |
| 2264 } | 2242 } |
| 2265 | 2243 |
| 2266 | 2244 |
| 2267 class Library extends HeapObject implements M.Library { | 2245 class Library extends HeapObject implements M.Library { |
| 2268 @observable String uri; | 2246 String uri; |
| 2269 @reflectable final dependencies = new ObservableList<LibraryDependency>(); | 2247 final dependencies = <LibraryDependency>[]; |
| 2270 @reflectable final scripts = new ObservableList<Script>(); | 2248 final scripts = <Script>[]; |
| 2271 @reflectable final classes = new ObservableList<Class>(); | 2249 final classes = <Class>[]; |
| 2272 @reflectable final variables = new ObservableList<Field>(); | 2250 final variables = <Field>[]; |
| 2273 @reflectable final functions = new ObservableList<ServiceFunction>(); | 2251 final functions = <ServiceFunction>[]; |
| 2274 | 2252 |
| 2275 bool get immutable => false; | 2253 bool get immutable => false; |
| 2276 | 2254 |
| 2277 bool isDart(String libraryName) { | 2255 bool isDart(String libraryName) { |
| 2278 return uri == 'dart:$libraryName'; | 2256 return uri == 'dart:$libraryName'; |
| 2279 } | 2257 } |
| 2280 | 2258 |
| 2281 Library._empty(ServiceObjectOwner owner) : super._empty(owner); | 2259 Library._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2282 | 2260 |
| 2283 void _update(ObservableMap map, bool mapIsRef) { | 2261 void _update(Map map, bool mapIsRef) { |
| 2284 _upgradeCollection(map, isolate); | 2262 _upgradeCollection(map, isolate); |
| 2285 super._update(map, mapIsRef); | 2263 super._update(map, mapIsRef); |
| 2286 | 2264 |
| 2287 uri = map['uri']; | 2265 uri = map['uri']; |
| 2288 var shortUri = uri; | 2266 var shortUri = uri; |
| 2289 if (uri.startsWith('file://') || | 2267 if (uri.startsWith('file://') || |
| 2290 uri.startsWith('http://')) { | 2268 uri.startsWith('http://')) { |
| 2291 shortUri = uri.substring(uri.lastIndexOf('/') + 1); | 2269 shortUri = uri.substring(uri.lastIndexOf('/') + 1); |
| 2292 } | 2270 } |
| 2293 name = map['name']; | 2271 name = map['name']; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2322 Script get rootScript { | 2300 Script get rootScript { |
| 2323 for (Script script in scripts) { | 2301 for (Script script in scripts) { |
| 2324 if (script.uri == uri) return script; | 2302 if (script.uri == uri) return script; |
| 2325 } | 2303 } |
| 2326 return null; | 2304 return null; |
| 2327 } | 2305 } |
| 2328 | 2306 |
| 2329 String toString() => "Library($uri)"; | 2307 String toString() => "Library($uri)"; |
| 2330 } | 2308 } |
| 2331 | 2309 |
| 2332 class AllocationCount extends Observable implements M.AllocationCount { | 2310 class AllocationCount implements M.AllocationCount { |
| 2333 @observable int instances = 0; | 2311 int instances = 0; |
| 2334 @observable int bytes = 0; | 2312 int bytes = 0; |
| 2335 | 2313 |
| 2336 void reset() { | 2314 void reset() { |
| 2337 instances = 0; | 2315 instances = 0; |
| 2338 bytes = 0; | 2316 bytes = 0; |
| 2339 } | 2317 } |
| 2340 | 2318 |
| 2341 bool get empty => (instances == 0) && (bytes == 0); | 2319 bool get empty => (instances == 0) && (bytes == 0); |
| 2342 bool get notEmpty => (instances != 0) || (bytes != 0); | 2320 bool get notEmpty => (instances != 0) || (bytes != 0); |
| 2343 } | 2321 } |
| 2344 | 2322 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2361 accumulated.bytes = stats[ACCUMULATED_SIZE]; | 2339 accumulated.bytes = stats[ACCUMULATED_SIZE]; |
| 2362 current.instances = stats[LIVE_AFTER_GC] + stats[ALLOCATED_SINCE_GC]; | 2340 current.instances = stats[LIVE_AFTER_GC] + stats[ALLOCATED_SINCE_GC]; |
| 2363 current.bytes = stats[LIVE_AFTER_GC_SIZE] + stats[ALLOCATED_SINCE_GC_SIZE]; | 2341 current.bytes = stats[LIVE_AFTER_GC_SIZE] + stats[ALLOCATED_SINCE_GC_SIZE]; |
| 2364 } | 2342 } |
| 2365 | 2343 |
| 2366 bool get empty => accumulated.empty && current.empty; | 2344 bool get empty => accumulated.empty && current.empty; |
| 2367 bool get notEmpty => accumulated.notEmpty || current.notEmpty; | 2345 bool get notEmpty => accumulated.notEmpty || current.notEmpty; |
| 2368 } | 2346 } |
| 2369 | 2347 |
| 2370 class Class extends HeapObject implements M.Class { | 2348 class Class extends HeapObject implements M.Class { |
| 2371 @observable Library library; | 2349 Library library; |
| 2372 | 2350 |
| 2373 @observable bool isAbstract; | 2351 bool isAbstract; |
| 2374 @observable bool isConst; | 2352 bool isConst; |
| 2375 @observable bool isFinalized; | 2353 bool isFinalized; |
| 2376 @observable bool isPatch; | 2354 bool isPatch; |
| 2377 @observable bool isImplemented; | 2355 bool isImplemented; |
| 2378 | 2356 |
| 2379 @observable SourceLocation location; | 2357 SourceLocation location; |
| 2380 | 2358 |
| 2381 @observable DartError error; | 2359 DartError error; |
| 2382 @observable int vmCid; | 2360 int vmCid; |
| 2383 | 2361 |
| 2384 final Allocations newSpace = new Allocations(); | 2362 final Allocations newSpace = new Allocations(); |
| 2385 final Allocations oldSpace = new Allocations(); | 2363 final Allocations oldSpace = new Allocations(); |
| 2386 final AllocationCount promotedByLastNewGC = new AllocationCount(); | 2364 final AllocationCount promotedByLastNewGC = new AllocationCount(); |
| 2387 | 2365 |
| 2388 @observable bool get hasAllocations => newSpace.notEmpty || oldSpace.notEmpty; | 2366 bool get hasAllocations => newSpace.notEmpty || oldSpace.notEmpty; |
| 2389 @observable bool get hasNoAllocations => newSpace.empty && oldSpace.empty; | 2367 bool get hasNoAllocations => newSpace.empty && oldSpace.empty; |
| 2390 @observable bool traceAllocations = false; | 2368 bool traceAllocations = false; |
| 2391 @reflectable final fields = new ObservableList<Field>(); | 2369 final fields = <Field>[]; |
| 2392 @reflectable final functions = new ObservableList<ServiceFunction>(); | 2370 final functions = <ServiceFunction>[]; |
| 2393 | 2371 |
| 2394 @observable Class superclass; | 2372 Class superclass; |
| 2395 @reflectable final interfaces = new ObservableList<Instance>(); | 2373 final interfaces = <Instance>[]; |
| 2396 @reflectable final subclasses = new ObservableList<Class>(); | 2374 final subclasses = <Class>[]; |
| 2397 | 2375 |
| 2398 @observable Instance superType; | 2376 Instance superType; |
| 2399 @observable Instance mixin; | 2377 Instance mixin; |
| 2400 | 2378 |
| 2401 bool get immutable => false; | 2379 bool get immutable => false; |
| 2402 | 2380 |
| 2403 Class._empty(ServiceObjectOwner owner) : super._empty(owner); | 2381 Class._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2404 | 2382 |
| 2405 void _update(ObservableMap map, bool mapIsRef) { | 2383 void _update(Map map, bool mapIsRef) { |
| 2406 _upgradeCollection(map, isolate); | 2384 _upgradeCollection(map, isolate); |
| 2407 super._update(map, mapIsRef); | 2385 super._update(map, mapIsRef); |
| 2408 | 2386 |
| 2409 name = map['name']; | 2387 name = map['name']; |
| 2410 vmName = (map.containsKey('_vmName') ? map['_vmName'] : name); | 2388 vmName = (map.containsKey('_vmName') ? map['_vmName'] : name); |
| 2411 if (vmName == '::') { | 2389 if (vmName == '::') { |
| 2412 name = 'top-level-class'; // Better than '' | 2390 name = 'top-level-class'; // Better than '' |
| 2413 } | 2391 } |
| 2414 var idPrefix = "classes/"; | 2392 var idPrefix = "classes/"; |
| 2415 assert(id.startsWith(idPrefix)); | 2393 assert(id.startsWith(idPrefix)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2465 | 2443 |
| 2466 error = map['error']; | 2444 error = map['error']; |
| 2467 | 2445 |
| 2468 traceAllocations = | 2446 traceAllocations = |
| 2469 (map['_traceAllocations'] != null) ? map['_traceAllocations'] : false; | 2447 (map['_traceAllocations'] != null) ? map['_traceAllocations'] : false; |
| 2470 | 2448 |
| 2471 var allocationStats = map['_allocationStats']; | 2449 var allocationStats = map['_allocationStats']; |
| 2472 if (allocationStats != null) { | 2450 if (allocationStats != null) { |
| 2473 newSpace.update(allocationStats['new']); | 2451 newSpace.update(allocationStats['new']); |
| 2474 oldSpace.update(allocationStats['old']); | 2452 oldSpace.update(allocationStats['old']); |
| 2475 notifyPropertyChange(#hasNoAllocations, 0, 1); | |
| 2476 promotedByLastNewGC.instances = allocationStats['promotedInstances']; | 2453 promotedByLastNewGC.instances = allocationStats['promotedInstances']; |
| 2477 promotedByLastNewGC.bytes = allocationStats['promotedBytes']; | 2454 promotedByLastNewGC.bytes = allocationStats['promotedBytes']; |
| 2478 } | 2455 } |
| 2479 } | 2456 } |
| 2480 | 2457 |
| 2481 void _addSubclass(Class subclass) { | 2458 void _addSubclass(Class subclass) { |
| 2482 if (subclasses.contains(subclass)) { | 2459 if (subclasses.contains(subclass)) { |
| 2483 return; | 2460 return; |
| 2484 } | 2461 } |
| 2485 subclasses.add(subclass); | 2462 subclasses.add(subclass); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2616 | 2593 |
| 2617 class MapAssociation implements M.MapAssociation { | 2594 class MapAssociation implements M.MapAssociation { |
| 2618 final Guarded<Instance> key; | 2595 final Guarded<Instance> key; |
| 2619 final Guarded<Instance> value; | 2596 final Guarded<Instance> value; |
| 2620 MapAssociation(key, value) | 2597 MapAssociation(key, value) |
| 2621 : key = new Guarded(key), | 2598 : key = new Guarded(key), |
| 2622 value = new Guarded(value); | 2599 value = new Guarded(value); |
| 2623 } | 2600 } |
| 2624 | 2601 |
| 2625 class Instance extends HeapObject implements M.Instance { | 2602 class Instance extends HeapObject implements M.Instance { |
| 2626 @observable M.InstanceKind kind; | 2603 M.InstanceKind kind; |
| 2627 @observable String valueAsString; // If primitive. | 2604 String valueAsString; // If primitive. |
| 2628 @observable bool valueAsStringIsTruncated; | 2605 bool valueAsStringIsTruncated; |
| 2629 @observable ServiceFunction closureFunction; // If a closure. | 2606 ServiceFunction closureFunction; // If a closure. |
| 2630 @observable Context closureContext; // If a closure. | 2607 Context closureContext; // If a closure. |
| 2631 @observable int length; // If a List, Map or TypedData. | 2608 int length; // If a List, Map or TypedData. |
| 2632 int count; | 2609 int count; |
| 2633 int offset; | 2610 int offset; |
| 2634 @observable Instance pattern; // If a RegExp. | 2611 Instance pattern; // If a RegExp. |
| 2635 | 2612 |
| 2636 @observable String name; | 2613 String name; |
| 2637 @observable Class typeClass; | 2614 Class typeClass; |
| 2638 @observable Class parameterizedClass; | 2615 Class parameterizedClass; |
| 2639 @observable TypeArguments typeArguments; | 2616 TypeArguments typeArguments; |
| 2640 @observable int parameterIndex; | 2617 int parameterIndex; |
| 2641 @observable Instance targetType; | 2618 Instance targetType; |
| 2642 @observable Instance bound; | 2619 Instance bound; |
| 2643 | 2620 |
| 2644 @observable Iterable<BoundField> fields; | 2621 Iterable<BoundField> fields; |
| 2645 @observable var nativeFields; | 2622 var nativeFields; |
| 2646 @observable Iterable<Guarded<HeapObject>> elements; // If a List. | 2623 Iterable<Guarded<HeapObject>> elements; // If a List. |
| 2647 @observable Iterable<MapAssociation> associations; // If a Map. | 2624 Iterable<MapAssociation> associations; // If a Map. |
| 2648 @observable Iterable<dynamic> typedElements; // If a TypedData. | 2625 Iterable<dynamic> typedElements; // If a TypedData. |
| 2649 @observable HeapObject referent; // If a MirrorReference. | 2626 HeapObject referent; // If a MirrorReference. |
| 2650 @observable Instance key; // If a WeakProperty. | 2627 Instance key; // If a WeakProperty. |
| 2651 @observable Instance value; // If a WeakProperty. | 2628 Instance value; // If a WeakProperty. |
| 2652 @observable Breakpoint activationBreakpoint; // If a Closure. | 2629 Breakpoint activationBreakpoint; // If a Closure. |
| 2653 @observable ServiceFunction oneByteFunction; // If a RegExp. | 2630 ServiceFunction oneByteFunction; // If a RegExp. |
| 2654 @observable ServiceFunction twoByteFunction; // If a RegExp. | 2631 ServiceFunction twoByteFunction; // If a RegExp. |
| 2655 @observable ServiceFunction externalOneByteFunction; // If a RegExp. | 2632 ServiceFunction externalOneByteFunction; // If a RegExp. |
| 2656 @observable ServiceFunction externalTwoByteFunction; // If a RegExp. | 2633 ServiceFunction externalTwoByteFunction; // If a RegExp. |
| 2657 @observable Instance oneByteBytecode; // If a RegExp. | 2634 Instance oneByteBytecode; // If a RegExp. |
| 2658 @observable Instance twoByteBytecode; // If a RegExp. | 2635 Instance twoByteBytecode; // If a RegExp. |
| 2659 @observable bool isCaseSensitive; // If a RegExp. | 2636 bool isCaseSensitive; // If a RegExp. |
| 2660 @observable bool isMultiLine; // If a RegExp. | 2637 bool isMultiLine; // If a RegExp. |
| 2661 | 2638 |
| 2662 bool get isAbstractType => M.isAbstractType(kind); | 2639 bool get isAbstractType => M.isAbstractType(kind); |
| 2663 bool get isNull => kind == M.InstanceKind.vNull; | 2640 bool get isNull => kind == M.InstanceKind.vNull; |
| 2664 bool get isBool => kind == M.InstanceKind.bool; | 2641 bool get isBool => kind == M.InstanceKind.bool; |
| 2665 bool get isDouble => kind == M.InstanceKind.double; | 2642 bool get isDouble => kind == M.InstanceKind.double; |
| 2666 bool get isString => kind == M.InstanceKind.string; | 2643 bool get isString => kind == M.InstanceKind.string; |
| 2667 bool get isInt => kind == M.InstanceKind.int; | 2644 bool get isInt => kind == M.InstanceKind.int; |
| 2668 bool get isList => kind == M.InstanceKind.list; | 2645 bool get isList => kind == M.InstanceKind.list; |
| 2669 bool get isMap => kind == M.InstanceKind.map; | 2646 bool get isMap => kind == M.InstanceKind.map; |
| 2670 bool get isTypedData { | 2647 bool get isTypedData { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2697 } | 2674 } |
| 2698 return (clazz.name == 'OutOfMemoryError') && clazz.library.isDart('core'); | 2675 return (clazz.name == 'OutOfMemoryError') && clazz.library.isDart('core'); |
| 2699 } | 2676 } |
| 2700 | 2677 |
| 2701 // TODO(turnidge): Is this properly backwards compatible when new | 2678 // TODO(turnidge): Is this properly backwards compatible when new |
| 2702 // instance kinds are added? | 2679 // instance kinds are added? |
| 2703 bool get isPlainInstance => kind == 'PlainInstance'; | 2680 bool get isPlainInstance => kind == 'PlainInstance'; |
| 2704 | 2681 |
| 2705 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); | 2682 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2706 | 2683 |
| 2707 void _update(ObservableMap map, bool mapIsRef) { | 2684 void _update(Map map, bool mapIsRef) { |
| 2708 // Extract full properties.1 | 2685 // Extract full properties.1 |
| 2709 _upgradeCollection(map, isolate); | 2686 _upgradeCollection(map, isolate); |
| 2710 super._update(map, mapIsRef); | 2687 super._update(map, mapIsRef); |
| 2711 | 2688 |
| 2712 kind = stringToInstanceKind(map['kind']); | 2689 kind = stringToInstanceKind(map['kind']); |
| 2713 valueAsString = map['valueAsString']; | 2690 valueAsString = map['valueAsString']; |
| 2714 // Coerce absence to false. | 2691 // Coerce absence to false. |
| 2715 valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true; | 2692 valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true; |
| 2716 closureFunction = map['closureFunction']; | 2693 closureFunction = map['closureFunction']; |
| 2717 closureContext = map['closureContext']; | 2694 closureContext = map['closureContext']; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2825 | 2802 |
| 2826 Future<ServiceObject> evaluate(String expression) { | 2803 Future<ServiceObject> evaluate(String expression) { |
| 2827 return isolate.eval(this, expression); | 2804 return isolate.eval(this, expression); |
| 2828 } | 2805 } |
| 2829 | 2806 |
| 2830 String toString() => 'Instance($shortName)'; | 2807 String toString() => 'Instance($shortName)'; |
| 2831 } | 2808 } |
| 2832 | 2809 |
| 2833 | 2810 |
| 2834 class Context extends HeapObject implements M.Context { | 2811 class Context extends HeapObject implements M.Context { |
| 2835 @observable Context parentContext; | 2812 Context parentContext; |
| 2836 @observable int length; | 2813 int length; |
| 2837 @observable Iterable<ContextElement> variables; | 2814 Iterable<ContextElement> variables; |
| 2838 | 2815 |
| 2839 Context._empty(ServiceObjectOwner owner) : super._empty(owner); | 2816 Context._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2840 | 2817 |
| 2841 void _update(ObservableMap map, bool mapIsRef) { | 2818 void _update(Map map, bool mapIsRef) { |
| 2842 // Extract full properties. | 2819 // Extract full properties. |
| 2843 _upgradeCollection(map, isolate); | 2820 _upgradeCollection(map, isolate); |
| 2844 super._update(map, mapIsRef); | 2821 super._update(map, mapIsRef); |
| 2845 | 2822 |
| 2846 length = map['length']; | 2823 length = map['length']; |
| 2847 parentContext = map['parent']; | 2824 parentContext = map['parent']; |
| 2848 | 2825 |
| 2849 if (mapIsRef) { | 2826 if (mapIsRef) { |
| 2850 return; | 2827 return; |
| 2851 } | 2828 } |
| 2852 | 2829 |
| 2853 variables = (map['variables'] ?? const []).map((element) => | 2830 variables = (map['variables'] ?? const []).map((element) => |
| 2854 new ContextElement(element)); | 2831 new ContextElement(element)); |
| 2855 | 2832 |
| 2856 // We are fully loaded. | 2833 // We are fully loaded. |
| 2857 _loaded = true; | 2834 _loaded = true; |
| 2858 } | 2835 } |
| 2859 | 2836 |
| 2860 String toString() => 'Context($length)'; | 2837 String toString() => 'Context($length)'; |
| 2861 } | 2838 } |
| 2862 | 2839 |
| 2863 class ContextElement extends M.ContextElement { | 2840 class ContextElement extends M.ContextElement { |
| 2864 final Guarded<Instance> value; | 2841 final Guarded<Instance> value; |
| 2865 | 2842 |
| 2866 ContextElement(ObservableMap map) | 2843 ContextElement(Map map) |
| 2867 : value = new Guarded<Instance>(map['value']); | 2844 : value = new Guarded<Instance>(map['value']); |
| 2868 } | 2845 } |
| 2869 | 2846 |
| 2870 M.FunctionKind stringToFunctionKind(String value) { | 2847 M.FunctionKind stringToFunctionKind(String value) { |
| 2871 switch(value) { | 2848 switch(value) { |
| 2872 case 'RegularFunction': return M.FunctionKind.regular; | 2849 case 'RegularFunction': return M.FunctionKind.regular; |
| 2873 case 'ClosureFunction': return M.FunctionKind.closure; | 2850 case 'ClosureFunction': return M.FunctionKind.closure; |
| 2874 case 'GetterFunction': return M.FunctionKind.getter; | 2851 case 'GetterFunction': return M.FunctionKind.getter; |
| 2875 case 'SetterFunction': return M.FunctionKind.setter; | 2852 case 'SetterFunction': return M.FunctionKind.setter; |
| 2876 case 'Constructor': return M.FunctionKind.constructor; | 2853 case 'Constructor': return M.FunctionKind.constructor; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2888 case 'Stub': return M.FunctionKind.stub; | 2865 case 'Stub': return M.FunctionKind.stub; |
| 2889 case 'Tag': return M.FunctionKind.tag; | 2866 case 'Tag': return M.FunctionKind.tag; |
| 2890 case 'SignatureFunction': return M.FunctionKind.signatureFunction; | 2867 case 'SignatureFunction': return M.FunctionKind.signatureFunction; |
| 2891 } | 2868 } |
| 2892 Logger.root.severe('Unrecognized function kind: $value'); | 2869 Logger.root.severe('Unrecognized function kind: $value'); |
| 2893 throw new FallThroughError(); | 2870 throw new FallThroughError(); |
| 2894 } | 2871 } |
| 2895 | 2872 |
| 2896 class ServiceFunction extends HeapObject implements M.Function { | 2873 class ServiceFunction extends HeapObject implements M.Function { |
| 2897 // owner is a Library, Class, or ServiceFunction. | 2874 // owner is a Library, Class, or ServiceFunction. |
| 2898 @observable M.ObjectRef dartOwner; | 2875 M.ObjectRef dartOwner; |
| 2899 @observable Library library; | 2876 Library library; |
| 2900 @observable bool isStatic; | 2877 bool isStatic; |
| 2901 @observable bool isConst; | 2878 bool isConst; |
| 2902 @observable SourceLocation location; | 2879 SourceLocation location; |
| 2903 @observable Code code; | 2880 Code code; |
| 2904 @observable Code unoptimizedCode; | 2881 Code unoptimizedCode; |
| 2905 @observable bool isOptimizable; | 2882 bool isOptimizable; |
| 2906 @observable bool isInlinable; | 2883 bool isInlinable; |
| 2907 @observable bool hasIntrinsic; | 2884 bool hasIntrinsic; |
| 2908 @observable bool isRecognized; | 2885 bool isRecognized; |
| 2909 @observable bool isNative; | 2886 bool isNative; |
| 2910 @observable M.FunctionKind kind; | 2887 M.FunctionKind kind; |
| 2911 @observable int deoptimizations; | 2888 int deoptimizations; |
| 2912 @observable String qualifiedName; | 2889 String qualifiedName; |
| 2913 @observable int usageCounter; | 2890 int usageCounter; |
| 2914 @observable bool isDart; | 2891 bool isDart; |
| 2915 @observable ProfileFunction profile; | 2892 ProfileFunction profile; |
| 2916 @observable Instance icDataArray; | 2893 Instance icDataArray; |
| 2917 @observable Field field; | 2894 Field field; |
| 2918 | 2895 |
| 2919 bool get immutable => false; | 2896 bool get immutable => false; |
| 2920 | 2897 |
| 2921 ServiceFunction._empty(ServiceObject owner) : super._empty(owner); | 2898 ServiceFunction._empty(ServiceObject owner) : super._empty(owner); |
| 2922 | 2899 |
| 2923 void _update(ObservableMap map, bool mapIsRef) { | 2900 void _update(Map map, bool mapIsRef) { |
| 2924 _upgradeCollection(map, isolate); | 2901 _upgradeCollection(map, isolate); |
| 2925 super._update(map, mapIsRef); | 2902 super._update(map, mapIsRef); |
| 2926 | 2903 |
| 2927 name = map['name']; | 2904 name = map['name']; |
| 2928 vmName = (map.containsKey('_vmName') ? map['_vmName'] : name); | 2905 vmName = (map.containsKey('_vmName') ? map['_vmName'] : name); |
| 2929 | 2906 |
| 2930 dartOwner = map['owner']; | 2907 dartOwner = map['owner']; |
| 2931 kind = stringToFunctionKind(map['_kind']); | 2908 kind = stringToFunctionKind(map['_kind']); |
| 2932 isDart = M.isDartFunction(kind); | 2909 isDart = M.isDartFunction(kind); |
| 2933 | 2910 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 throw new FallThroughError(); | 2973 throw new FallThroughError(); |
| 2997 } | 2974 } |
| 2998 | 2975 |
| 2999 class Sentinel extends ServiceObject implements M.Sentinel { | 2976 class Sentinel extends ServiceObject implements M.Sentinel { |
| 3000 | 2977 |
| 3001 M.SentinelKind kind; | 2978 M.SentinelKind kind; |
| 3002 String valueAsString; | 2979 String valueAsString; |
| 3003 | 2980 |
| 3004 Sentinel._empty(ServiceObjectOwner owner) : super._empty(owner); | 2981 Sentinel._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3005 | 2982 |
| 3006 void _update(ObservableMap map, bool mapIsRef) { | 2983 void _update(Map map, bool mapIsRef) { |
| 3007 // Extract full properties. | 2984 // Extract full properties. |
| 3008 _upgradeCollection(map, isolate); | 2985 _upgradeCollection(map, isolate); |
| 3009 | 2986 |
| 3010 kind = stringToSentinelKind(map['kind']); | 2987 kind = stringToSentinelKind(map['kind']); |
| 3011 valueAsString = map['valueAsString']; | 2988 valueAsString = map['valueAsString']; |
| 3012 _loaded = true; | 2989 _loaded = true; |
| 3013 } | 2990 } |
| 3014 | 2991 |
| 3015 String toString() => 'Sentinel($kind)'; | 2992 String toString() => 'Sentinel($kind)'; |
| 3016 String get shortName => valueAsString; | 2993 String get shortName => valueAsString; |
| 3017 } | 2994 } |
| 3018 | 2995 |
| 3019 class Field extends HeapObject implements M.Field { | 2996 class Field extends HeapObject implements M.Field { |
| 3020 // Library or Class. | 2997 // Library or Class. |
| 3021 @observable HeapObject dartOwner; | 2998 HeapObject dartOwner; |
| 3022 @observable Library library; | 2999 Library library; |
| 3023 @observable Instance declaredType; | 3000 Instance declaredType; |
| 3024 @observable bool isStatic; | 3001 bool isStatic; |
| 3025 @observable bool isFinal; | 3002 bool isFinal; |
| 3026 @observable bool isConst; | 3003 bool isConst; |
| 3027 @observable Instance staticValue; | 3004 Instance staticValue; |
| 3028 @observable String name; | 3005 String name; |
| 3029 @observable String vmName; | 3006 String vmName; |
| 3030 | 3007 |
| 3031 @observable bool guardNullable; | 3008 bool guardNullable; |
| 3032 M.GuardClassKind guardClassKind; | 3009 M.GuardClassKind guardClassKind; |
| 3033 @observable Class guardClass; | 3010 Class guardClass; |
| 3034 @observable String guardLength; | 3011 String guardLength; |
| 3035 @observable SourceLocation location; | 3012 SourceLocation location; |
| 3036 | 3013 |
| 3037 Field._empty(ServiceObjectOwner owner) : super._empty(owner); | 3014 Field._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3038 | 3015 |
| 3039 void _update(ObservableMap map, bool mapIsRef) { | 3016 void _update(Map map, bool mapIsRef) { |
| 3040 // Extract full properties. | 3017 // Extract full properties. |
| 3041 _upgradeCollection(map, isolate); | 3018 _upgradeCollection(map, isolate); |
| 3042 super._update(map, mapIsRef); | 3019 super._update(map, mapIsRef); |
| 3043 | 3020 |
| 3044 name = map['name']; | 3021 name = map['name']; |
| 3045 vmName = (map.containsKey('_vmName') ? map['_vmName'] : name); | 3022 vmName = (map.containsKey('_vmName') ? map['_vmName'] : name); |
| 3046 dartOwner = map['owner']; | 3023 dartOwner = map['owner']; |
| 3047 declaredType = map['declaredType']; | 3024 declaredType = map['declaredType']; |
| 3048 isStatic = map['static']; | 3025 isStatic = map['static']; |
| 3049 isFinal = map['final']; | 3026 isFinal = map['final']; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3080 | 3057 |
| 3081 guardLength = map['_guardLength']; | 3058 guardLength = map['_guardLength']; |
| 3082 location = map['location']; | 3059 location = map['location']; |
| 3083 _loaded = true; | 3060 _loaded = true; |
| 3084 } | 3061 } |
| 3085 | 3062 |
| 3086 String toString() => 'Field(${dartOwner.name}.$name)'; | 3063 String toString() => 'Field(${dartOwner.name}.$name)'; |
| 3087 } | 3064 } |
| 3088 | 3065 |
| 3089 | 3066 |
| 3090 class ScriptLine extends Observable { | 3067 class ScriptLine { |
| 3091 final Script script; | 3068 final Script script; |
| 3092 final int line; | 3069 final int line; |
| 3093 final String text; | 3070 final String text; |
| 3094 @observable Set<Breakpoint> breakpoints; | 3071 Set<Breakpoint> breakpoints; |
| 3095 | 3072 |
| 3096 ScriptLine(this.script, this.line, this.text); | 3073 ScriptLine(this.script, this.line, this.text); |
| 3097 | 3074 |
| 3098 bool get isBlank { | 3075 bool get isBlank { |
| 3099 return text.isEmpty || text.trim().isEmpty; | 3076 return text.isEmpty || text.trim().isEmpty; |
| 3100 } | 3077 } |
| 3101 | 3078 |
| 3102 bool _isTrivial = null; | 3079 bool _isTrivial = null; |
| 3103 bool get isTrivial { | 3080 bool get isTrivial { |
| 3104 if (_isTrivial == null) { | 3081 if (_isTrivial == null) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3214 | 3191 |
| 3215 /// The location of a local variable reference in a script. | 3192 /// The location of a local variable reference in a script. |
| 3216 class LocalVarLocation { | 3193 class LocalVarLocation { |
| 3217 final int line; | 3194 final int line; |
| 3218 final int column; | 3195 final int column; |
| 3219 final int endColumn; | 3196 final int endColumn; |
| 3220 LocalVarLocation(this.line, this.column, this.endColumn); | 3197 LocalVarLocation(this.line, this.column, this.endColumn); |
| 3221 } | 3198 } |
| 3222 | 3199 |
| 3223 class Script extends HeapObject implements M.Script { | 3200 class Script extends HeapObject implements M.Script { |
| 3224 final lines = new ObservableList<ScriptLine>(); | 3201 final lines = <ScriptLine>[]; |
| 3225 @observable String uri; | 3202 String uri; |
| 3226 @observable String kind; | 3203 String kind; |
| 3227 @observable DateTime loadTime; | 3204 DateTime loadTime; |
| 3228 @observable int firstTokenPos; | 3205 int firstTokenPos; |
| 3229 @observable int lastTokenPos; | 3206 int lastTokenPos; |
| 3230 @observable int lineOffset; | 3207 int lineOffset; |
| 3231 @observable int columnOffset; | 3208 int columnOffset; |
| 3232 @observable Library library; | 3209 Library library; |
| 3233 | 3210 |
| 3234 String source; | 3211 String source; |
| 3235 | 3212 |
| 3236 bool get immutable => true; | 3213 bool get immutable => true; |
| 3237 | 3214 |
| 3238 String _shortUri; | 3215 String _shortUri; |
| 3239 | 3216 |
| 3240 Script._empty(ServiceObjectOwner owner) : super._empty(owner); | 3217 Script._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3241 | 3218 |
| 3242 ScriptLine getLine(int line) { | 3219 ScriptLine getLine(int line) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3309 if (c == 95) return true; // Underscore | 3286 if (c == 95) return true; // Underscore |
| 3310 if (c == 36) return true; // Dollar | 3287 if (c == 36) return true; // Dollar |
| 3311 return false; | 3288 return false; |
| 3312 } | 3289 } |
| 3313 | 3290 |
| 3314 static bool _isIdentifierChar(int c) { | 3291 static bool _isIdentifierChar(int c) { |
| 3315 if (_isInitialIdentifierChar(c)) return true; | 3292 if (_isInitialIdentifierChar(c)) return true; |
| 3316 return c >= 48 && c <= 75; // Digit | 3293 return c >= 48 && c <= 75; // Digit |
| 3317 } | 3294 } |
| 3318 | 3295 |
| 3319 void _update(ObservableMap map, bool mapIsRef) { | 3296 void _update(Map map, bool mapIsRef) { |
| 3320 _upgradeCollection(map, isolate); | 3297 _upgradeCollection(map, isolate); |
| 3321 super._update(map, mapIsRef); | 3298 super._update(map, mapIsRef); |
| 3322 | 3299 |
| 3323 uri = map['uri']; | 3300 uri = map['uri']; |
| 3324 kind = map['_kind']; | 3301 kind = map['_kind']; |
| 3325 _shortUri = uri.substring(uri.lastIndexOf('/') + 1); | 3302 _shortUri = uri.substring(uri.lastIndexOf('/') + 1); |
| 3326 name = _shortUri; | 3303 name = _shortUri; |
| 3327 vmName = uri; | 3304 vmName = uri; |
| 3328 if (mapIsRef) { | 3305 if (mapIsRef) { |
| 3329 return; | 3306 return; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3385 lines.clear(); | 3362 lines.clear(); |
| 3386 Logger.root.info('Adding ${sourceLines.length} source lines for ${uri}'); | 3363 Logger.root.info('Adding ${sourceLines.length} source lines for ${uri}'); |
| 3387 for (var i = 0; i < sourceLines.length; i++) { | 3364 for (var i = 0; i < sourceLines.length; i++) { |
| 3388 lines.add(new ScriptLine(this, i + lineOffset + 1, sourceLines[i])); | 3365 lines.add(new ScriptLine(this, i + lineOffset + 1, sourceLines[i])); |
| 3389 } | 3366 } |
| 3390 for (var bpt in isolate.breakpoints.values) { | 3367 for (var bpt in isolate.breakpoints.values) { |
| 3391 if (bpt.location.script == this) { | 3368 if (bpt.location.script == this) { |
| 3392 _addBreakpoint(bpt); | 3369 _addBreakpoint(bpt); |
| 3393 } | 3370 } |
| 3394 } | 3371 } |
| 3395 | |
| 3396 // Notify any Observers that this Script's state has changed. | |
| 3397 notifyChange(null); | |
| 3398 } | 3372 } |
| 3399 | 3373 |
| 3400 void _addBreakpoint(Breakpoint bpt) { | 3374 void _addBreakpoint(Breakpoint bpt) { |
| 3401 var line; | 3375 var line; |
| 3402 if (bpt.location.tokenPos != null) { | 3376 if (bpt.location.tokenPos != null) { |
| 3403 line = tokenToLine(bpt.location.tokenPos); | 3377 line = tokenToLine(bpt.location.tokenPos); |
| 3404 } else { | 3378 } else { |
| 3405 UnresolvedSourceLocation loc = bpt.location; | 3379 UnresolvedSourceLocation loc = bpt.location; |
| 3406 line = loc.line; | 3380 line = loc.line; |
| 3407 } | 3381 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3539 scanLineForLocalVariableLocations(pattern, | 3513 scanLineForLocalVariableLocations(pattern, |
| 3540 name, | 3514 name, |
| 3541 lineContents, | 3515 lineContents, |
| 3542 line, | 3516 line, |
| 3543 0)); | 3517 0)); |
| 3544 } | 3518 } |
| 3545 return r; | 3519 return r; |
| 3546 } | 3520 } |
| 3547 } | 3521 } |
| 3548 | 3522 |
| 3549 class PcDescriptor extends Observable { | 3523 class PcDescriptor { |
| 3550 final int pcOffset; | 3524 final int pcOffset; |
| 3551 @reflectable final int deoptId; | 3525 final int deoptId; |
| 3552 @reflectable final int tokenPos; | 3526 final int tokenPos; |
| 3553 @reflectable final int tryIndex; | 3527 final int tryIndex; |
| 3554 @reflectable final String kind; | 3528 final String kind; |
| 3555 @observable Script script; | 3529 Script script; |
| 3556 @observable String formattedLine; | 3530 String formattedLine; |
| 3557 PcDescriptor(this.pcOffset, this.deoptId, this.tokenPos, this.tryIndex, | 3531 PcDescriptor(this.pcOffset, this.deoptId, this.tokenPos, this.tryIndex, |
| 3558 this.kind); | 3532 this.kind); |
| 3559 | 3533 |
| 3560 @reflectable String formattedDeoptId() { | 3534 String formattedDeoptId() { |
| 3561 if (deoptId == -1) { | 3535 if (deoptId == -1) { |
| 3562 return 'N/A'; | 3536 return 'N/A'; |
| 3563 } | 3537 } |
| 3564 return deoptId.toString(); | 3538 return deoptId.toString(); |
| 3565 } | 3539 } |
| 3566 | 3540 |
| 3567 @reflectable String formattedTokenPos() { | 3541 String formattedTokenPos() { |
| 3568 if (tokenPos == -1) { | 3542 if (tokenPos == -1) { |
| 3569 return ''; | 3543 return ''; |
| 3570 } | 3544 } |
| 3571 return tokenPos.toString(); | 3545 return tokenPos.toString(); |
| 3572 } | 3546 } |
| 3573 | 3547 |
| 3574 void processScript(Script script) { | 3548 void processScript(Script script) { |
| 3575 this.script = null; | 3549 this.script = null; |
| 3576 if (tokenPos == -1) { | 3550 if (tokenPos == -1) { |
| 3577 return; | 3551 return; |
| 3578 } | 3552 } |
| 3579 var line = script.tokenToLine(tokenPos); | 3553 var line = script.tokenToLine(tokenPos); |
| 3580 if (line == null) { | 3554 if (line == null) { |
| 3581 return; | 3555 return; |
| 3582 } | 3556 } |
| 3583 this.script = script; | 3557 this.script = script; |
| 3584 var scriptLine = script.getLine(line); | 3558 var scriptLine = script.getLine(line); |
| 3585 formattedLine = scriptLine.text; | 3559 formattedLine = scriptLine.text; |
| 3586 } | 3560 } |
| 3587 } | 3561 } |
| 3588 | 3562 |
| 3589 class PcDescriptors extends ServiceObject implements M.PcDescriptorsRef { | 3563 class PcDescriptors extends ServiceObject implements M.PcDescriptorsRef { |
| 3590 @observable Class clazz; | 3564 Class clazz; |
| 3591 @observable int size; | 3565 int size; |
| 3592 bool get immutable => true; | 3566 bool get immutable => true; |
| 3593 @reflectable final List<PcDescriptor> descriptors = | 3567 final List<PcDescriptor> descriptors = <PcDescriptor>[]; |
| 3594 new ObservableList<PcDescriptor>(); | |
| 3595 | 3568 |
| 3596 PcDescriptors._empty(ServiceObjectOwner owner) : super._empty(owner) { | 3569 PcDescriptors._empty(ServiceObjectOwner owner) : super._empty(owner) { |
| 3597 } | 3570 } |
| 3598 | 3571 |
| 3599 void _update(ObservableMap m, bool mapIsRef) { | 3572 void _update(Map m, bool mapIsRef) { |
| 3600 if (mapIsRef) { | 3573 if (mapIsRef) { |
| 3601 return; | 3574 return; |
| 3602 } | 3575 } |
| 3603 _upgradeCollection(m, isolate); | 3576 _upgradeCollection(m, isolate); |
| 3604 clazz = m['class']; | 3577 clazz = m['class']; |
| 3605 size = m['size']; | 3578 size = m['size']; |
| 3606 descriptors.clear(); | 3579 descriptors.clear(); |
| 3607 for (var descriptor in m['members']) { | 3580 for (var descriptor in m['members']) { |
| 3608 var pcOffset = int.parse(descriptor['pcOffset'], radix:16); | 3581 var pcOffset = int.parse(descriptor['pcOffset'], radix:16); |
| 3609 var deoptId = descriptor['deoptId']; | 3582 var deoptId = descriptor['deoptId']; |
| 3610 var tokenPos = descriptor['tokenPos']; | 3583 var tokenPos = descriptor['tokenPos']; |
| 3611 var tryIndex = descriptor['tryIndex']; | 3584 var tryIndex = descriptor['tryIndex']; |
| 3612 var kind = descriptor['kind'].trim(); | 3585 var kind = descriptor['kind'].trim(); |
| 3613 descriptors.add( | 3586 descriptors.add( |
| 3614 new PcDescriptor(pcOffset, deoptId, tokenPos, tryIndex, kind)); | 3587 new PcDescriptor(pcOffset, deoptId, tokenPos, tryIndex, kind)); |
| 3615 } | 3588 } |
| 3616 } | 3589 } |
| 3617 } | 3590 } |
| 3618 | 3591 |
| 3619 class LocalVarDescriptor extends Observable | 3592 class LocalVarDescriptor implements M.LocalVarDescriptorsRef { |
| 3620 implements M.LocalVarDescriptorsRef { | 3593 final String id; |
| 3621 @reflectable final String id; | 3594 final String name; |
| 3622 @reflectable final String name; | 3595 final int index; |
| 3623 @reflectable final int index; | 3596 final int beginPos; |
| 3624 @reflectable final int beginPos; | 3597 final int endPos; |
| 3625 @reflectable final int endPos; | 3598 final int scopeId; |
| 3626 @reflectable final int scopeId; | 3599 final String kind; |
| 3627 @reflectable final String kind; | |
| 3628 | 3600 |
| 3629 LocalVarDescriptor(this.id, this.name, this.index, this.beginPos, this.endPos, | 3601 LocalVarDescriptor(this.id, this.name, this.index, this.beginPos, this.endPos, |
| 3630 this.scopeId, this.kind); | 3602 this.scopeId, this.kind); |
| 3631 } | 3603 } |
| 3632 | 3604 |
| 3633 class LocalVarDescriptors extends ServiceObject { | 3605 class LocalVarDescriptors extends ServiceObject { |
| 3634 @observable Class clazz; | 3606 Class clazz; |
| 3635 @observable int size; | 3607 int size; |
| 3636 bool get immutable => true; | 3608 bool get immutable => true; |
| 3637 @reflectable final List<LocalVarDescriptor> descriptors = | 3609 final List<LocalVarDescriptor> descriptors = <LocalVarDescriptor>[]; |
| 3638 new ObservableList<LocalVarDescriptor>(); | |
| 3639 LocalVarDescriptors._empty(ServiceObjectOwner owner) : super._empty(owner); | 3610 LocalVarDescriptors._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3640 | 3611 |
| 3641 void _update(ObservableMap m, bool mapIsRef) { | 3612 void _update(Map m, bool mapIsRef) { |
| 3642 if (mapIsRef) { | 3613 if (mapIsRef) { |
| 3643 return; | 3614 return; |
| 3644 } | 3615 } |
| 3645 _upgradeCollection(m, isolate); | 3616 _upgradeCollection(m, isolate); |
| 3646 clazz = m['class']; | 3617 clazz = m['class']; |
| 3647 size = m['size']; | 3618 size = m['size']; |
| 3648 descriptors.clear(); | 3619 descriptors.clear(); |
| 3649 for (var descriptor in m['members']) { | 3620 for (var descriptor in m['members']) { |
| 3650 var id = descriptor['name']; | 3621 var id = descriptor['name']; |
| 3651 var name = descriptor['name']; | 3622 var name = descriptor['name']; |
| 3652 var index = descriptor['index']; | 3623 var index = descriptor['index']; |
| 3653 var beginPos = descriptor['beginPos']; | 3624 var beginPos = descriptor['beginPos']; |
| 3654 var endPos = descriptor['endPos']; | 3625 var endPos = descriptor['endPos']; |
| 3655 var scopeId = descriptor['scopeId']; | 3626 var scopeId = descriptor['scopeId']; |
| 3656 var kind = descriptor['kind'].trim(); | 3627 var kind = descriptor['kind'].trim(); |
| 3657 descriptors.add( | 3628 descriptors.add( |
| 3658 new LocalVarDescriptor(id, name, index, beginPos, endPos, scopeId, | 3629 new LocalVarDescriptor(id, name, index, beginPos, endPos, scopeId, |
| 3659 kind)); | 3630 kind)); |
| 3660 } | 3631 } |
| 3661 } | 3632 } |
| 3662 } | 3633 } |
| 3663 | 3634 |
| 3664 class ObjectPool extends HeapObject implements M.ObjectPool { | 3635 class ObjectPool extends HeapObject implements M.ObjectPool { |
| 3665 bool get immutable => false; | 3636 bool get immutable => false; |
| 3666 | 3637 |
| 3667 @observable int length; | 3638 int length; |
| 3668 @observable List<ObjectPoolEntry> entries; | 3639 List<ObjectPoolEntry> entries; |
| 3669 | 3640 |
| 3670 ObjectPool._empty(ServiceObjectOwner owner) : super._empty(owner); | 3641 ObjectPool._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3671 | 3642 |
| 3672 void _update(ObservableMap map, bool mapIsRef) { | 3643 void _update(Map map, bool mapIsRef) { |
| 3673 _upgradeCollection(map, isolate); | 3644 _upgradeCollection(map, isolate); |
| 3674 super._update(map, mapIsRef); | 3645 super._update(map, mapIsRef); |
| 3675 | 3646 |
| 3676 length = map['length']; | 3647 length = map['length']; |
| 3677 if (mapIsRef) { | 3648 if (mapIsRef) { |
| 3678 return; | 3649 return; |
| 3679 } | 3650 } |
| 3680 entries = map['_entries'].map((map) => new ObjectPoolEntry(map)); | 3651 entries = map['_entries'].map((map) => new ObjectPoolEntry(map)); |
| 3681 } | 3652 } |
| 3682 } | 3653 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3712 return M.ObjectPoolEntryKind.object; | 3683 return M.ObjectPoolEntryKind.object; |
| 3713 case 'Immediate': | 3684 case 'Immediate': |
| 3714 return M.ObjectPoolEntryKind.immediate; | 3685 return M.ObjectPoolEntryKind.immediate; |
| 3715 case 'NativeEntry': | 3686 case 'NativeEntry': |
| 3716 return M.ObjectPoolEntryKind.nativeEntry; | 3687 return M.ObjectPoolEntryKind.nativeEntry; |
| 3717 } | 3688 } |
| 3718 throw new Exception('Unknown ObjectPoolEntryKind ($kind)'); | 3689 throw new Exception('Unknown ObjectPoolEntryKind ($kind)'); |
| 3719 } | 3690 } |
| 3720 | 3691 |
| 3721 class ICData extends HeapObject implements M.ICData { | 3692 class ICData extends HeapObject implements M.ICData { |
| 3722 @observable HeapObject dartOwner; | 3693 HeapObject dartOwner; |
| 3723 @observable String selector; | 3694 String selector; |
| 3724 @observable Instance argumentsDescriptor; | 3695 Instance argumentsDescriptor; |
| 3725 @observable Instance entries; | 3696 Instance entries; |
| 3726 | 3697 |
| 3727 bool get immutable => false; | 3698 bool get immutable => false; |
| 3728 | 3699 |
| 3729 ICData._empty(ServiceObjectOwner owner) : super._empty(owner); | 3700 ICData._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3730 | 3701 |
| 3731 void _update(ObservableMap map, bool mapIsRef) { | 3702 void _update(Map map, bool mapIsRef) { |
| 3732 _upgradeCollection(map, isolate); | 3703 _upgradeCollection(map, isolate); |
| 3733 super._update(map, mapIsRef); | 3704 super._update(map, mapIsRef); |
| 3734 | 3705 |
| 3735 dartOwner = map['_owner']; | 3706 dartOwner = map['_owner']; |
| 3736 selector = map['_selector']; | 3707 selector = map['_selector']; |
| 3737 if (mapIsRef) { | 3708 if (mapIsRef) { |
| 3738 return; | 3709 return; |
| 3739 } | 3710 } |
| 3740 argumentsDescriptor = map['_argumentsDescriptor']; | 3711 argumentsDescriptor = map['_argumentsDescriptor']; |
| 3741 entries = map['_entries']; | 3712 entries = map['_entries']; |
| 3742 } | 3713 } |
| 3743 } | 3714 } |
| 3744 | 3715 |
| 3745 class TypeArguments extends HeapObject implements M.TypeArguments { | 3716 class TypeArguments extends HeapObject implements M.TypeArguments { |
| 3746 HeapObject dartOwner; | 3717 HeapObject dartOwner; |
| 3747 String name; | 3718 String name; |
| 3748 Iterable<Instance> types; | 3719 Iterable<Instance> types; |
| 3749 | 3720 |
| 3750 TypeArguments._empty(ServiceObjectOwner owner) : super._empty(owner); | 3721 TypeArguments._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3751 | 3722 |
| 3752 void _update(ObservableMap map, bool mapIsRef) { | 3723 void _update(Map map, bool mapIsRef) { |
| 3753 _upgradeCollection(map, isolate); | 3724 _upgradeCollection(map, isolate); |
| 3754 super._update(map, mapIsRef); | 3725 super._update(map, mapIsRef); |
| 3755 | 3726 |
| 3756 dartOwner = map['_owner']; | 3727 dartOwner = map['_owner']; |
| 3757 name = map['name']; | 3728 name = map['name']; |
| 3758 if (mapIsRef) { | 3729 if (mapIsRef) { |
| 3759 return; | 3730 return; |
| 3760 } | 3731 } |
| 3761 types = map['types']; | 3732 types = map['types']; |
| 3762 } | 3733 } |
| 3763 } | 3734 } |
| 3764 | 3735 |
| 3765 class InstanceSet extends HeapObject implements M.InstanceSet { | 3736 class InstanceSet extends HeapObject implements M.InstanceSet { |
| 3766 HeapObject dartOwner; | 3737 HeapObject dartOwner; |
| 3767 int count; | 3738 int count; |
| 3768 Iterable<HeapObject> samples; | 3739 Iterable<HeapObject> samples; |
| 3769 | 3740 |
| 3770 InstanceSet._empty(ServiceObjectOwner owner) : super._empty(owner); | 3741 InstanceSet._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3771 | 3742 |
| 3772 void _update(ObservableMap map, bool mapIsRef) { | 3743 void _update(Map map, bool mapIsRef) { |
| 3773 _upgradeCollection(map, isolate); | 3744 _upgradeCollection(map, isolate); |
| 3774 super._update(map, mapIsRef); | 3745 super._update(map, mapIsRef); |
| 3775 | 3746 |
| 3776 if (mapIsRef) { | 3747 if (mapIsRef) { |
| 3777 return; | 3748 return; |
| 3778 } | 3749 } |
| 3779 count = map['totalCount']; | 3750 count = map['totalCount']; |
| 3780 samples = map['samples']; | 3751 samples = map['samples']; |
| 3781 } | 3752 } |
| 3782 } | 3753 } |
| 3783 | 3754 |
| 3784 class MegamorphicCache extends HeapObject implements M.MegamorphicCache { | 3755 class MegamorphicCache extends HeapObject implements M.MegamorphicCache { |
| 3785 @observable int mask; | 3756 int mask; |
| 3786 @observable Instance buckets; | 3757 Instance buckets; |
| 3787 @observable String selector; | 3758 String selector; |
| 3788 @observable Instance argumentsDescriptor; | 3759 Instance argumentsDescriptor; |
| 3789 | 3760 |
| 3790 bool get immutable => false; | 3761 bool get immutable => false; |
| 3791 | 3762 |
| 3792 MegamorphicCache._empty(ServiceObjectOwner owner) : super._empty(owner); | 3763 MegamorphicCache._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3793 | 3764 |
| 3794 void _update(ObservableMap map, bool mapIsRef) { | 3765 void _update(Map map, bool mapIsRef) { |
| 3795 _upgradeCollection(map, isolate); | 3766 _upgradeCollection(map, isolate); |
| 3796 super._update(map, mapIsRef); | 3767 super._update(map, mapIsRef); |
| 3797 | 3768 |
| 3798 selector = map['_selector']; | 3769 selector = map['_selector']; |
| 3799 if (mapIsRef) { | 3770 if (mapIsRef) { |
| 3800 return; | 3771 return; |
| 3801 } | 3772 } |
| 3802 | 3773 |
| 3803 mask = map['_mask']; | 3774 mask = map['_mask']; |
| 3804 buckets = map['_buckets']; | 3775 buckets = map['_buckets']; |
| 3805 argumentsDescriptor = map['_argumentsDescriptor']; | 3776 argumentsDescriptor = map['_argumentsDescriptor']; |
| 3806 } | 3777 } |
| 3807 } | 3778 } |
| 3808 | 3779 |
| 3809 class TokenStream extends HeapObject implements M.TokenStreamRef { | 3780 class TokenStream extends HeapObject implements M.TokenStreamRef { |
| 3810 bool get immutable => true; | 3781 bool get immutable => true; |
| 3811 | 3782 |
| 3812 @observable String privateKey; | 3783 String privateKey; |
| 3813 | 3784 |
| 3814 TokenStream._empty(ServiceObjectOwner owner) : super._empty(owner); | 3785 TokenStream._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3815 | 3786 |
| 3816 void _update(ObservableMap map, bool mapIsRef) { | 3787 void _update(Map map, bool mapIsRef) { |
| 3817 _upgradeCollection(map, isolate); | 3788 _upgradeCollection(map, isolate); |
| 3818 super._update(map, mapIsRef); | 3789 super._update(map, mapIsRef); |
| 3819 | 3790 |
| 3820 if (mapIsRef) { | 3791 if (mapIsRef) { |
| 3821 return; | 3792 return; |
| 3822 } | 3793 } |
| 3823 privateKey = map['privateKey']; | 3794 privateKey = map['privateKey']; |
| 3824 } | 3795 } |
| 3825 } | 3796 } |
| 3826 | 3797 |
| 3827 class CodeInstruction extends Observable { | 3798 class CodeInstruction { |
| 3828 @observable final int address; | 3799 final int address; |
| 3829 @observable final int pcOffset; | 3800 final int pcOffset; |
| 3830 @observable final String machine; | 3801 final String machine; |
| 3831 @observable final String human; | 3802 final String human; |
| 3832 @observable final ServiceObject object; | 3803 final ServiceObject object; |
| 3833 @observable CodeInstruction jumpTarget; | 3804 CodeInstruction jumpTarget; |
| 3834 @reflectable List<PcDescriptor> descriptors = | 3805 List<PcDescriptor> descriptors = <PcDescriptor>[]; |
| 3835 new ObservableList<PcDescriptor>(); | |
| 3836 | 3806 |
| 3837 CodeInstruction(this.address, | 3807 CodeInstruction(this.address, |
| 3838 this.pcOffset, | 3808 this.pcOffset, |
| 3839 this.machine, | 3809 this.machine, |
| 3840 this.human, | 3810 this.human, |
| 3841 this.object); | 3811 this.object); |
| 3842 | 3812 |
| 3843 @reflectable bool get isComment => address == 0; | 3813 bool get isComment => address == 0; |
| 3844 @reflectable bool get hasDescriptors => descriptors.length > 0; | 3814 bool get hasDescriptors => descriptors.length > 0; |
| 3845 | 3815 |
| 3846 bool _isJumpInstruction() { | 3816 bool _isJumpInstruction() { |
| 3847 return human.startsWith('j'); | 3817 return human.startsWith('j'); |
| 3848 } | 3818 } |
| 3849 | 3819 |
| 3850 int _getJumpAddress() { | 3820 int _getJumpAddress() { |
| 3851 assert(_isJumpInstruction()); | 3821 assert(_isJumpInstruction()); |
| 3852 var chunks = human.split(' '); | 3822 var chunks = human.split(' '); |
| 3853 if (chunks.length != 2) { | 3823 if (chunks.length != 2) { |
| 3854 // We expect jump instructions to be of the form 'j.. address'. | 3824 // We expect jump instructions to be of the form 'j.. address'. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3906 | 3876 |
| 3907 class CodeInlineInterval { | 3877 class CodeInlineInterval { |
| 3908 final int start; | 3878 final int start; |
| 3909 final int end; | 3879 final int end; |
| 3910 final List<ServiceFunction> functions = new List<ServiceFunction>(); | 3880 final List<ServiceFunction> functions = new List<ServiceFunction>(); |
| 3911 bool contains(int pc) => (pc >= start) && (pc < end); | 3881 bool contains(int pc) => (pc >= start) && (pc < end); |
| 3912 CodeInlineInterval(this.start, this.end); | 3882 CodeInlineInterval(this.start, this.end); |
| 3913 } | 3883 } |
| 3914 | 3884 |
| 3915 class Code extends HeapObject implements M.Code { | 3885 class Code extends HeapObject implements M.Code { |
| 3916 @observable M.CodeKind kind; | 3886 M.CodeKind kind; |
| 3917 @observable ObjectPool objectPool; | 3887 ObjectPool objectPool; |
| 3918 @observable ServiceFunction function; | 3888 ServiceFunction function; |
| 3919 @observable Script script; | 3889 Script script; |
| 3920 @observable bool isOptimized; | 3890 bool isOptimized; |
| 3921 @observable bool hasIntrinsic; | 3891 bool hasIntrinsic; |
| 3922 @observable bool isNative; | 3892 bool isNative; |
| 3923 | 3893 |
| 3924 @reflectable int startAddress = 0; | 3894 int startAddress = 0; |
| 3925 @reflectable int endAddress = 0; | 3895 int endAddress = 0; |
| 3926 @reflectable final instructions = new ObservableList<CodeInstruction>(); | 3896 final instructions = <CodeInstruction>[]; |
| 3927 List<CodeInstruction> instructionsByAddressOffset; | 3897 List<CodeInstruction> instructionsByAddressOffset; |
| 3928 | 3898 |
| 3929 @observable ProfileCode profile; | 3899 ProfileCode profile; |
| 3930 final List<CodeInlineInterval> inlineIntervals = | 3900 final List<CodeInlineInterval> inlineIntervals = <CodeInlineInterval>[]; |
| 3931 new List<CodeInlineInterval>(); | 3901 final List<ServiceFunction> inlinedFunctions = <ServiceFunction>[]; |
| 3932 final ObservableList<ServiceFunction> inlinedFunctions = | |
| 3933 new ObservableList<ServiceFunction>(); | |
| 3934 | 3902 |
| 3935 bool get immutable => true; | 3903 bool get immutable => true; |
| 3936 | 3904 |
| 3937 Code._empty(ServiceObjectOwner owner) : super._empty(owner); | 3905 Code._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 3938 | 3906 |
| 3939 void _updateDescriptors(Script script) { | 3907 void _updateDescriptors(Script script) { |
| 3940 this.script = script; | 3908 this.script = script; |
| 3941 for (var instruction in instructions) { | 3909 for (var instruction in instructions) { |
| 3942 for (var descriptor in instruction.descriptors) { | 3910 for (var descriptor in instruction.descriptors) { |
| 3943 descriptor.processScript(script); | 3911 descriptor.processScript(script); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3978 /// exception. | 3946 /// exception. |
| 3979 Future<ServiceObject> reload({int count: kDefaultFieldLimit}) { | 3947 Future<ServiceObject> reload({int count: kDefaultFieldLimit}) { |
| 3980 assert(kind != null); | 3948 assert(kind != null); |
| 3981 if (isDartCode) { | 3949 if (isDartCode) { |
| 3982 // We only reload Dart code. | 3950 // We only reload Dart code. |
| 3983 return super.reload(count: count); | 3951 return super.reload(count: count); |
| 3984 } | 3952 } |
| 3985 return new Future.value(this); | 3953 return new Future.value(this); |
| 3986 } | 3954 } |
| 3987 | 3955 |
| 3988 void _update(ObservableMap m, bool mapIsRef) { | 3956 void _update(Map m, bool mapIsRef) { |
| 3989 name = m['name']; | 3957 name = m['name']; |
| 3990 vmName = (m.containsKey('_vmName') ? m['_vmName'] : name); | 3958 vmName = (m.containsKey('_vmName') ? m['_vmName'] : name); |
| 3991 isOptimized = m['_optimized']; | 3959 isOptimized = m['_optimized']; |
| 3992 kind = stringToCodeKind(m['kind']); | 3960 kind = stringToCodeKind(m['kind']); |
| 3993 hasIntrinsic = m['_intrinsic']; | 3961 hasIntrinsic = m['_intrinsic']; |
| 3994 isNative = m['_native']; | 3962 isNative = m['_native']; |
| 3995 if (mapIsRef) { | 3963 if (mapIsRef) { |
| 3996 return; | 3964 return; |
| 3997 } | 3965 } |
| 3998 _loaded = true; | 3966 _loaded = true; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4057 if (inline_id < 0) { | 4025 if (inline_id < 0) { |
| 4058 continue; | 4026 continue; |
| 4059 } | 4027 } |
| 4060 var function = inlinedFunctionsTable[inline_id]; | 4028 var function = inlinedFunctionsTable[inline_id]; |
| 4061 codeInlineInterval.functions.add(function); | 4029 codeInlineInterval.functions.add(function); |
| 4062 } | 4030 } |
| 4063 inlineIntervals.add(codeInlineInterval); | 4031 inlineIntervals.add(codeInlineInterval); |
| 4064 } | 4032 } |
| 4065 } | 4033 } |
| 4066 | 4034 |
| 4067 @observable bool hasDisassembly = false; | 4035 bool hasDisassembly = false; |
| 4068 | 4036 |
| 4069 void _processDisassembly(List disassembly) { | 4037 void _processDisassembly(List disassembly) { |
| 4070 assert(disassembly != null); | 4038 assert(disassembly != null); |
| 4071 instructions.clear(); | 4039 instructions.clear(); |
| 4072 instructionsByAddressOffset = new List(endAddress - startAddress); | 4040 instructionsByAddressOffset = new List(endAddress - startAddress); |
| 4073 | 4041 |
| 4074 assert((disassembly.length % 4) == 0); | 4042 assert((disassembly.length % 4) == 0); |
| 4075 for (var i = 0; i < disassembly.length; i += 4) { | 4043 for (var i = 0; i < disassembly.length; i += 4) { |
| 4076 var address = 0; // Assume code comment. | 4044 var address = 0; // Assume code comment. |
| 4077 var machine = disassembly[i + 1]; | 4045 var machine = disassembly[i + 1]; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4120 'Could not find instruction with pc descriptor address: $address'); | 4088 'Could not find instruction with pc descriptor address: $address'); |
| 4121 } | 4089 } |
| 4122 } | 4090 } |
| 4123 } | 4091 } |
| 4124 | 4092 |
| 4125 /// Returns true if [address] is contained inside [this]. | 4093 /// Returns true if [address] is contained inside [this]. |
| 4126 bool contains(int address) { | 4094 bool contains(int address) { |
| 4127 return (address >= startAddress) && (address < endAddress); | 4095 return (address >= startAddress) && (address < endAddress); |
| 4128 } | 4096 } |
| 4129 | 4097 |
| 4130 @reflectable bool get isDartCode => (kind == M.CodeKind.dart) || | 4098 bool get isDartCode => (kind == M.CodeKind.dart) || |
| 4131 (kind == M.CodeKind.stub); | 4099 (kind == M.CodeKind.stub); |
| 4132 | 4100 |
| 4133 String toString() => 'Code($kind, $name)'; | 4101 String toString() => 'Code($kind, $name)'; |
| 4134 } | 4102 } |
| 4135 | 4103 |
| 4136 | 4104 |
| 4137 class SocketKind { | 4105 class SocketKind { |
| 4138 final _value; | 4106 final _value; |
| 4139 const SocketKind._internal(this._value); | 4107 const SocketKind._internal(this._value); |
| 4140 String toString() => '$_value'; | 4108 String toString() => '$_value'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4153 throw new FallThroughError(); | 4121 throw new FallThroughError(); |
| 4154 } | 4122 } |
| 4155 static const Listening = const SocketKind._internal('Listening'); | 4123 static const Listening = const SocketKind._internal('Listening'); |
| 4156 static const Normal = const SocketKind._internal('Normal'); | 4124 static const Normal = const SocketKind._internal('Normal'); |
| 4157 static const Pipe = const SocketKind._internal('Pipe'); | 4125 static const Pipe = const SocketKind._internal('Pipe'); |
| 4158 static const Internal = const SocketKind._internal('Internal'); | 4126 static const Internal = const SocketKind._internal('Internal'); |
| 4159 } | 4127 } |
| 4160 | 4128 |
| 4161 /// A snapshot of statistics associated with a [Socket]. | 4129 /// A snapshot of statistics associated with a [Socket]. |
| 4162 class SocketStats { | 4130 class SocketStats { |
| 4163 @reflectable final int bytesRead; | 4131 final int bytesRead; |
| 4164 @reflectable final int bytesWritten; | 4132 final int bytesWritten; |
| 4165 @reflectable final int readCalls; | 4133 final int readCalls; |
| 4166 @reflectable final int writeCalls; | 4134 final int writeCalls; |
| 4167 @reflectable final int available; | 4135 final int available; |
| 4168 | 4136 |
| 4169 SocketStats(this.bytesRead, this.bytesWritten, | 4137 SocketStats(this.bytesRead, this.bytesWritten, |
| 4170 this.readCalls, this.writeCalls, | 4138 this.readCalls, this.writeCalls, |
| 4171 this.available); | 4139 this.available); |
| 4172 } | 4140 } |
| 4173 | 4141 |
| 4174 /// A peer to a Socket in dart:io. Sockets can represent network sockets or | 4142 /// A peer to a Socket in dart:io. Sockets can represent network sockets or |
| 4175 /// OS pipes. Each socket is owned by another ServceObject, for example, | 4143 /// OS pipes. Each socket is owned by another ServceObject, for example, |
| 4176 /// a process or an HTTP server. | 4144 /// a process or an HTTP server. |
| 4177 class Socket extends ServiceObject { | 4145 class Socket extends ServiceObject { |
| 4178 Socket._empty(ServiceObjectOwner owner) : super._empty(owner); | 4146 Socket._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 4179 | 4147 |
| 4180 ServiceObject socketOwner; | 4148 ServiceObject socketOwner; |
| 4181 | 4149 |
| 4182 @reflectable bool get isPipe => (kind == SocketKind.Pipe); | 4150 bool get isPipe => (kind == SocketKind.Pipe); |
| 4183 | 4151 |
| 4184 @observable SocketStats latest; | 4152 SocketStats latest; |
| 4185 @observable SocketStats previous; | 4153 SocketStats previous; |
| 4186 | 4154 |
| 4187 @observable SocketKind kind; | 4155 SocketKind kind; |
| 4188 | 4156 |
| 4189 @observable String protocol = ''; | 4157 String protocol = ''; |
| 4190 | 4158 |
| 4191 @observable bool readClosed = false; | 4159 bool readClosed = false; |
| 4192 @observable bool writeClosed = false; | 4160 bool writeClosed = false; |
| 4193 @observable bool closing = false; | 4161 bool closing = false; |
| 4194 | 4162 |
| 4195 /// Listening for connections. | 4163 /// Listening for connections. |
| 4196 @observable bool listening = false; | 4164 bool listening = false; |
| 4197 | 4165 |
| 4198 @observable int fd; | 4166 int fd; |
| 4199 | 4167 |
| 4200 @observable String localAddress; | 4168 String localAddress; |
| 4201 @observable int localPort; | 4169 int localPort; |
| 4202 @observable String remoteAddress; | 4170 String remoteAddress; |
| 4203 @observable int remotePort; | 4171 int remotePort; |
| 4204 | 4172 |
| 4205 // Updates internal state from [map]. [map] can be a reference. | 4173 // Updates internal state from [map]. [map] can be a reference. |
| 4206 void _update(ObservableMap map, bool mapIsRef) { | 4174 void _update(Map map, bool mapIsRef) { |
| 4207 name = map['name']; | 4175 name = map['name']; |
| 4208 vmName = map['name']; | 4176 vmName = map['name']; |
| 4209 | 4177 |
| 4210 kind = SocketKind.fromString(map['kind']); | 4178 kind = SocketKind.fromString(map['kind']); |
| 4211 | 4179 |
| 4212 if (mapIsRef) { | 4180 if (mapIsRef) { |
| 4213 return; | 4181 return; |
| 4214 } | 4182 } |
| 4215 | 4183 |
| 4216 _loaded = true; | 4184 _loaded = true; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4233 socketOwner = map['owner']; | 4201 socketOwner = map['owner']; |
| 4234 } | 4202 } |
| 4235 } | 4203 } |
| 4236 | 4204 |
| 4237 class ServiceMetric extends ServiceObject implements M.Metric { | 4205 class ServiceMetric extends ServiceObject implements M.Metric { |
| 4238 ServiceMetric._empty(ServiceObjectOwner owner) : super._empty(owner) { | 4206 ServiceMetric._empty(ServiceObjectOwner owner) : super._empty(owner) { |
| 4239 } | 4207 } |
| 4240 | 4208 |
| 4241 bool get immutable => false; | 4209 bool get immutable => false; |
| 4242 | 4210 |
| 4243 Future<ObservableMap> _fetchDirect({int count: kDefaultFieldLimit}) { | 4211 Future<Map> _fetchDirect({int count: kDefaultFieldLimit}) { |
| 4244 assert(owner is Isolate); | 4212 assert(owner is Isolate); |
| 4245 return isolate.invokeRpcNoUpgrade('_getIsolateMetric', { 'metricId': id }); | 4213 return isolate.invokeRpcNoUpgrade('_getIsolateMetric', { 'metricId': id }); |
| 4246 } | 4214 } |
| 4247 | 4215 |
| 4248 @observable String description; | 4216 String description; |
| 4249 @observable double value = 0.0; | 4217 double value = 0.0; |
| 4250 // Only a guage has a non-null min and max. | 4218 // Only a guage has a non-null min and max. |
| 4251 @observable double min; | 4219 double min; |
| 4252 @observable double max; | 4220 double max; |
| 4253 | 4221 |
| 4254 bool get isGauge => (min != null) && (max != null); | 4222 bool get isGauge => (min != null) && (max != null); |
| 4255 | 4223 |
| 4256 void _update(ObservableMap map, bool mapIsRef) { | 4224 void _update(Map map, bool mapIsRef) { |
| 4257 name = map['name']; | 4225 name = map['name']; |
| 4258 description = map['description']; | 4226 description = map['description']; |
| 4259 vmName = map['name']; | 4227 vmName = map['name']; |
| 4260 value = map['value']; | 4228 value = map['value']; |
| 4261 min = map['min']; | 4229 min = map['min']; |
| 4262 max = map['max']; | 4230 max = map['max']; |
| 4263 } | 4231 } |
| 4264 | 4232 |
| 4265 String toString() => "ServiceMetric($_id)"; | 4233 String toString() => "ServiceMetric($_id)"; |
| 4266 } | 4234 } |
| 4267 | 4235 |
| 4268 class Frame extends ServiceObject implements M.Frame { | 4236 class Frame extends ServiceObject implements M.Frame { |
| 4269 @observable int index; | 4237 int index; |
| 4270 @observable ServiceFunction function; | 4238 ServiceFunction function; |
| 4271 @observable SourceLocation location; | 4239 SourceLocation location; |
| 4272 @observable Code code; | 4240 Code code; |
| 4273 @observable List<ServiceMap> variables = new ObservableList<ServiceMap>(); | 4241 List<ServiceMap> variables = <ServiceMap>[]; |
| 4274 | 4242 |
| 4275 Frame._empty(ServiceObject owner) : super._empty(owner); | 4243 Frame._empty(ServiceObject owner) : super._empty(owner); |
| 4276 | 4244 |
| 4277 void _update(ObservableMap map, bool mapIsRef) { | 4245 void _update(Map map, bool mapIsRef) { |
| 4278 assert(!mapIsRef); | 4246 assert(!mapIsRef); |
| 4279 _loaded = true; | 4247 _loaded = true; |
| 4280 _upgradeCollection(map, owner); | 4248 _upgradeCollection(map, owner); |
| 4281 this.index = map['index']; | 4249 this.index = map['index']; |
| 4282 this.function = map['function']; | 4250 this.function = map['function']; |
| 4283 this.location = map['location']; | 4251 this.location = map['location']; |
| 4284 this.code = map['code']; | 4252 this.code = map['code']; |
| 4285 this.variables = map['vars']; | 4253 this.variables = map['vars']; |
| 4286 } | 4254 } |
| 4287 | 4255 |
| 4288 String toString() => "Frame(${function.qualifiedName} $location)"; | 4256 String toString() => "Frame(${function.qualifiedName} $location)"; |
| 4289 } | 4257 } |
| 4290 | 4258 |
| 4291 | 4259 |
| 4292 class ServiceMessage extends ServiceObject { | 4260 class ServiceMessage extends ServiceObject { |
| 4293 @observable int index; | 4261 int index; |
| 4294 @observable String messageObjectId; | 4262 String messageObjectId; |
| 4295 @observable int size; | 4263 int size; |
| 4296 @observable ServiceFunction handler; | 4264 ServiceFunction handler; |
| 4297 @observable SourceLocation location; | 4265 SourceLocation location; |
| 4298 | 4266 |
| 4299 ServiceMessage._empty(ServiceObject owner) : super._empty(owner); | 4267 ServiceMessage._empty(ServiceObject owner) : super._empty(owner); |
| 4300 | 4268 |
| 4301 void _update(ObservableMap map, bool mapIsRef) { | 4269 void _update(Map map, bool mapIsRef) { |
| 4302 assert(!mapIsRef); | 4270 assert(!mapIsRef); |
| 4303 _loaded = true; | 4271 _loaded = true; |
| 4304 _upgradeCollection(map, owner); | 4272 _upgradeCollection(map, owner); |
| 4305 this.messageObjectId = map['messageObjectId']; | 4273 this.messageObjectId = map['messageObjectId']; |
| 4306 this.index = map['index']; | 4274 this.index = map['index']; |
| 4307 this.size = map['size']; | 4275 this.size = map['size']; |
| 4308 this.handler = map['handler']; | 4276 this.handler = map['handler']; |
| 4309 this.location = map['location']; | 4277 this.location = map['location']; |
| 4310 } | 4278 } |
| 4311 } | 4279 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4348 } | 4316 } |
| 4349 } | 4317 } |
| 4350 } | 4318 } |
| 4351 } | 4319 } |
| 4352 return result; | 4320 return result; |
| 4353 } | 4321 } |
| 4354 | 4322 |
| 4355 | 4323 |
| 4356 // Returns true if [map] is a service map. i.e. it has the following keys: | 4324 // Returns true if [map] is a service map. i.e. it has the following keys: |
| 4357 // 'id' and a 'type'. | 4325 // 'id' and a 'type'. |
| 4358 bool _isServiceMap(ObservableMap m) { | 4326 bool _isServiceMap(Map m) { |
| 4359 return (m != null) && (m['type'] != null); | 4327 return (m != null) && (m['type'] != null); |
| 4360 } | 4328 } |
| 4361 | 4329 |
| 4362 bool _hasRef(String type) => type.startsWith('@'); | 4330 bool _hasRef(String type) => type.startsWith('@'); |
| 4363 String _stripRef(String type) => (_hasRef(type) ? type.substring(1) : type); | 4331 String _stripRef(String type) => (_hasRef(type) ? type.substring(1) : type); |
| 4364 | 4332 |
| 4365 /// Recursively upgrades all [ServiceObject]s inside [collection] which must | 4333 /// Recursively upgrades all [ServiceObject]s inside [collection] which must |
| 4366 /// be an [ObservableMap] or an [ObservableList]. Upgraded elements will be | 4334 /// be an [ObservableMap] or an [ObservableList]. Upgraded elements will be |
| 4367 /// associated with [vm] and [isolate]. | 4335 /// associated with [vm] and [isolate]. |
| 4368 void _upgradeCollection(collection, ServiceObjectOwner owner) { | 4336 void _upgradeCollection(collection, ServiceObjectOwner owner) { |
| 4369 if (collection is ServiceMap) { | 4337 if (collection is ServiceMap) { |
| 4370 return; | 4338 return; |
| 4371 } | 4339 } |
| 4372 if (collection is ObservableMap) { | 4340 if (collection is Map) { |
| 4373 _upgradeObservableMap(collection, owner); | 4341 _upgradeMap(collection, owner); |
| 4374 } else if (collection is ObservableList) { | 4342 } else if (collection is List) { |
| 4375 _upgradeObservableList(collection, owner); | 4343 _upgradeList(collection, owner); |
| 4376 } | 4344 } |
| 4377 } | 4345 } |
| 4378 | 4346 |
| 4379 void _upgradeObservableMap(ObservableMap map, ServiceObjectOwner owner) { | 4347 void _upgradeMap(Map map, ServiceObjectOwner owner) { |
| 4380 map.forEach((k, v) { | 4348 map.forEach((k, v) { |
| 4381 if ((v is ObservableMap) && _isServiceMap(v)) { | 4349 if ((v is Map) && _isServiceMap(v)) { |
| 4382 map[k] = owner.getFromMap(v); | 4350 map[k] = owner.getFromMap(v); |
| 4383 } else if (v is ObservableList) { | 4351 } else if (v is List) { |
| 4384 _upgradeObservableList(v, owner); | 4352 _upgradeList(v, owner); |
| 4385 } else if (v is ObservableMap) { | 4353 } else if (v is Map) { |
| 4386 _upgradeObservableMap(v, owner); | 4354 _upgradeMap(v, owner); |
| 4387 } | 4355 } |
| 4388 }); | 4356 }); |
| 4389 } | 4357 } |
| 4390 | 4358 |
| 4391 void _upgradeObservableList(ObservableList list, ServiceObjectOwner owner) { | 4359 void _upgradeList(List list, ServiceObjectOwner owner) { |
| 4392 for (var i = 0; i < list.length; i++) { | 4360 for (var i = 0; i < list.length; i++) { |
| 4393 var v = list[i]; | 4361 var v = list[i]; |
| 4394 if ((v is ObservableMap) && _isServiceMap(v)) { | 4362 if ((v is Map) && _isServiceMap(v)) { |
| 4395 list[i] = owner.getFromMap(v); | 4363 list[i] = owner.getFromMap(v); |
| 4396 } else if (v is ObservableList) { | 4364 } else if (v is List) { |
| 4397 _upgradeObservableList(v, owner); | 4365 _upgradeList(v, owner); |
| 4398 } else if (v is ObservableMap) { | 4366 } else if (v is Map) { |
| 4399 _upgradeObservableMap(v, owner); | 4367 _upgradeMap(v, owner); |
| 4400 } | 4368 } |
| 4401 } | 4369 } |
| 4402 } | 4370 } |
| OLD | NEW |