annotate agent/src/share/classes/sun/jvm/hotspot/ui/ObjectListPanel.java @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents a61af66fc99e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.ui;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.awt.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import java.awt.event.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import javax.swing.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import javax.swing.table.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.ui.table.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import sun.jvm.hotspot.ui.tree.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 /** Lists objects along with their types */
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 public class ObjectListPanel extends SAPanel {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private ObjectListTableModel dataModel;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private JTable table;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private java.util.List elements;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private HeapProgressThunk thunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private boolean checkedForArrays;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private boolean hasArrays;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private int numColumns;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // For changing the text of the "Compute Liveness" button
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private JButton livenessButton;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private ActionListener livenessButtonListener;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private static final String showLivenessText = "Show Liveness";
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 /** Takes a List<Oop> in constructor, and an optional
a61af66fc99e Initial load
duke
parents:
diff changeset
57 HeapProgressThunk used if computing liveness */
a61af66fc99e Initial load
duke
parents:
diff changeset
58 public ObjectListPanel(java.util.List els,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 HeapProgressThunk thunk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 elements = els;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 this.thunk = thunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 computeNumColumns();
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 dataModel = new ObjectListTableModel();
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 table = new JTable(dataModel);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 JTableHeader header = table.getTableHeader();
a61af66fc99e Initial load
duke
parents:
diff changeset
73 header.setDefaultRenderer(new SortHeaderCellRenderer(header, dataModel));
a61af66fc99e Initial load
duke
parents:
diff changeset
74 header.addMouseListener(new SortHeaderMouseAdapter(table, dataModel));
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 JScrollPane scrollPane = new JScrollPane(table);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 add(scrollPane, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 JPanel panel = new JPanel();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
a61af66fc99e Initial load
duke
parents:
diff changeset
81 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
a61af66fc99e Initial load
duke
parents:
diff changeset
82 Box box = Box.createHorizontalBox();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 box.add(Box.createGlue());
a61af66fc99e Initial load
duke
parents:
diff changeset
84 JButton button = new JButton("Inspect");
a61af66fc99e Initial load
duke
parents:
diff changeset
85 button.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 fireShowInspector();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 });
a61af66fc99e Initial load
duke
parents:
diff changeset
90 box.add(button);
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 box.add(Box.createHorizontalStrut(20));
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Liveness button
a61af66fc99e Initial load
duke
parents:
diff changeset
95 button = new JButton();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 livenessButton = button;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (VM.getVM().getRevPtrs() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 button.setText("Compute Liveness");
a61af66fc99e Initial load
duke
parents:
diff changeset
99 livenessButtonListener = new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 fireComputeLiveness();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 };
a61af66fc99e Initial load
duke
parents:
diff changeset
104 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 button.setText("Show Liveness Path");
a61af66fc99e Initial load
duke
parents:
diff changeset
106 livenessButtonListener = new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 fireShowLiveness();
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 };
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 button.addActionListener(livenessButtonListener);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 box.add(button);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 box.add(Box.createGlue());
a61af66fc99e Initial load
duke
parents:
diff changeset
115 panel.add(box);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 add(panel, BorderLayout.SOUTH);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
121 //
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 private static class AddressWrapper implements Comparable {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 private Address address;
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 private AddressWrapper(Address address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 this.address = address;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return address.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 public int compareTo(Object o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 AddressWrapper wrapper = (AddressWrapper) o;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 Address addr = wrapper.address;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (AddressOps.lessThan(address, addr)) return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (AddressOps.greaterThan(address, addr)) return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 private class ObjectListTableModel extends SortableTableModel {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 public ObjectListTableModel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // Set the rows
a61af66fc99e Initial load
duke
parents:
diff changeset
146 this.elements = ObjectListPanel.this.elements;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 setComparator(new ObjectListComparator(this));
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public int getColumnCount() { return numColumns; }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public int getRowCount() { return elements.size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 public String getColumnName(int col) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 switch (col) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return "Address";
a61af66fc99e Initial load
duke
parents:
diff changeset
156 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return "Oop";
a61af66fc99e Initial load
duke
parents:
diff changeset
158 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if (hasArrays) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return "Length";
a61af66fc99e Initial load
duke
parents:
diff changeset
161 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return "Class Description";
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (hasArrays) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return "Class Description";
a61af66fc99e Initial load
duke
parents:
diff changeset
167 } else if (VM.getVM().getRevPtrs() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 return "Liveness";
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 case 4:
a61af66fc99e Initial load
duke
parents:
diff changeset
171 if (hasArrays && (VM.getVM().getRevPtrs() != null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return "Liveness";
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 throw new RuntimeException("Index " + col + " out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 public Object getValueAt(int row, int col) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 Oop oop = (Oop) elements.get(row);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 return getValueForColumn(oop, col);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 public Object getValueForColumn(Oop oop, int col) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 ByteArrayOutputStream bos = new ByteArrayOutputStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 switch (col) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
188 return new AddressWrapper(oop.getHandle());
a61af66fc99e Initial load
duke
parents:
diff changeset
189 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
190 oop.printValueOn(new PrintStream(bos));
a61af66fc99e Initial load
duke
parents:
diff changeset
191 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if (hasArrays) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 if (oop instanceof Array) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 return new Long(((Array) oop).getLength());
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 oop.getKlass().printValueOn(new PrintStream(bos));
a61af66fc99e Initial load
duke
parents:
diff changeset
200 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 case 3:
a61af66fc99e Initial load
duke
parents:
diff changeset
203 if (hasArrays) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 oop.getKlass().printValueOn(new PrintStream(bos));
a61af66fc99e Initial load
duke
parents:
diff changeset
205 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 if (VM.getVM().getRevPtrs() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if (VM.getVM().getRevPtrs().get(oop) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return "Alive";
a61af66fc99e Initial load
duke
parents:
diff changeset
210 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return "Dead";
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 case 4:
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if (hasArrays) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (VM.getVM().getRevPtrs() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 if (VM.getVM().getRevPtrs().get(oop) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 return "Alive";
a61af66fc99e Initial load
duke
parents:
diff changeset
220 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 return "Dead";
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
226 throw new RuntimeException("Column " + col + " out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 return bos.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 private class ObjectListComparator extends TableModelComparator {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 public ObjectListComparator(ObjectListTableModel model) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 super(model);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
238 * Returns the value for the comparing object for the
a61af66fc99e Initial load
duke
parents:
diff changeset
239 * column.
a61af66fc99e Initial load
duke
parents:
diff changeset
240 *
a61af66fc99e Initial load
duke
parents:
diff changeset
241 * @param obj Object that was passed for Comparator
a61af66fc99e Initial load
duke
parents:
diff changeset
242 * @param column the column to retrieve
a61af66fc99e Initial load
duke
parents:
diff changeset
243 */
a61af66fc99e Initial load
duke
parents:
diff changeset
244 public Object getValueForColumn(Object obj, int column) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 ObjectListTableModel omodel = (ObjectListTableModel)model;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 return omodel.getValueForColumn((Oop) obj, column);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 private void fireShowInspector() {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 int i = table.getSelectedRow();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 if (i < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 Oop oop = (Oop) elements.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 SAListener listener = (SAListener) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
261 listener.showInspector(new OopTreeNodeAdapter(oop, null));
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 private void fireComputeLiveness() {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 final Runnable cutoverButtonRunnable = new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 livenessButton.removeActionListener(livenessButtonListener);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 livenessButtonListener = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 livenessButton.addActionListener(new ActionListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 public void actionPerformed(ActionEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 fireShowLiveness();
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 });
a61af66fc99e Initial load
duke
parents:
diff changeset
275 computeNumColumns();
a61af66fc99e Initial load
duke
parents:
diff changeset
276 livenessButton.setEnabled(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 livenessButton.setText(showLivenessText);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 dataModel.fireTableStructureChanged();
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 };
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (VM.getVM().getRevPtrs() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 cutoverButtonRunnable.run();
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 final WorkerThread worker = new WorkerThread();
a61af66fc99e Initial load
duke
parents:
diff changeset
287 worker.invokeLater(new Runnable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 ReversePtrsAnalysis rev = new ReversePtrsAnalysis();
a61af66fc99e Initial load
duke
parents:
diff changeset
291 if (thunk != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 rev.setHeapProgressThunk(thunk);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294 rev.run();
a61af66fc99e Initial load
duke
parents:
diff changeset
295 cutoverButtonRunnable.run();
a61af66fc99e Initial load
duke
parents:
diff changeset
296 } finally {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 worker.shutdown();
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 });
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 private void fireShowLiveness() {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 if (VM.getVM().getRevPtrs() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 int i = table.getSelectedRow();
a61af66fc99e Initial load
duke
parents:
diff changeset
310 if (i < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
311 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 Oop oop = (Oop) elements.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
315 LivenessPathList list = LivenessAnalysis.computeAllLivenessPaths(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
316 if (list == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 return; // dead object
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 SAListener listener = (SAListener) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 listener.showLiveness(oop, list);
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 private void checkForArrays() {
a61af66fc99e Initial load
duke
parents:
diff changeset
327 if (checkedForArrays) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
328 checkedForArrays = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 for (Iterator iter = elements.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
330 if (iter.next() instanceof Array) {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 hasArrays = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
332 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 private void computeNumColumns() {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 checkForArrays();
a61af66fc99e Initial load
duke
parents:
diff changeset
339 numColumns = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
340 if (hasArrays) ++numColumns;
a61af66fc99e Initial load
duke
parents:
diff changeset
341 if (VM.getVM().getRevPtrs() != null) ++numColumns;
a61af66fc99e Initial load
duke
parents:
diff changeset
342 }
a61af66fc99e Initial load
duke
parents:
diff changeset
343 }