OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 code_view_element; | 5 library code_view_element; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'observatory_element.dart'; | 9 import 'observatory_element.dart'; |
| 10 import 'service_ref.dart'; |
10 import 'package:observatory/app.dart'; | 11 import 'package:observatory/app.dart'; |
11 import 'package:observatory/service.dart'; | 12 import 'package:observatory/service.dart'; |
12 import 'package:observatory/cpu_profile.dart'; | 13 import 'package:observatory/cpu_profile.dart'; |
13 import 'package:polymer/polymer.dart'; | 14 import 'package:polymer/polymer.dart'; |
14 | 15 |
15 class DisassemblyTable extends SortedTable { | 16 class DisassemblyTable extends SortedTable { |
16 DisassemblyTable(columns) : super(columns); | 17 DisassemblyTable(columns) : super(columns); |
17 } | 18 } |
18 | 19 |
19 class InlineTable extends SortedTable { | 20 class InlineTable extends SortedTable { |
20 InlineTable(columns) : super(columns); | 21 InlineTable(columns) : super(columns); |
21 } | 22 } |
22 | 23 |
23 @CustomTag('code-view') | 24 @CustomTag('code-view') |
24 class CodeViewElement extends ObservatoryElement { | 25 class CodeViewElement extends ObservatoryElement { |
25 @observable Code code; | 26 @observable Code code; |
26 ProfileCode get profile => code == null ? null : code.profile; | 27 ProfileCode get profile => code == null ? null : code.profile; |
27 DisassemblyTable disassemblyTable; | 28 DisassemblyTable disassemblyTable; |
28 InlineTable inlineTable; | 29 InlineTable inlineTable; |
29 | 30 |
30 CodeViewElement.created() : super.created() { | 31 CodeViewElement.created() : super.created() { |
31 // Create table models. | 32 // Create table models. |
32 var columns = [ | 33 var columns = [ |
33 new SortedTableColumn('Address'), | 34 new SortedTableColumn('Address'), |
34 new SortedTableColumn('Inclusive'), | 35 new SortedTableColumn('Inclusive'), |
35 new SortedTableColumn('Exclusive'), | 36 new SortedTableColumn('Exclusive'), |
36 new SortedTableColumn('Disassembly'), | 37 new SortedTableColumn('Disassembly'), |
| 38 new SortedTableColumn('Objects'), |
37 ]; | 39 ]; |
38 disassemblyTable = new DisassemblyTable(columns); | 40 disassemblyTable = new DisassemblyTable(columns); |
39 columns = [ | 41 columns = [ |
40 new SortedTableColumn('Address'), | 42 new SortedTableColumn('Address'), |
41 new SortedTableColumn('Inclusive'), | 43 new SortedTableColumn('Inclusive'), |
42 new SortedTableColumn('Exclusive'), | 44 new SortedTableColumn('Exclusive'), |
43 new SortedTableColumn('Functions'), | 45 new SortedTableColumn('Functions'), |
44 ]; | 46 ]; |
45 inlineTable = new InlineTable(columns); | 47 inlineTable = new InlineTable(columns); |
46 } | 48 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 166 |
165 void _updateDiasssemblyTable() { | 167 void _updateDiasssemblyTable() { |
166 disassemblyTable.clearRows(); | 168 disassemblyTable.clearRows(); |
167 if (code == null) { | 169 if (code == null) { |
168 return; | 170 return; |
169 } | 171 } |
170 for (CodeInstruction instruction in code.instructions) { | 172 for (CodeInstruction instruction in code.instructions) { |
171 var row = [formattedAddress(instruction), | 173 var row = [formattedAddress(instruction), |
172 formattedInclusive(instruction), | 174 formattedInclusive(instruction), |
173 formattedExclusive(instruction), | 175 formattedExclusive(instruction), |
174 instruction.human]; | 176 instruction.human, |
| 177 instruction.object]; |
175 disassemblyTable.addRow(new SortedTableRow(row)); | 178 disassemblyTable.addRow(new SortedTableRow(row)); |
176 } | 179 } |
177 } | 180 } |
178 | 181 |
179 void _addDisassemblyDOMRow() { | 182 void _addDisassemblyDOMRow() { |
180 var tableBody = $['disassemblyTableBody']; | 183 var tableBody = $['disassemblyTableBody']; |
181 assert(tableBody != null); | 184 assert(tableBody != null); |
182 var tr = new TableRowElement(); | 185 var tr = new TableRowElement(); |
183 | 186 |
184 var cell; | 187 var cell; |
185 | 188 |
186 // Add new space. | 189 // Add new space. |
187 cell = tr.insertCell(-1); | 190 cell = tr.insertCell(-1); |
188 cell.classes.add('monospace'); | 191 cell.classes.add('monospace'); |
189 cell = tr.insertCell(-1); | 192 cell = tr.insertCell(-1); |
190 cell.classes.add('monospace'); | 193 cell.classes.add('monospace'); |
191 cell = tr.insertCell(-1); | 194 cell = tr.insertCell(-1); |
192 cell.classes.add('monospace'); | 195 cell.classes.add('monospace'); |
193 cell = tr.insertCell(-1); | 196 cell = tr.insertCell(-1); |
194 cell.classes.add('monospace'); | 197 cell.classes.add('monospace'); |
| 198 cell = tr.insertCell(-1); |
| 199 cell.classes.add('monospace'); |
195 | 200 |
196 tableBody.children.add(tr); | 201 tableBody.children.add(tr); |
197 } | 202 } |
198 | 203 |
199 void _fillDisassemblyDOMRow(TableRowElement tr, int rowIndex) { | 204 void _fillDisassemblyDOMRow(TableRowElement tr, int rowIndex) { |
200 final row = disassemblyTable.rows[rowIndex]; | 205 final row = disassemblyTable.rows[rowIndex]; |
201 final n = row.values.length; | 206 final n = row.values.length; |
202 for (var i = 0; i < n; i++) { | 207 for (var i = 0; i < n; i++) { |
203 final cell = tr.children[i]; | 208 final cell = tr.children[i]; |
204 cell.title = row.values[i].toString(); | 209 final content = row.values[i]; |
205 cell.text = row.values[i].toString(); | 210 if (content is ServiceObject) { |
| 211 ServiceRefElement element = new Element.tag('any-service-ref'); |
| 212 element.ref = content; |
| 213 cell.append(element); |
| 214 } else if (content != null) { |
| 215 cell.text = content.toString(); |
| 216 } |
206 } | 217 } |
207 } | 218 } |
208 | 219 |
209 void _updateDisassemblyDOMTable() { | 220 void _updateDisassemblyDOMTable() { |
210 var tableBody = $['disassemblyTableBody']; | 221 var tableBody = $['disassemblyTableBody']; |
211 assert(tableBody != null); | 222 assert(tableBody != null); |
212 // Resize DOM table. | 223 // Resize DOM table. |
213 if (tableBody.children.length > disassemblyTable.sortedRows.length) { | 224 if (tableBody.children.length > disassemblyTable.sortedRows.length) { |
214 // Shrink the table. | 225 // Shrink the table. |
215 var deadRows = | 226 var deadRows = |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 var addressRangeString = formattedAddressRange(interval); | 298 var addressRangeString = formattedAddressRange(interval); |
288 var addressRangeElement = new SpanElement(); | 299 var addressRangeElement = new SpanElement(); |
289 addressRangeElement.classes.add('monospace'); | 300 addressRangeElement.classes.add('monospace'); |
290 addressRangeElement.text = addressRangeString; | 301 addressRangeElement.text = addressRangeString; |
291 addressRangeCell.children.clear(); | 302 addressRangeCell.children.clear(); |
292 addressRangeCell.children.add(addressRangeElement); | 303 addressRangeCell.children.add(addressRangeElement); |
293 } | 304 } |
294 | 305 |
295 for (var i = addressRangeColumn + 1; i < columns - 1; i++) { | 306 for (var i = addressRangeColumn + 1; i < columns - 1; i++) { |
296 var cell = tr.children[i]; | 307 var cell = tr.children[i]; |
297 cell.title = row.values[i].toString(); | |
298 cell.text = row.values[i].toString(); | 308 cell.text = row.values[i].toString(); |
299 } | 309 } |
300 var functions = row.values[functionsColumn]; | 310 var functions = row.values[functionsColumn]; |
301 var functionsCell = tr.children[functionsColumn]; | 311 var functionsCell = tr.children[functionsColumn]; |
302 functionsCell.children.clear(); | 312 functionsCell.children.clear(); |
303 for (var func in functions) { | 313 for (var func in functions) { |
304 var functionRef = new Element.tag('function-ref'); | 314 var functionRef = new Element.tag('function-ref'); |
305 functionRef.ref = func; | 315 functionRef.ref = func; |
306 functionsCell.children.add(functionRef); | 316 functionsCell.children.add(functionRef); |
307 var gap = new SpanElement(); | 317 var gap = new SpanElement(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 374 } |
365 | 375 |
366 void mouseOut(Event e, var detail, Node target) { | 376 void mouseOut(Event e, var detail, Node target) { |
367 var jt = _findJumpTarget(target); | 377 var jt = _findJumpTarget(target); |
368 if (jt == null) { | 378 if (jt == null) { |
369 return; | 379 return; |
370 } | 380 } |
371 jt.classes.remove('highlight'); | 381 jt.classes.remove('highlight'); |
372 } | 382 } |
373 } | 383 } |
OLD | NEW |