Skip to content

Commit fbb0738

Browse files
committed
Merge branch 'master' into graal
2 parents 9ab9d8f + 5d35535 commit fbb0738

28 files changed

+388
-210
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ First download or clone this repository into directory `visualvm`. There are two
1414

1515
## Configure the dependencies
1616

17-
Then extract the [NetBeans Platform 9.0 Dev binaries](visualvm/nb90_platform_27022018.zip) into directory `visualvm/visualvm` (should create `visualvm/visualvm/netbeans`).
17+
Then extract the [NetBeans Platform 9.0](visualvm/nb90_platform_07082018.zip) into directory `visualvm/visualvm` (should create `visualvm/visualvm/netbeans`).
1818

1919
## Build and run VisualVM tool
2020

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/ClassHierarchyPlugin.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public ClassHierarchyPlugin(HeapContext context, HeapViewerActions actions) {
7878
heap = context.getFragment().getHeap();
7979

8080
objectsView = new TreeTableView("java_objects_hierarchy", context, actions, TreeTableViewColumn.classesPlain(heap)) { // NOI18N
81-
protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
81+
protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
8282
JavaClass javaClass;
8383
synchronized (objectsView) { javaClass = selected; }
8484

@@ -96,6 +96,7 @@ protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID,
9696
SuperClassNode firstNode = null;
9797
SuperClassNode previousNode = null;
9898

99+
Thread worker = Thread.currentThread();
99100
while (javaClass != null) {
100101
node = new SuperClassNode(javaClass);
101102
if (firstNode == null) firstNode = node;
@@ -104,6 +105,8 @@ protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID,
104105
javaClass = javaClass.getSuperClass();
105106

106107
previousNode = node;
108+
109+
if (worker.isInterrupted()) throw new InterruptedException();
107110
}
108111

109112
node.setChildren(HeapViewerNode.NO_NODES);

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaArrayItemsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public boolean supportsNode(HeapViewerNode parent, Heap heap, String viewID) {
7676
}
7777
}
7878

79-
public HeapViewerNode[] getNodes(final HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
79+
public HeapViewerNode[] getNodes(final HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
8080
final Instance instance = HeapViewerNode.getValue(parent, DataType.INSTANCE, heap);
8181
if (instance == null) return null;
8282

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaClassesProvider.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static String getNoPackagesString(HeapViewerNodeFilter viewFilter) {
8484
}
8585
}
8686

87-
public static HeapViewerNode[] getHeapClasses(HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
87+
public static HeapViewerNode[] getHeapClasses(HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
8888
NodesComputer<JavaClass> computer = new NodesComputer<JavaClass>(heap.getAllClasses().size(), UIThresholds.MAX_TOPLEVEL_CLASSES) {
8989
protected boolean sorts(DataType dataType) {
9090
return true;
@@ -112,10 +112,12 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
112112
}
113113

114114

115-
public static HeapViewerNode[] getHeapPackages(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
115+
public static HeapViewerNode[] getHeapPackages(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
116116
List<HeapViewerNode> nodes = new ArrayList();
117117
Map<String, ClassesContainer.Objects> packages = new HashMap();
118118

119+
Thread worker = Thread.currentThread();
120+
119121
List<JavaClass> classes = heap.getAllClasses();
120122
for (JavaClass cls : classes) {
121123
String className = cls.getName();
@@ -135,6 +137,7 @@ public static HeapViewerNode[] getHeapPackages(HeapViewerNode parent, Heap heap,
135137
}
136138
node.add(cls, heap);
137139
}
140+
if (worker.isInterrupted()) throw new InterruptedException();
138141
}
139142

140143
return nodes.isEmpty() ? new HeapViewerNode[] { new TextNode(Classes_Messages.getNoPackagesString(viewFilter)) } :
@@ -164,7 +167,7 @@ private static String getNoItemsString(HeapViewerNodeFilter viewFilter) {
164167
}
165168
}
166169

167-
public static HeapViewerNode[] getHeapGCRoots(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress, int aggregation) {
170+
public static HeapViewerNode[] getHeapGCRoots(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress, int aggregation) throws InterruptedException {
168171
final List<GCRoot> gcroots = new ArrayList(heap.getGCRoots());
169172

170173
if (aggregation == 0) {
@@ -294,7 +297,7 @@ private static String getNoItemsString(HeapViewerNodeFilter viewFilter) {
294297
}
295298
}
296299

297-
public static HeapViewerNode[] getHeapDominators(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress, int aggregation) {
300+
public static HeapViewerNode[] getHeapDominators(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress, int aggregation) throws InterruptedException {
298301
if (!DataType.RETAINED_SIZE.valuesAvailable(heap))
299302
return new HeapViewerNode[] { new TextNode(Bundle.Dominators_Messages_NoRetainedSizes()) };
300303

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaDiffClassesProvider.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
*/
6565
class JavaDiffClassesProvider {
6666

67-
static HeapViewerNode[] getDiffHeapClasses(HeapViewerNode parent, final Heap heap1, List<ClassNode> diffClasses, boolean retained, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
67+
static HeapViewerNode[] getDiffHeapClasses(HeapViewerNode parent, final Heap heap1, List<ClassNode> diffClasses, boolean retained, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
6868
NodesComputer<ClassNode> computer = new NodesComputer<ClassNode>(diffClasses.size(), UIThresholds.MAX_TOPLEVEL_CLASSES) {
6969
protected boolean sorts(DataType dataType) {
7070
return true;
@@ -91,10 +91,12 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
9191
return nodes.length == 0 ? new HeapViewerNode[] { new TextNode(JavaClassesProvider.Classes_Messages.getNoClassesString(viewFilter)) } : nodes;
9292
}
9393

94-
static HeapViewerNode[] getDiffHeapPackages(HeapViewerNode parent, Heap heap1, List<ClassNode> diffClasses, boolean retained, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
94+
static HeapViewerNode[] getDiffHeapPackages(HeapViewerNode parent, Heap heap1, List<ClassNode> diffClasses, boolean retained, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
9595
List<HeapViewerNode> nodes = new ArrayList();
9696
Map<String, DiffPackageNode> packages = new HashMap();
9797

98+
Thread worker = Thread.currentThread();
99+
98100
for (ClassNode cls : diffClasses) {
99101
String className = cls.getName();
100102
int nameIdx = className.lastIndexOf('.'); // NOI18N
@@ -112,6 +114,7 @@ static HeapViewerNode[] getDiffHeapPackages(HeapViewerNode parent, Heap heap1, L
112114
}
113115
node.add(cls, heap1);
114116
}
117+
if (worker.isInterrupted()) throw new InterruptedException();
115118
}
116119

117120
return nodes.isEmpty() ? new HeapViewerNode[] { new TextNode(JavaClassesProvider.Classes_Messages.getNoPackagesString(viewFilter)) } :

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaDiffObjectsView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public JavaDiffObjectsView(HeapContext context1, File file2, final boolean compa
162162
}
163163

164164
objectsView = new PluggableTreeTableView("diff_java_objects", context1, actions, columns) { // NOI18N
165-
protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
165+
protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
166166
synchronized (statusLock) {
167167
if (diffClasses == null) return new HeapViewerNode[] { status };
168168
}

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaFieldsPlugin.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.graalvm.visualvm.heapviewer.ui.TreeTableViewColumn;
6666
import org.graalvm.visualvm.heapviewer.ui.UIThresholds;
6767
import org.graalvm.visualvm.heapviewer.utils.ExcludingIterator;
68+
import org.graalvm.visualvm.heapviewer.utils.InterruptibleIterator;
6869
import org.graalvm.visualvm.heapviewer.utils.NodesComputer;
6970
import org.graalvm.visualvm.heapviewer.utils.ProgressIterator;
7071
import org.graalvm.visualvm.heapviewer.utils.counters.InstanceCounter;
@@ -143,7 +144,7 @@ public JavaFieldsPlugin(HeapContext context, HeapViewerActions actions) {
143144
};
144145
objectsView = new TreeTableView("java_objects_fields", context, actions, columns) { // NOI18N
145146
@Override
146-
protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
147+
protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
147148
HeapViewerNode _selected;
148149
synchronized (objectsView) { _selected = selected; }
149150

@@ -312,7 +313,7 @@ static InstancesWrapper fromNode(HeapViewerNode node) {
312313
}
313314

314315

315-
private HeapViewerNode[] getClassFieldsHistogram(final InstancesWrapper instances, HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
316+
private HeapViewerNode[] getClassFieldsHistogram(final InstancesWrapper instances, HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
316317
final List<Field> fields = getAllInstanceFields(instances.getJavaClass());
317318
NodesComputer<Field> computer = new NodesComputer<Field>(fields.size(), UIThresholds.MAX_INSTANCE_FIELDS) {
318319
protected boolean sorts(DataType dataType) {
@@ -382,7 +383,7 @@ public String toString() {
382383

383384
abstract Iterator<Instance> instancesIterator();
384385

385-
protected HeapViewerNode[] lazilyComputeChildren(Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
386+
protected HeapViewerNode[] lazilyComputeChildren(Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
386387
String fieldTypeName = fieldType.getName();
387388

388389
if ("object".equals(fieldTypeName)) { // NOI18N
@@ -403,10 +404,9 @@ protected HeapViewerNode[] lazilyComputeChildren(Heap heap, String viewID, HeapV
403404
if (!computingChildren) return null;
404405
} finally {
405406
computingChildren = false;
407+
progress.finish();
406408
}
407409

408-
progress.finish();
409-
410410
valuesCount = values.size();
411411

412412
NodesComputer<InstanceCounter.Record> computer = new NodesComputer<InstanceCounter.Record>(valuesCount, 20) {
@@ -458,10 +458,9 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
458458
if (!computingChildren) return null;
459459
} finally {
460460
computingChildren = false;
461+
progress.finish();
461462
}
462463

463-
progress.finish();
464-
465464
valuesCount = counter.size();
466465

467466
NodesComputer<PrimitiveCounter.Record> computer = new NodesComputer<PrimitiveCounter.Record>(valuesCount, 20) {
@@ -550,9 +549,9 @@ protected Object getValue(DataType type, Heap heap) {
550549
}
551550

552551

553-
protected HeapViewerNode[] lazilyComputeChildren(Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
554-
552+
protected HeapViewerNode[] lazilyComputeChildren(Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
555553
final String fieldName = fieldName();
554+
556555
NodesComputer<Instance> computer = new NodesComputer<Instance>(valuesCount, 20) {
557556
protected boolean sorts(DataType dataType) {
558557
return true;
@@ -565,7 +564,7 @@ public boolean isLeaf() {
565564
};
566565
}
567566
protected ProgressIterator<Instance> objectsIterator(int index, Progress progress) {
568-
Iterator<Instance> fieldInstanceIterator = new ExcludingIterator<Instance>(instancesIterator()) {
567+
Iterator<Instance> fieldInstanceIterator = new ExcludingIterator<Instance>(new InterruptibleIterator(instancesIterator())) {
569568
@Override
570569
protected boolean exclude(Instance instance) {
571570
FieldValue value = getValueOfField(instance, fieldName);
@@ -584,6 +583,7 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
584583
return Bundle.JavaFieldsPlugin_FieldHistogramNodesContainer(firstNodeIdx, lastNodeIdx);
585584
}
586585
};
586+
587587
return computer.computeNodes(PrimitiveFieldValueNode.this, heap, viewID, null, dataTypes, sortOrders, progress);
588588

589589
}
@@ -655,9 +655,9 @@ protected Object getValue(DataType type, Heap heap) {
655655
}
656656

657657

658-
protected HeapViewerNode[] lazilyComputeChildren(Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
659-
658+
protected HeapViewerNode[] lazilyComputeChildren(Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
660659
final String fieldName = fieldName();
660+
661661
NodesComputer<Instance> computer = new NodesComputer<Instance>(valuesCount, 20) {
662662
protected boolean sorts(DataType dataType) {
663663
return true;
@@ -671,7 +671,7 @@ public boolean isLeaf() {
671671
}
672672
protected ProgressIterator<Instance> objectsIterator(int index, Progress progress) {
673673
final Instance _instance = getInstance();
674-
Iterator<Instance> fieldInstanceIterator = new ExcludingIterator<Instance>(instancesIterator()) {
674+
Iterator<Instance> fieldInstanceIterator = new ExcludingIterator<Instance>(new InterruptibleIterator(instancesIterator())) {
675675
@Override
676676
protected boolean exclude(Instance instance) {
677677
FieldValue value = getValueOfField(instance, fieldName);
@@ -692,9 +692,7 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
692692
}
693693
};
694694

695-
HeapViewerNode[] result = computer.computeNodes(InstanceFieldValueNode.this, heap, viewID, null, dataTypes, sortOrders, progress);
696-
697-
return result;
695+
return computer.computeNodes(InstanceFieldValueNode.this, heap, viewID, null, dataTypes, sortOrders, progress);
698696

699697
}
700698

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaFieldsProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@
6060
})
6161
public abstract class JavaFieldsProvider extends HeapViewerNode.Provider {
6262

63-
public HeapViewerNode[] getNodes(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
63+
public HeapViewerNode[] getNodes(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
6464
List<FieldValue> fields = getFields(parent, heap);
6565
return getNodes(fields, parent, heap, viewID, viewFilter, dataTypes, sortOrders, progress);
6666
}
6767

68-
static HeapViewerNode[] getNodes(final List<FieldValue> fields, final HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
68+
static HeapViewerNode[] getNodes(final List<FieldValue> fields, final HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
6969
if (fields == null) return null;
7070

7171
NodesComputer<Integer> computer = new NodesComputer<Integer>(fields.size(), UIThresholds.MAX_INSTANCE_FIELDS) {

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaInstancesProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public boolean supportsNode(HeapViewerNode parent, Heap heap, String viewID) {
7171
return parent instanceof ClassNode;
7272
}
7373

74-
public HeapViewerNode[] getNodes(final HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
74+
public HeapViewerNode[] getNodes(final HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
7575
JavaClass jclass = HeapViewerNode.getValue(parent, DataType.CLASS, heap);
7676
if (jclass == null) return null;
7777

@@ -102,7 +102,7 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
102102
}
103103

104104

105-
public static HeapViewerNode[] getHeapInstances(final HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) {
105+
public static HeapViewerNode[] getHeapInstances(final HeapViewerNode parent, final Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException {
106106
// TODO: might be faster to process just instances of the classes matching viewFilter, if defined
107107

108108
long totalInstancesL = heap.getSummary().getTotalLiveInstances();

0 commit comments

Comments
 (0)