| 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 /// A [ServiceObject] is an object known to the VM service and is tied | 7 /// A [ServiceObject] is an object known to the VM service and is tied |
| 8 /// to an owning [Isolate]. | 8 /// to an owning [Isolate]. |
| 9 abstract class ServiceObject extends Observable { | 9 abstract class ServiceObject extends Observable { |
| 10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { | 10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 /// The user-level type of this object. | 33 /// The user-level type of this object. |
| 34 @reflectable String get type => _type; | 34 @reflectable String get type => _type; |
| 35 String _type; | 35 String _type; |
| 36 | 36 |
| 37 /// The vm type of this object. | 37 /// The vm type of this object. |
| 38 @reflectable String get vmType => _vmType; | 38 @reflectable String get vmType => _vmType; |
| 39 String _vmType; | 39 String _vmType; |
| 40 | 40 |
| 41 bool get isBool => vmType == 'Bool'; | 41 bool get isBool => vmType == 'Bool'; |
| 42 bool get isClosure => false; |
| 43 bool get isContext => vmType == 'Context'; |
| 42 bool get isDouble => vmType == 'Double'; | 44 bool get isDouble => vmType == 'Double'; |
| 43 bool get isError => vmType == 'Error'; | 45 bool get isError => vmType == 'Error'; |
| 44 bool get isInstance => vmType == 'Instance'; | 46 bool get isInstance => vmType == 'Instance'; |
| 45 bool get isInt => vmType == 'Smi' || vmType == 'Mint' || vmType == 'Bigint'; | 47 bool get isInt => vmType == 'Smi' || vmType == 'Mint' || vmType == 'Bigint'; |
| 46 bool get isList => vmType == 'GrowableObjectArray' || vmType == 'Array'; | 48 bool get isList => vmType == 'GrowableObjectArray' || vmType == 'Array'; |
| 47 bool get isNull => vmType == 'Null'; | 49 bool get isNull => vmType == 'Null'; |
| 48 bool get isSentinel => vmType == 'Sentinel'; | 50 bool get isSentinel => vmType == 'Sentinel'; |
| 49 bool get isString => vmType == 'String'; | 51 bool get isString => vmType == 'String'; |
| 50 bool get isType => vmType == 'Type'; | 52 bool get isType => vmType == 'Type'; |
| 51 | 53 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 var type = _stripRef(map['type']); | 86 var type = _stripRef(map['type']); |
| 85 var obj = null; | 87 var obj = null; |
| 86 assert(type != 'VM'); | 88 assert(type != 'VM'); |
| 87 switch (type) { | 89 switch (type) { |
| 88 case 'Class': | 90 case 'Class': |
| 89 obj = new Class._empty(owner); | 91 obj = new Class._empty(owner); |
| 90 break; | 92 break; |
| 91 case 'Code': | 93 case 'Code': |
| 92 obj = new Code._empty(owner); | 94 obj = new Code._empty(owner); |
| 93 break; | 95 break; |
| 96 case 'Context': |
| 97 obj = new Context._empty(owner); |
| 98 break; |
| 94 case 'Counter': | 99 case 'Counter': |
| 95 obj = new ServiceMetric._empty(owner); | 100 obj = new ServiceMetric._empty(owner); |
| 96 break; | 101 break; |
| 97 case 'Error': | 102 case 'Error': |
| 98 obj = new DartError._empty(owner); | 103 obj = new DartError._empty(owner); |
| 99 break; | 104 break; |
| 100 case 'Function': | 105 case 'Function': |
| 101 obj = new ServiceFunction._empty(owner); | 106 obj = new ServiceFunction._empty(owner); |
| 102 break; | 107 break; |
| 103 case 'Gauge': | 108 case 'Gauge': |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 | 1468 |
| 1464 Future<ServiceObject> get(String command) { | 1469 Future<ServiceObject> get(String command) { |
| 1465 return isolate.get(id + "/$command"); | 1470 return isolate.get(id + "/$command"); |
| 1466 } | 1471 } |
| 1467 | 1472 |
| 1468 String toString() => 'Class($vmName)'; | 1473 String toString() => 'Class($vmName)'; |
| 1469 } | 1474 } |
| 1470 | 1475 |
| 1471 class Instance extends ServiceObject { | 1476 class Instance extends ServiceObject { |
| 1472 @observable Class clazz; | 1477 @observable Class clazz; |
| 1473 @observable String valueAsString; | |
| 1474 @observable int size; | 1478 @observable int size; |
| 1479 @observable String valueAsString; // If primitive. |
| 1475 @observable ServiceFunction closureFunc; // If a closure. | 1480 @observable ServiceFunction closureFunc; // If a closure. |
| 1481 @observable Context closureCtxt; // If a closure. |
| 1476 @observable String name; // If a Type. | 1482 @observable String name; // If a Type. |
| 1483 @observable int length; // If a List. |
| 1477 | 1484 |
| 1478 @observable var typeClass; | 1485 @observable var typeClass; |
| 1479 @observable var length; | |
| 1480 @observable var fields; | 1486 @observable var fields; |
| 1481 @observable var nativeFields; | 1487 @observable var nativeFields; |
| 1482 @observable var elements; | 1488 @observable var elements; |
| 1483 @observable var userName; | 1489 @observable var userName; |
| 1484 | 1490 |
| 1485 bool get isClosure => closureFunc != null; | 1491 bool get isClosure => closureFunc != null; |
| 1486 | 1492 |
| 1487 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); | 1493 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 1488 | 1494 |
| 1489 void _update(ObservableMap map, bool mapIsRef) { | 1495 void _update(ObservableMap map, bool mapIsRef) { |
| 1490 // Extract full properties. | 1496 // Extract full properties. |
| 1491 _upgradeCollection(map, isolate); | 1497 _upgradeCollection(map, isolate); |
| 1492 | 1498 |
| 1493 clazz = map['class']; | 1499 clazz = map['class']; |
| 1500 size = map['size']; |
| 1494 valueAsString = map['valueAsString']; | 1501 valueAsString = map['valueAsString']; |
| 1495 size = map['size']; | |
| 1496 closureFunc = map['closureFunc']; | 1502 closureFunc = map['closureFunc']; |
| 1503 closureCtxt = map['closureCtxt']; |
| 1497 name = map['name']; | 1504 name = map['name']; |
| 1505 length = map['length']; |
| 1498 | 1506 |
| 1499 if (mapIsRef) { | 1507 if (mapIsRef) { |
| 1500 return; | 1508 return; |
| 1501 } | 1509 } |
| 1502 | 1510 |
| 1503 nativeFields = map['nativeFields']; | 1511 nativeFields = map['nativeFields']; |
| 1504 fields = map['fields']; | 1512 fields = map['fields']; |
| 1505 length = map['length']; | |
| 1506 elements = map['elements']; | 1513 elements = map['elements']; |
| 1507 typeClass = map['type_class']; | 1514 typeClass = map['type_class']; |
| 1508 userName = map['user_name']; | 1515 userName = map['user_name']; |
| 1509 | 1516 |
| 1510 // We are fully loaded. | 1517 // We are fully loaded. |
| 1511 _loaded = true; | 1518 _loaded = true; |
| 1512 } | 1519 } |
| 1513 | 1520 |
| 1514 String get shortName => valueAsString != null ? valueAsString : 'a ${clazz.nam
e}'; | 1521 String get shortName => valueAsString != null ? valueAsString : 'a ${clazz.nam
e}'; |
| 1515 | 1522 |
| 1516 String toString() => 'Instance($shortName)'; | 1523 String toString() => 'Instance($shortName)'; |
| 1517 } | 1524 } |
| 1518 | 1525 |
| 1526 |
| 1527 class Context extends ServiceObject { |
| 1528 @observable Class clazz; |
| 1529 @observable int size; |
| 1530 |
| 1531 @observable ServiceObject parentContext; |
| 1532 @observable var length; |
| 1533 @observable var variables; |
| 1534 |
| 1535 bool get isClosure => closureFunc != null; |
| 1536 |
| 1537 Context._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 1538 |
| 1539 void _update(ObservableMap map, bool mapIsRef) { |
| 1540 // Extract full properties. |
| 1541 _upgradeCollection(map, isolate); |
| 1542 |
| 1543 size = map['size']; |
| 1544 length = map['length']; |
| 1545 parentContext = map['parent']; |
| 1546 |
| 1547 if (mapIsRef) { |
| 1548 return; |
| 1549 } |
| 1550 |
| 1551 clazz = map['class']; |
| 1552 variables = map['variables']; |
| 1553 |
| 1554 // We are fully loaded. |
| 1555 _loaded = true; |
| 1556 } |
| 1557 |
| 1558 String get shortName => valueAsString != null ? valueAsString : 'a ${clazz.nam
e}'; |
| 1559 |
| 1560 String toString() => 'Context($length)'; |
| 1561 } |
| 1562 |
| 1563 |
| 1519 // TODO(koda): Sync this with VM. | 1564 // TODO(koda): Sync this with VM. |
| 1520 class FunctionKind { | 1565 class FunctionKind { |
| 1521 final String _strValue; | 1566 final String _strValue; |
| 1522 FunctionKind._internal(this._strValue); | 1567 FunctionKind._internal(this._strValue); |
| 1523 toString() => _strValue; | 1568 toString() => _strValue; |
| 1524 bool isFake() => [kCollected, kNative, kTag, kReused].contains(this); | 1569 bool isFake() => [kCollected, kNative, kTag, kReused].contains(this); |
| 1525 | 1570 |
| 1526 static FunctionKind fromJSON(String value) { | 1571 static FunctionKind fromJSON(String value) { |
| 1527 switch(value) { | 1572 switch(value) { |
| 1528 case 'kRegularFunction': return kRegularFunction; | 1573 case 'kRegularFunction': return kRegularFunction; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 @reflectable int exclusiveTicks = 0; | 2041 @reflectable int exclusiveTicks = 0; |
| 1997 @reflectable int inclusiveTicks = 0; | 2042 @reflectable int inclusiveTicks = 0; |
| 1998 @reflectable int startAddress = 0; | 2043 @reflectable int startAddress = 0; |
| 1999 @reflectable int endAddress = 0; | 2044 @reflectable int endAddress = 0; |
| 2000 @reflectable final callers = new List<CodeCallCount>(); | 2045 @reflectable final callers = new List<CodeCallCount>(); |
| 2001 @reflectable final callees = new List<CodeCallCount>(); | 2046 @reflectable final callees = new List<CodeCallCount>(); |
| 2002 @reflectable final instructions = new ObservableList<CodeInstruction>(); | 2047 @reflectable final instructions = new ObservableList<CodeInstruction>(); |
| 2003 @reflectable final addressTicks = new ObservableMap<int, CodeTick>(); | 2048 @reflectable final addressTicks = new ObservableMap<int, CodeTick>(); |
| 2004 @observable String formattedInclusiveTicks = ''; | 2049 @observable String formattedInclusiveTicks = ''; |
| 2005 @observable String formattedExclusiveTicks = ''; | 2050 @observable String formattedExclusiveTicks = ''; |
| 2006 @observable ServiceMap objectPool; | 2051 @observable Instance objectPool; |
| 2007 @observable ServiceFunction function; | 2052 @observable ServiceFunction function; |
| 2008 @observable Script script; | 2053 @observable Script script; |
| 2009 @observable bool isOptimized = false; | 2054 @observable bool isOptimized = false; |
| 2010 String name; | 2055 String name; |
| 2011 String vmName; | 2056 String vmName; |
| 2012 | 2057 |
| 2013 bool get canCache => true; | 2058 bool get canCache => true; |
| 2014 bool get immutable => true; | 2059 bool get immutable => true; |
| 2015 | 2060 |
| 2016 Code._empty(ServiceObjectOwner owner) : super._empty(owner); | 2061 Code._empty(ServiceObjectOwner owner) : super._empty(owner); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 var v = list[i]; | 2524 var v = list[i]; |
| 2480 if ((v is ObservableMap) && _isServiceMap(v)) { | 2525 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 2481 list[i] = owner.getFromMap(v); | 2526 list[i] = owner.getFromMap(v); |
| 2482 } else if (v is ObservableList) { | 2527 } else if (v is ObservableList) { |
| 2483 _upgradeObservableList(v, owner); | 2528 _upgradeObservableList(v, owner); |
| 2484 } else if (v is ObservableMap) { | 2529 } else if (v is ObservableMap) { |
| 2485 _upgradeObservableMap(v, owner); | 2530 _upgradeObservableMap(v, owner); |
| 2486 } | 2531 } |
| 2487 } | 2532 } |
| 2488 } | 2533 } |
| OLD | NEW |