| 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 library heap_map_element; | 5 library heap_map_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 import 'observatory_element.dart'; | 10 import 'observatory_element.dart'; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 var offset = 0; | 139 var offset = 0; |
| 140 var size = 0; | 140 var size = 0; |
| 141 for (var i = 0; i < objects.length; i += 2) { | 141 for (var i = 0; i < objects.length; i += 2) { |
| 142 size = objects[i]; | 142 size = objects[i]; |
| 143 offset += size; | 143 offset += size; |
| 144 if (offset > pageOffset) { | 144 if (offset > pageOffset) { |
| 145 pageOffset = offset - size; | 145 pageOffset = offset - size; |
| 146 break; | 146 break; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 return new ObjectInfo(int.parse(page['object_start']) + | 149 return new ObjectInfo(int.parse(page['objectStart']) + |
| 150 pageOffset * fragmentation['unit_size_bytes'], | 150 pageOffset * fragmentation['unitSizeBytes'], |
| 151 size * fragmentation['unit_size_bytes']); | 151 size * fragmentation['unitSizeBytes']); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void _handleMouseMove(MouseEvent event) { | 154 void _handleMouseMove(MouseEvent event) { |
| 155 var info = _objectAt(event.offset); | 155 var info = _objectAt(event.offset); |
| 156 var addressString = '${info.size}B @ 0x${info.address.toRadixString(16)}'; | 156 var addressString = '${info.size}B @ 0x${info.address.toRadixString(16)}'; |
| 157 var className = _classNameAt(event.offset); | 157 var className = _classNameAt(event.offset); |
| 158 status = (className == '') ? '-' : '$className $addressString'; | 158 status = (className == '') ? '-' : '$className $addressString'; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void _handleClick(MouseEvent event) { | 161 void _handleClick(MouseEvent event) { |
| 162 var address = _objectAt(event.offset).address.toRadixString(16); | 162 var address = _objectAt(event.offset).address.toRadixString(16); |
| 163 isolate.getObjectByAddress(address).then((result) { | 163 isolate.getObjectByAddress(address).then((result) { |
| 164 if (result is DartError) { | 164 if (result is DartError) { |
| 165 Logger.root.severe(result.message); | 165 Logger.root.severe(result.message); |
| 166 } else { | 166 } else if (result.type != 'Sentinel') { |
| 167 app.locationManager.go(gotoLink('/inspect', result)); | 167 app.locationManager.go(gotoLink('/inspect', result)); |
| 168 } | 168 } |
| 169 }); | 169 }); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void _updateFragmentationData() { | 172 void _updateFragmentationData() { |
| 173 if (fragmentation == null || _fragmentationCanvas == null) { | 173 if (fragmentation == null || _fragmentationCanvas == null) { |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 _updateClassList( | 176 _updateClassList( |
| 177 fragmentation['class_list'], fragmentation['free_class_id']); | 177 fragmentation['classList'], fragmentation['freeClassId']); |
| 178 var pages = fragmentation['pages']; | 178 var pages = fragmentation['pages']; |
| 179 var width = _fragmentationCanvas.parent.client.width; | 179 var width = _fragmentationCanvas.parent.client.width; |
| 180 _pageHeight = _PAGE_SEPARATION_HEIGHT + | 180 _pageHeight = _PAGE_SEPARATION_HEIGHT + |
| 181 fragmentation['page_size_bytes'] ~/ | 181 fragmentation['pageSizeBytes'] ~/ |
| 182 fragmentation['unit_size_bytes'] ~/ width; | 182 fragmentation['unitSizeBytes'] ~/ width; |
| 183 var height = min(_pageHeight * pages.length, _MAX_CANVAS_HEIGHT); | 183 var height = min(_pageHeight * pages.length, _MAX_CANVAS_HEIGHT); |
| 184 _fragmentationData = | 184 _fragmentationData = |
| 185 _fragmentationCanvas.context2D.createImageData(width, height); | 185 _fragmentationCanvas.context2D.createImageData(width, height); |
| 186 _fragmentationCanvas.width = _fragmentationData.width; | 186 _fragmentationCanvas.width = _fragmentationData.width; |
| 187 _fragmentationCanvas.height = _fragmentationData.height; | 187 _fragmentationCanvas.height = _fragmentationData.height; |
| 188 _renderPages(0); | 188 _renderPages(0); |
| 189 } | 189 } |
| 190 | 190 |
| 191 // Renders and draws asynchronously, one page at a time to avoid | 191 // Renders and draws asynchronously, one page at a time to avoid |
| 192 // blocking the UI. | 192 // blocking the UI. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 }).whenComplete(done); | 246 }).whenComplete(done); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void fragmentationChanged(oldValue) { | 249 void fragmentationChanged(oldValue) { |
| 250 // Async, in case attached has not yet run (observed in JS version). | 250 // Async, in case attached has not yet run (observed in JS version). |
| 251 new Future(() { | 251 new Future(() { |
| 252 _updateFragmentationData(); | 252 _updateFragmentationData(); |
| 253 }); | 253 }); |
| 254 } | 254 } |
| 255 } | 255 } |
| OLD | NEW |