| 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 /// An RpcException represents an exceptional event that happened | 7 /// An RpcException represents an exceptional event that happened |
| 8 /// while invoking an rpc. | 8 /// while invoking an rpc. |
| 9 abstract class RpcException implements Exception { | 9 abstract class RpcException implements Exception { |
| 10 RpcException(this.message); | 10 RpcException(this.message); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 break; | 168 break; |
| 169 case 'Counter': | 169 case 'Counter': |
| 170 obj = new ServiceMetric._empty(owner); | 170 obj = new ServiceMetric._empty(owner); |
| 171 break; | 171 break; |
| 172 case 'Error': | 172 case 'Error': |
| 173 obj = new DartError._empty(owner); | 173 obj = new DartError._empty(owner); |
| 174 break; | 174 break; |
| 175 case 'Field': | 175 case 'Field': |
| 176 obj = new Field._empty(owner); | 176 obj = new Field._empty(owner); |
| 177 break; | 177 break; |
| 178 case 'Frame': |
| 179 obj = new Frame._empty(owner); |
| 180 break; |
| 178 case 'Function': | 181 case 'Function': |
| 179 obj = new ServiceFunction._empty(owner); | 182 obj = new ServiceFunction._empty(owner); |
| 180 break; | 183 break; |
| 181 case 'Gauge': | 184 case 'Gauge': |
| 182 obj = new ServiceMetric._empty(owner); | 185 obj = new ServiceMetric._empty(owner); |
| 183 break; | 186 break; |
| 184 case 'Isolate': | 187 case 'Isolate': |
| 185 obj = new Isolate._empty(owner.vm); | 188 obj = new Isolate._empty(owner.vm); |
| 186 break; | 189 break; |
| 187 case 'Library': | 190 case 'Library': |
| 188 obj = new Library._empty(owner); | 191 obj = new Library._empty(owner); |
| 189 break; | 192 break; |
| 193 case 'Message': |
| 194 obj = new ServiceMessage._empty(owner); |
| 195 break; |
| 196 case 'SourceLocation': |
| 197 obj = new SourceLocation._empty(owner); |
| 198 break; |
| 190 case 'Object': | 199 case 'Object': |
| 191 switch (vmType) { | 200 switch (vmType) { |
| 192 case 'PcDescriptors': | 201 case 'PcDescriptors': |
| 193 obj = new PcDescriptors._empty(owner); | 202 obj = new PcDescriptors._empty(owner); |
| 194 break; | 203 break; |
| 195 case 'LocalVarDescriptors': | 204 case 'LocalVarDescriptors': |
| 196 obj = new LocalVarDescriptors._empty(owner); | 205 obj = new LocalVarDescriptors._empty(owner); |
| 197 break; | 206 break; |
| 198 case 'TokenStream': | 207 case 'TokenStream': |
| 199 obj = new TokenStream._empty(owner); | 208 obj = new TokenStream._empty(owner); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 abstract class ServiceObjectOwner extends ServiceObject { | 367 abstract class ServiceObjectOwner extends ServiceObject { |
| 359 /// Creates an empty [ServiceObjectOwner]. | 368 /// Creates an empty [ServiceObjectOwner]. |
| 360 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner); | 369 ServiceObjectOwner._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 361 | 370 |
| 362 /// Builds a [ServiceObject] corresponding to the [id] from [map]. | 371 /// Builds a [ServiceObject] corresponding to the [id] from [map]. |
| 363 /// The result may come from the cache. The result will not necessarily | 372 /// The result may come from the cache. The result will not necessarily |
| 364 /// be [loaded]. | 373 /// be [loaded]. |
| 365 ServiceObject getFromMap(ObservableMap map); | 374 ServiceObject getFromMap(ObservableMap map); |
| 366 } | 375 } |
| 367 | 376 |
| 377 /// A [SourceLocation] represents a location or range in the source code. |
| 378 class SourceLocation extends ServiceObject { |
| 379 Script script; |
| 380 int tokenPos; |
| 381 int endTokenPos; |
| 382 |
| 383 SourceLocation._empty(ServiceObject owner) : super._empty(owner); |
| 384 |
| 385 void _update(ObservableMap map, bool mapIsRef) { |
| 386 assert(!mapIsRef); |
| 387 _upgradeCollection(map, owner); |
| 388 script = map['script']; |
| 389 tokenPos = map['tokenPos']; |
| 390 assert(script != null && tokenPos != null); |
| 391 endTokenPos = map['endTokenPos']; |
| 392 } |
| 393 |
| 394 String toString() { |
| 395 if (endTokenPos == null) { |
| 396 return '${script.name}:token(${tokenPos})'; |
| 397 } else { |
| 398 return '${script.name}:tokens(${tokenPos}-${endTokenPos})'; |
| 399 } |
| 400 } |
| 401 } |
| 402 |
| 368 /// State for a VM being inspected. | 403 /// State for a VM being inspected. |
| 369 abstract class VM extends ServiceObjectOwner { | 404 abstract class VM extends ServiceObjectOwner { |
| 370 @reflectable VM get vm => this; | 405 @reflectable VM get vm => this; |
| 371 @reflectable Isolate get isolate => null; | 406 @reflectable Isolate get isolate => null; |
| 372 | 407 |
| 373 // TODO(turnidge): The connection should not be stored in the VM object. | 408 // TODO(turnidge): The connection should not be stored in the VM object. |
| 374 bool get isDisconnected; | 409 bool get isDisconnected; |
| 375 | 410 |
| 376 // TODO(johnmccutchan): Ensure that isolates do not end up in _cache. | 411 // TODO(johnmccutchan): Ensure that isolates do not end up in _cache. |
| 377 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>(); | 412 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>(); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 return invokeRpcNoUpgrade('getIsolate', {}); | 958 return invokeRpcNoUpgrade('getIsolate', {}); |
| 924 } | 959 } |
| 925 | 960 |
| 926 @observable Class objectClass; | 961 @observable Class objectClass; |
| 927 @observable final rootClasses = new ObservableList<Class>(); | 962 @observable final rootClasses = new ObservableList<Class>(); |
| 928 Map<int, Class> _classesByCid = new Map<int, Class>(); | 963 Map<int, Class> _classesByCid = new Map<int, Class>(); |
| 929 | 964 |
| 930 @observable Library rootLibrary; | 965 @observable Library rootLibrary; |
| 931 @observable ObservableList<Library> libraries = | 966 @observable ObservableList<Library> libraries = |
| 932 new ObservableList<Library>(); | 967 new ObservableList<Library>(); |
| 933 @observable ObservableMap topFrame; | 968 @observable Frame topFrame; |
| 934 | 969 |
| 935 @observable String name; | 970 @observable String name; |
| 936 @observable String vmName; | 971 @observable String vmName; |
| 937 @observable ServiceFunction entry; | 972 @observable ServiceFunction entry; |
| 938 | 973 |
| 939 @observable final Map<String, double> timers = | 974 @observable final Map<String, double> timers = |
| 940 toObservable(new Map<String, double>()); | 975 toObservable(new Map<String, double>()); |
| 941 | 976 |
| 942 final HeapSpace newSpace = new HeapSpace(); | 977 final HeapSpace newSpace = new HeapSpace(); |
| 943 final HeapSpace oldSpace = new HeapSpace(); | 978 final HeapSpace oldSpace = new HeapSpace(); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 Future<ServiceObject> addBreakpoint(Script script, int line) async { | 1185 Future<ServiceObject> addBreakpoint(Script script, int line) async { |
| 1151 // TODO(turnidge): Pass line as an int instead of a string. | 1186 // TODO(turnidge): Pass line as an int instead of a string. |
| 1152 try { | 1187 try { |
| 1153 Map params = { | 1188 Map params = { |
| 1154 'scriptId': script.id, | 1189 'scriptId': script.id, |
| 1155 'line': '$line', | 1190 'line': '$line', |
| 1156 }; | 1191 }; |
| 1157 Breakpoint bpt = await invokeRpc('addBreakpoint', params); | 1192 Breakpoint bpt = await invokeRpc('addBreakpoint', params); |
| 1158 if (bpt.resolved && | 1193 if (bpt.resolved && |
| 1159 script.loaded && | 1194 script.loaded && |
| 1160 script.tokenToLine(bpt.tokenPos) != line) { | 1195 script.tokenToLine(bpt.location.tokenPos) != line) { |
| 1161 // TODO(turnidge): Can this still happen? | 1196 // TODO(turnidge): Can this still happen? |
| 1162 script.getLine(line).possibleBpt = false; | 1197 script.getLine(line).possibleBpt = false; |
| 1163 } | 1198 } |
| 1164 return bpt; | 1199 return bpt; |
| 1165 } on ServerRpcException catch(e) { | 1200 } on ServerRpcException catch(e) { |
| 1166 if (e.code == ServerRpcException.kCannotAddBreakpoint) { | 1201 if (e.code == ServerRpcException.kCannotAddBreakpoint) { |
| 1167 // Unable to set a breakpoint at the desired line. | 1202 // Unable to set a breakpoint at the desired line. |
| 1168 script.getLine(line).possibleBpt = false; | 1203 script.getLine(line).possibleBpt = false; |
| 1169 } | 1204 } |
| 1170 rethrow; | 1205 rethrow; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 static const kConnectionClosed = 'ConnectionClosed'; | 1453 static const kConnectionClosed = 'ConnectionClosed'; |
| 1419 | 1454 |
| 1420 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); | 1455 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 1421 | 1456 |
| 1422 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { | 1457 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { |
| 1423 kind = kConnectionClosed; | 1458 kind = kConnectionClosed; |
| 1424 } | 1459 } |
| 1425 | 1460 |
| 1426 @observable String kind; | 1461 @observable String kind; |
| 1427 @observable Breakpoint breakpoint; | 1462 @observable Breakpoint breakpoint; |
| 1428 @observable ServiceMap topFrame; | 1463 @observable Frame topFrame; |
| 1429 @observable ServiceMap exception; | 1464 @observable ServiceMap exception; |
| 1430 @observable ServiceObject inspectee; | 1465 @observable ServiceObject inspectee; |
| 1431 @observable ByteData data; | 1466 @observable ByteData data; |
| 1432 @observable int count; | 1467 @observable int count; |
| 1433 @observable String reason; | 1468 @observable String reason; |
| 1434 int chunkIndex, chunkCount, nodeCount; | 1469 int chunkIndex, chunkCount, nodeCount; |
| 1435 | 1470 |
| 1436 @observable bool get isPauseEvent { | 1471 @observable bool get isPauseEvent { |
| 1437 return (kind == kPauseStart || | 1472 return (kind == kPauseStart || |
| 1438 kind == kPauseExit || | 1473 kind == kPauseExit || |
| 1439 kind == kPauseBreakpoint || | 1474 kind == kPauseBreakpoint || |
| 1440 kind == kPauseInterrupted || | 1475 kind == kPauseInterrupted || |
| 1441 kind == kPauseException); | 1476 kind == kPauseException); |
| 1442 } | 1477 } |
| 1443 | 1478 |
| 1444 void _update(ObservableMap map, bool mapIsRef) { | 1479 void _update(ObservableMap map, bool mapIsRef) { |
| 1445 _loaded = true; | 1480 _loaded = true; |
| 1446 _upgradeCollection(map, owner); | 1481 _upgradeCollection(map, owner); |
| 1447 assert(map['isolate'] == null || owner == map['isolate']); | 1482 assert(map['isolate'] == null || owner == map['isolate']); |
| 1448 kind = map['kind']; | 1483 kind = map['kind']; |
| 1449 notifyPropertyChange(#isPauseEvent, 0, 1); | 1484 notifyPropertyChange(#isPauseEvent, 0, 1); |
| 1450 name = 'ServiceEvent $kind'; | 1485 name = 'ServiceEvent $kind'; |
| 1451 vmName = name; | 1486 vmName = name; |
| 1452 if (map['breakpoint'] != null) { | 1487 if (map['breakpoint'] != null) { |
| 1453 breakpoint = map['breakpoint']; | 1488 breakpoint = map['breakpoint']; |
| 1454 } | 1489 } |
| 1455 if (map['topFrame'] != null) { | 1490 topFrame = map['topFrame']; |
| 1456 topFrame = map['topFrame']; | |
| 1457 } | |
| 1458 if (map['exception'] != null) { | 1491 if (map['exception'] != null) { |
| 1459 exception = map['exception']; | 1492 exception = map['exception']; |
| 1460 } | 1493 } |
| 1461 if (map['inspectee'] != null) { | 1494 if (map['inspectee'] != null) { |
| 1462 inspectee = map['inspectee']; | 1495 inspectee = map['inspectee']; |
| 1463 } | 1496 } |
| 1464 if (map['_data'] != null) { | 1497 if (map['_data'] != null) { |
| 1465 data = map['_data']; | 1498 data = map['_data']; |
| 1466 } | 1499 } |
| 1467 if (map['chunkIndex'] != null) { | 1500 if (map['chunkIndex'] != null) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1493 | 1526 |
| 1494 // TODO(turnidge): Add state to track if a breakpoint has been | 1527 // TODO(turnidge): Add state to track if a breakpoint has been |
| 1495 // removed from the program. Remove from the cache when deleted. | 1528 // removed from the program. Remove from the cache when deleted. |
| 1496 bool get canCache => true; | 1529 bool get canCache => true; |
| 1497 bool get immutable => false; | 1530 bool get immutable => false; |
| 1498 | 1531 |
| 1499 // A unique integer identifier for this breakpoint. | 1532 // A unique integer identifier for this breakpoint. |
| 1500 @observable int number; | 1533 @observable int number; |
| 1501 | 1534 |
| 1502 // Source location information. | 1535 // Source location information. |
| 1503 @observable Script script; | 1536 @observable SourceLocation location; |
| 1504 @observable int tokenPos; | |
| 1505 | 1537 |
| 1506 // The breakpoint has been assigned to a final source location. | 1538 // The breakpoint has been assigned to a final source location. |
| 1507 @observable bool resolved; | 1539 @observable bool resolved; |
| 1508 | 1540 |
| 1509 void _update(ObservableMap map, bool mapIsRef) { | 1541 void _update(ObservableMap map, bool mapIsRef) { |
| 1510 _loaded = true; | 1542 _loaded = true; |
| 1511 _upgradeCollection(map, owner); | 1543 _upgradeCollection(map, owner); |
| 1512 | 1544 |
| 1513 var newNumber = map['breakpointNumber']; | 1545 var newNumber = map['breakpointNumber']; |
| 1514 var newScript = map['location']['script']; | 1546 // number never changes. |
| 1515 var newTokenPos = map['location']['tokenPos']; | 1547 assert((number == null) || (number == newNumber)); |
| 1548 number = newNumber; |
| 1516 | 1549 |
| 1517 // number and script never change. | 1550 resolved = map['resolved']; |
| 1518 assert((number == null) || (number == newNumber)); | |
| 1519 assert((script == null) || (script == newScript)); | |
| 1520 | 1551 |
| 1521 number = map['breakpointNumber']; | 1552 var oldLocation = location; |
| 1522 script = map['location']['script']; | 1553 var newLocation = map['location']; |
| 1523 resolved = map['resolved']; | 1554 var oldScript; |
| 1524 bool tokenPosChanged = tokenPos != newTokenPos; | 1555 var newScript; |
| 1525 | 1556 var oldTokenPos; |
| 1526 if (script.loaded && | 1557 var newTokenPos; |
| 1527 (tokenPos != null) && | 1558 if (oldLocation != null) { |
| 1559 oldScript = location.script; |
| 1560 oldTokenPos = location.tokenPos; |
| 1561 } |
| 1562 if (newLocation != null) { |
| 1563 newScript = newLocation.script; |
| 1564 newTokenPos = newLocation.tokenPos; |
| 1565 } |
| 1566 // script never changes |
| 1567 assert((oldScript == null) || (oldScript == newScript)); |
| 1568 bool tokenPosChanged = oldTokenPos != newTokenPos; |
| 1569 if (newScript.loaded && |
| 1570 (newTokenPos != null) && |
| 1528 tokenPosChanged) { | 1571 tokenPosChanged) { |
| 1529 // The breakpoint has moved. Remove it and add it later. | 1572 // The breakpoint has moved. Remove it and add it later. |
| 1530 script._removeBreakpoint(this); | 1573 if (oldScript != null) { |
| 1574 oldScript._removeBreakpoint(this); |
| 1575 } |
| 1531 } | 1576 } |
| 1532 | 1577 location = newLocation; |
| 1533 tokenPos = newTokenPos; | 1578 if (newScript.loaded && tokenPosChanged) { |
| 1534 if (script.loaded && tokenPosChanged) { | 1579 newScript._addBreakpoint(this); |
| 1535 script._addBreakpoint(this); | |
| 1536 } | 1580 } |
| 1537 } | 1581 } |
| 1538 | 1582 |
| 1539 void remove() { | 1583 void remove() { |
| 1540 // Remove any references to this breakpoint. It has been removed. | 1584 // Remove any references to this breakpoint. It has been removed. |
| 1541 script._removeBreakpoint(this); | 1585 location.script._removeBreakpoint(this); |
| 1542 if ((isolate.pauseEvent != null) && | 1586 if ((isolate.pauseEvent != null) && |
| 1543 (isolate.pauseEvent.breakpoint != null) && | 1587 (isolate.pauseEvent.breakpoint != null) && |
| 1544 (isolate.pauseEvent.breakpoint.id == id)) { | 1588 (isolate.pauseEvent.breakpoint.id == id)) { |
| 1545 isolate.pauseEvent.breakpoint = null; | 1589 isolate.pauseEvent.breakpoint = null; |
| 1546 } | 1590 } |
| 1547 } | 1591 } |
| 1548 | 1592 |
| 1549 String toString() { | 1593 String toString() { |
| 1550 if (number != null) { | 1594 if (number != null) { |
| 1551 return 'Breakpoint ${number} at ${script.name}(token:${tokenPos})'; | 1595 return 'Breakpoint ${number} at ${location})'; |
| 1552 } else { | 1596 } else { |
| 1553 return 'Uninitialized breakpoint'; | 1597 return 'Uninitialized breakpoint'; |
| 1554 } | 1598 } |
| 1555 } | 1599 } |
| 1556 } | 1600 } |
| 1557 | 1601 |
| 1558 | 1602 |
| 1559 class LibraryDependency { | 1603 class LibraryDependency { |
| 1560 @reflectable final bool isImport; | 1604 @reflectable final bool isImport; |
| 1561 @reflectable final bool isDeferred; | 1605 @reflectable final bool isDeferred; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 accumulated.bytes = stats[ACCUMULATED_SIZE]; | 1701 accumulated.bytes = stats[ACCUMULATED_SIZE]; |
| 1658 current.instances = stats[LIVE_AFTER_GC] + stats[ALLOCATED_SINCE_GC]; | 1702 current.instances = stats[LIVE_AFTER_GC] + stats[ALLOCATED_SINCE_GC]; |
| 1659 current.bytes = stats[LIVE_AFTER_GC_SIZE] + stats[ALLOCATED_SINCE_GC_SIZE]; | 1703 current.bytes = stats[LIVE_AFTER_GC_SIZE] + stats[ALLOCATED_SINCE_GC_SIZE]; |
| 1660 } | 1704 } |
| 1661 | 1705 |
| 1662 bool get empty => accumulated.empty && current.empty; | 1706 bool get empty => accumulated.empty && current.empty; |
| 1663 } | 1707 } |
| 1664 | 1708 |
| 1665 class Class extends ServiceObject with Coverage { | 1709 class Class extends ServiceObject with Coverage { |
| 1666 @observable Library library; | 1710 @observable Library library; |
| 1667 @observable Script script; | |
| 1668 | 1711 |
| 1669 @observable bool isAbstract; | 1712 @observable bool isAbstract; |
| 1670 @observable bool isConst; | 1713 @observable bool isConst; |
| 1671 @observable bool isFinalized; | 1714 @observable bool isFinalized; |
| 1672 @observable bool isPatch; | 1715 @observable bool isPatch; |
| 1673 @observable bool isImplemented; | 1716 @observable bool isImplemented; |
| 1674 | 1717 |
| 1675 @observable int tokenPos; | 1718 @observable SourceLocation location; |
| 1676 @observable int endTokenPos; | |
| 1677 | 1719 |
| 1678 @observable ServiceMap error; | 1720 @observable ServiceMap error; |
| 1679 @observable int vmCid; | 1721 @observable int vmCid; |
| 1680 | 1722 |
| 1681 final Allocations newSpace = new Allocations(); | 1723 final Allocations newSpace = new Allocations(); |
| 1682 final Allocations oldSpace = new Allocations(); | 1724 final Allocations oldSpace = new Allocations(); |
| 1683 final AllocationCount promotedByLastNewGC = new AllocationCount(); | 1725 final AllocationCount promotedByLastNewGC = new AllocationCount(); |
| 1684 | 1726 |
| 1685 @observable bool get hasNoAllocations => newSpace.empty && oldSpace.empty; | 1727 @observable bool get hasNoAllocations => newSpace.empty && oldSpace.empty; |
| 1686 | 1728 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1713 // Extract full properties. | 1755 // Extract full properties. |
| 1714 _upgradeCollection(map, isolate); | 1756 _upgradeCollection(map, isolate); |
| 1715 | 1757 |
| 1716 // Some builtin classes aren't associated with a library. | 1758 // Some builtin classes aren't associated with a library. |
| 1717 if (map['library'] is Library) { | 1759 if (map['library'] is Library) { |
| 1718 library = map['library']; | 1760 library = map['library']; |
| 1719 } else { | 1761 } else { |
| 1720 library = null; | 1762 library = null; |
| 1721 } | 1763 } |
| 1722 | 1764 |
| 1723 script = map['script']; | 1765 location = map['location']; |
| 1724 | |
| 1725 isAbstract = map['abstract']; | 1766 isAbstract = map['abstract']; |
| 1726 isConst = map['const']; | 1767 isConst = map['const']; |
| 1727 isFinalized = map['_finalized']; | 1768 isFinalized = map['_finalized']; |
| 1728 isPatch = map['_patch']; | 1769 isPatch = map['_patch']; |
| 1729 isImplemented = map['_implemented']; | 1770 isImplemented = map['_implemented']; |
| 1730 | 1771 |
| 1731 tokenPos = map['tokenPos']; | |
| 1732 endTokenPos = map['endTokenPos']; | |
| 1733 | |
| 1734 subclasses.clear(); | 1772 subclasses.clear(); |
| 1735 subclasses.addAll(map['subclasses']); | 1773 subclasses.addAll(map['subclasses']); |
| 1736 subclasses.sort(ServiceObject.LexicalSortName); | 1774 subclasses.sort(ServiceObject.LexicalSortName); |
| 1737 | 1775 |
| 1738 interfaces.clear(); | 1776 interfaces.clear(); |
| 1739 interfaces.addAll(map['interfaces']); | 1777 interfaces.addAll(map['interfaces']); |
| 1740 interfaces.sort(ServiceObject.LexicalSortName); | 1778 interfaces.sort(ServiceObject.LexicalSortName); |
| 1741 | 1779 |
| 1742 fields.clear(); | 1780 fields.clear(); |
| 1743 fields.addAll(map['fields']); | 1781 fields.addAll(map['fields']); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 static FunctionKind kStub = new FunctionKind._internal('Stub'); | 1994 static FunctionKind kStub = new FunctionKind._internal('Stub'); |
| 1957 static FunctionKind kUNKNOWN = new FunctionKind._internal('UNKNOWN'); | 1995 static FunctionKind kUNKNOWN = new FunctionKind._internal('UNKNOWN'); |
| 1958 } | 1996 } |
| 1959 | 1997 |
| 1960 class ServiceFunction extends ServiceObject with Coverage { | 1998 class ServiceFunction extends ServiceObject with Coverage { |
| 1961 // owner is a Library, Class, or ServiceFunction. | 1999 // owner is a Library, Class, or ServiceFunction. |
| 1962 @observable ServiceObject dartOwner; | 2000 @observable ServiceObject dartOwner; |
| 1963 @observable Library library; | 2001 @observable Library library; |
| 1964 @observable bool isStatic; | 2002 @observable bool isStatic; |
| 1965 @observable bool isConst; | 2003 @observable bool isConst; |
| 1966 @observable Script script; | 2004 @observable SourceLocation location; |
| 1967 @observable int tokenPos; | |
| 1968 @observable int endTokenPos; | |
| 1969 @observable Code code; | 2005 @observable Code code; |
| 1970 @observable Code unoptimizedCode; | 2006 @observable Code unoptimizedCode; |
| 1971 @observable bool isOptimizable; | 2007 @observable bool isOptimizable; |
| 1972 @observable bool isInlinable; | 2008 @observable bool isInlinable; |
| 1973 @observable FunctionKind kind; | 2009 @observable FunctionKind kind; |
| 1974 @observable int deoptimizations; | 2010 @observable int deoptimizations; |
| 1975 @observable String qualifiedName; | 2011 @observable String qualifiedName; |
| 1976 @observable int usageCounter; | 2012 @observable int usageCounter; |
| 1977 @observable bool isDart; | 2013 @observable bool isDart; |
| 1978 @observable ProfileFunction profile; | 2014 @observable ProfileFunction profile; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2007 qualifiedName = name; | 2043 qualifiedName = name; |
| 2008 } | 2044 } |
| 2009 | 2045 |
| 2010 if (mapIsRef) { | 2046 if (mapIsRef) { |
| 2011 return; | 2047 return; |
| 2012 } | 2048 } |
| 2013 | 2049 |
| 2014 _loaded = true; | 2050 _loaded = true; |
| 2015 isStatic = map['static']; | 2051 isStatic = map['static']; |
| 2016 isConst = map['const']; | 2052 isConst = map['const']; |
| 2017 script = map['script']; | 2053 location = map['location']; |
| 2018 tokenPos = map['tokenPos']; | |
| 2019 endTokenPos = map['endTokenPos']; | |
| 2020 code = map['code']; | 2054 code = map['code']; |
| 2021 isOptimizable = map['_optimizable']; | 2055 isOptimizable = map['_optimizable']; |
| 2022 isInlinable = map['_inlinable']; | 2056 isInlinable = map['_inlinable']; |
| 2023 unoptimizedCode = map['_unoptimizedCode']; | 2057 unoptimizedCode = map['_unoptimizedCode']; |
| 2024 deoptimizations = map['_deoptimizations']; | 2058 deoptimizations = map['_deoptimizations']; |
| 2025 usageCounter = map['_usageCounter']; | 2059 usageCounter = map['_usageCounter']; |
| 2026 } | 2060 } |
| 2027 } | 2061 } |
| 2028 | 2062 |
| 2029 | 2063 |
| 2030 class Field extends ServiceObject { | 2064 class Field extends ServiceObject { |
| 2031 // Library or Class. | 2065 // Library or Class. |
| 2032 @observable ServiceObject dartOwner; | 2066 @observable ServiceObject dartOwner; |
| 2033 @observable Library library; | 2067 @observable Library library; |
| 2034 @observable Instance declaredType; | 2068 @observable Instance declaredType; |
| 2035 @observable bool isStatic; | 2069 @observable bool isStatic; |
| 2036 @observable bool isFinal; | 2070 @observable bool isFinal; |
| 2037 @observable bool isConst; | 2071 @observable bool isConst; |
| 2038 @observable Instance staticValue; | 2072 @observable Instance staticValue; |
| 2039 @observable String name; | 2073 @observable String name; |
| 2040 @observable String vmName; | 2074 @observable String vmName; |
| 2041 | 2075 |
| 2042 @observable bool guardNullable; | 2076 @observable bool guardNullable; |
| 2043 @observable String guardClass; | 2077 @observable String guardClass; |
| 2044 @observable String guardLength; | 2078 @observable String guardLength; |
| 2045 @observable Script script; | 2079 @observable SourceLocation location; |
| 2046 @observable int tokenPos; | |
| 2047 | 2080 |
| 2048 Field._empty(ServiceObjectOwner owner) : super._empty(owner); | 2081 Field._empty(ServiceObjectOwner owner) : super._empty(owner); |
| 2049 | 2082 |
| 2050 void _update(ObservableMap map, bool mapIsRef) { | 2083 void _update(ObservableMap map, bool mapIsRef) { |
| 2051 // Extract full properties. | 2084 // Extract full properties. |
| 2052 _upgradeCollection(map, isolate); | 2085 _upgradeCollection(map, isolate); |
| 2053 | 2086 |
| 2054 name = map['name']; | 2087 name = map['name']; |
| 2055 vmName = (map.containsKey('vmName') ? map['vmName'] : name); | 2088 vmName = (map.containsKey('vmName') ? map['vmName'] : name); |
| 2056 dartOwner = map['owner']; | 2089 dartOwner = map['owner']; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2068 library = dartOwner; | 2101 library = dartOwner; |
| 2069 } | 2102 } |
| 2070 | 2103 |
| 2071 if (mapIsRef) { | 2104 if (mapIsRef) { |
| 2072 return; | 2105 return; |
| 2073 } | 2106 } |
| 2074 | 2107 |
| 2075 guardNullable = map['_guardNullable']; | 2108 guardNullable = map['_guardNullable']; |
| 2076 guardClass = map['_guardClass']; | 2109 guardClass = map['_guardClass']; |
| 2077 guardLength = map['_guardLength']; | 2110 guardLength = map['_guardLength']; |
| 2078 script = map['script']; | 2111 location = map['location']; |
| 2079 tokenPos = map['tokenPos']; | |
| 2080 | |
| 2081 _loaded = true; | 2112 _loaded = true; |
| 2082 } | 2113 } |
| 2083 | 2114 |
| 2084 String toString() => 'Field(${dartOwner.name}.$name)'; | 2115 String toString() => 'Field(${dartOwner.name}.$name)'; |
| 2085 } | 2116 } |
| 2086 | 2117 |
| 2087 | 2118 |
| 2088 class ScriptLine extends Observable { | 2119 class ScriptLine extends Observable { |
| 2089 final Script script; | 2120 final Script script; |
| 2090 final int line; | 2121 final int line; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2157 breakpoints.remove(bpt); | 2188 breakpoints.remove(bpt); |
| 2158 if (breakpoints.isEmpty) { | 2189 if (breakpoints.isEmpty) { |
| 2159 breakpoints = null; | 2190 breakpoints = null; |
| 2160 breakpointResolved = false; | 2191 breakpointResolved = false; |
| 2161 } | 2192 } |
| 2162 } | 2193 } |
| 2163 } | 2194 } |
| 2164 | 2195 |
| 2165 class CallSite { | 2196 class CallSite { |
| 2166 final String name; | 2197 final String name; |
| 2198 // TODO(turnidge): Use SourceLocation here instead. |
| 2167 final Script script; | 2199 final Script script; |
| 2168 final int tokenPos; | 2200 final int tokenPos; |
| 2169 final List<CallSiteEntry> entries; | 2201 final List<CallSiteEntry> entries; |
| 2170 | 2202 |
| 2171 CallSite(this.name, this.script, this.tokenPos, this.entries); | 2203 CallSite(this.name, this.script, this.tokenPos, this.entries); |
| 2172 | 2204 |
| 2173 int get line => script.tokenToLine(tokenPos); | 2205 int get line => script.tokenToLine(tokenPos); |
| 2174 int get column => script.tokenToCol(tokenPos); | 2206 int get column => script.tokenToCol(tokenPos); |
| 2175 | 2207 |
| 2176 int get aggregateCount { | 2208 int get aggregateCount { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2345 var sourceLines = source.split('\n'); | 2377 var sourceLines = source.split('\n'); |
| 2346 if (sourceLines.length == 0) { | 2378 if (sourceLines.length == 0) { |
| 2347 return; | 2379 return; |
| 2348 } | 2380 } |
| 2349 lines.clear(); | 2381 lines.clear(); |
| 2350 Logger.root.info('Adding ${sourceLines.length} source lines for ${uri}'); | 2382 Logger.root.info('Adding ${sourceLines.length} source lines for ${uri}'); |
| 2351 for (var i = 0; i < sourceLines.length; i++) { | 2383 for (var i = 0; i < sourceLines.length; i++) { |
| 2352 lines.add(new ScriptLine(this, i + lineOffset + 1, sourceLines[i])); | 2384 lines.add(new ScriptLine(this, i + lineOffset + 1, sourceLines[i])); |
| 2353 } | 2385 } |
| 2354 for (var bpt in isolate.breakpoints.values) { | 2386 for (var bpt in isolate.breakpoints.values) { |
| 2355 if (bpt.script == this) { | 2387 if (bpt.location.script == this) { |
| 2356 _addBreakpoint(bpt); | 2388 _addBreakpoint(bpt); |
| 2357 } | 2389 } |
| 2358 } | 2390 } |
| 2359 | 2391 |
| 2360 _applyHitsToLines(); | 2392 _applyHitsToLines(); |
| 2361 // Notify any Observers that this Script's state has changed. | 2393 // Notify any Observers that this Script's state has changed. |
| 2362 notifyChange(null); | 2394 notifyChange(null); |
| 2363 } | 2395 } |
| 2364 | 2396 |
| 2365 void _applyHitsToLines() { | 2397 void _applyHitsToLines() { |
| 2366 for (var line in lines) { | 2398 for (var line in lines) { |
| 2367 var hits = _hits[line.line]; | 2399 var hits = _hits[line.line]; |
| 2368 line.hits = hits; | 2400 line.hits = hits; |
| 2369 } | 2401 } |
| 2370 } | 2402 } |
| 2371 | 2403 |
| 2372 void _addBreakpoint(Breakpoint bpt) { | 2404 void _addBreakpoint(Breakpoint bpt) { |
| 2373 var line = tokenToLine(bpt.tokenPos); | 2405 var line = tokenToLine(bpt.location.tokenPos); |
| 2374 getLine(line).addBreakpoint(bpt); | 2406 getLine(line).addBreakpoint(bpt); |
| 2375 } | 2407 } |
| 2376 | 2408 |
| 2377 void _removeBreakpoint(Breakpoint bpt) { | 2409 void _removeBreakpoint(Breakpoint bpt) { |
| 2378 var line = tokenToLine(bpt.tokenPos); | 2410 var line = tokenToLine(bpt.location.tokenPos); |
| 2379 if (line != null) { | 2411 if (line != null) { |
| 2380 getLine(line).removeBreakpoint(bpt); | 2412 getLine(line).removeBreakpoint(bpt); |
| 2381 } | 2413 } |
| 2382 } | 2414 } |
| 2383 | 2415 |
| 2384 List<LocalVarLocation> scanLineForLocalVariableLocations(Pattern pattern, | 2416 List<LocalVarLocation> scanLineForLocalVariableLocations(Pattern pattern, |
| 2385 String name, | 2417 String name, |
| 2386 String lineContents, | 2418 String lineContents, |
| 2387 int lineNumber, | 2419 int lineNumber, |
| 2388 int columnOffset) { | 2420 int columnOffset) { |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2753 if (script != null) { | 2785 if (script != null) { |
| 2754 // Already done. | 2786 // Already done. |
| 2755 return; | 2787 return; |
| 2756 } | 2788 } |
| 2757 if (kind != CodeKind.Dart){ | 2789 if (kind != CodeKind.Dart){ |
| 2758 return; | 2790 return; |
| 2759 } | 2791 } |
| 2760 if (function == null) { | 2792 if (function == null) { |
| 2761 return; | 2793 return; |
| 2762 } | 2794 } |
| 2763 if (function.script == null) { | 2795 if (function.location.script == null) { |
| 2764 // Attempt to load the function. | 2796 // Attempt to load the function. |
| 2765 function.load().then((func) { | 2797 function.load().then((func) { |
| 2766 var script = function.script; | 2798 var script = function.location.script; |
| 2767 if (script == null) { | 2799 if (script == null) { |
| 2768 // Function doesn't have an associated script. | 2800 // Function doesn't have an associated script. |
| 2769 return; | 2801 return; |
| 2770 } | 2802 } |
| 2771 // Load the script and then update descriptors. | 2803 // Load the script and then update descriptors. |
| 2772 script.load().then(_updateDescriptors); | 2804 script.load().then(_updateDescriptors); |
| 2773 }); | 2805 }); |
| 2774 return; | 2806 return; |
| 2775 } | 2807 } |
| 2776 // Load the script and then update descriptors. | 2808 // Load the script and then update descriptors. |
| 2777 function.script.load().then(_updateDescriptors); | 2809 function.location.script.load().then(_updateDescriptors); |
| 2778 } | 2810 } |
| 2779 | 2811 |
| 2780 /// Reload [this]. Returns a future which completes to [this] or an | 2812 /// Reload [this]. Returns a future which completes to [this] or an |
| 2781 /// exception. | 2813 /// exception. |
| 2782 Future<ServiceObject> reload() { | 2814 Future<ServiceObject> reload() { |
| 2783 assert(kind != null); | 2815 assert(kind != null); |
| 2784 if (isDartCode) { | 2816 if (isDartCode) { |
| 2785 // We only reload Dart code. | 2817 // We only reload Dart code. |
| 2786 return super.reload(); | 2818 return super.reload(); |
| 2787 } | 2819 } |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3117 void _onPoll(_) { | 3149 void _onPoll(_) { |
| 3118 // Reload metrics and add a sample to each. | 3150 // Reload metrics and add a sample to each. |
| 3119 for (var metric in metrics) { | 3151 for (var metric in metrics) { |
| 3120 metric.reload().then((m) { | 3152 metric.reload().then((m) { |
| 3121 m.addSample(new MetricSample(m.value)); | 3153 m.addSample(new MetricSample(m.value)); |
| 3122 }); | 3154 }); |
| 3123 } | 3155 } |
| 3124 } | 3156 } |
| 3125 } | 3157 } |
| 3126 | 3158 |
| 3159 class Frame extends ServiceObject { |
| 3160 @observable int index; |
| 3161 @observable ServiceFunction function; |
| 3162 @observable SourceLocation location; |
| 3163 @observable Code code; |
| 3164 @observable List<ServiceMap> variables = new ObservableList<ServiceMap>(); |
| 3165 |
| 3166 Frame._empty(ServiceObject owner) : super._empty(owner); |
| 3167 |
| 3168 void _update(ObservableMap map, bool mapIsRef) { |
| 3169 assert(!mapIsRef); |
| 3170 _loaded = true; |
| 3171 _upgradeCollection(map, owner); |
| 3172 this.index = map['index']; |
| 3173 this.function = map['function']; |
| 3174 this.location = map['location']; |
| 3175 this.code = map['code']; |
| 3176 this.variables = map['vars']; |
| 3177 } |
| 3178 } |
| 3179 |
| 3180 |
| 3181 class ServiceMessage extends ServiceObject { |
| 3182 @observable int index; |
| 3183 @observable String messageObjectId; |
| 3184 @observable int size; |
| 3185 @observable ServiceFunction handler; |
| 3186 @observable SourceLocation location; |
| 3187 |
| 3188 ServiceMessage._empty(ServiceObject owner) : super._empty(owner); |
| 3189 |
| 3190 void _update(ObservableMap map, bool mapIsRef) { |
| 3191 assert(!mapIsRef); |
| 3192 _loaded = true; |
| 3193 _upgradeCollection(map, owner); |
| 3194 this.messageObjectId = map['messageObjectId']; |
| 3195 this.index = map['index']; |
| 3196 this.size = map['size']; |
| 3197 this.handler = map['handler']; |
| 3198 this.location = map['location']; |
| 3199 } |
| 3200 } |
| 3201 |
| 3202 |
| 3127 // Returns true if [map] is a service map. i.e. it has the following keys: | 3203 // Returns true if [map] is a service map. i.e. it has the following keys: |
| 3128 // 'id' and a 'type'. | 3204 // 'id' and a 'type'. |
| 3129 bool _isServiceMap(ObservableMap m) { | 3205 bool _isServiceMap(ObservableMap m) { |
| 3130 return (m != null) && (m['type'] != null); | 3206 return (m != null) && (m['type'] != null); |
| 3131 } | 3207 } |
| 3132 | 3208 |
| 3133 bool _hasRef(String type) => type.startsWith('@'); | 3209 bool _hasRef(String type) => type.startsWith('@'); |
| 3134 String _stripRef(String type) => (_hasRef(type) ? type.substring(1) : type); | 3210 String _stripRef(String type) => (_hasRef(type) ? type.substring(1) : type); |
| 3135 | 3211 |
| 3136 /// Recursively upgrades all [ServiceObject]s inside [collection] which must | 3212 /// Recursively upgrades all [ServiceObject]s inside [collection] which must |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3164 var v = list[i]; | 3240 var v = list[i]; |
| 3165 if ((v is ObservableMap) && _isServiceMap(v)) { | 3241 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 3166 list[i] = owner.getFromMap(v); | 3242 list[i] = owner.getFromMap(v); |
| 3167 } else if (v is ObservableList) { | 3243 } else if (v is ObservableList) { |
| 3168 _upgradeObservableList(v, owner); | 3244 _upgradeObservableList(v, owner); |
| 3169 } else if (v is ObservableMap) { | 3245 } else if (v is ObservableMap) { |
| 3170 _upgradeObservableMap(v, owner); | 3246 _upgradeObservableMap(v, owner); |
| 3171 } | 3247 } |
| 3172 } | 3248 } |
| 3173 } | 3249 } |
| OLD | NEW |