Skip to content

Commit ef0491e

Browse files
committed
Merged properties & references for guest languages
- not synchronized yet, computation not terminated on selection change - hacked resolving of node renderer, to be fixed yet
1 parent 9a7527e commit ef0491e

11 files changed

+1014
-393
lines changed

visualvm/heapviewer.truffle/src/org/graalvm/visualvm/heapviewer/truffle/TruffleLanguageHeapFragment.java

Lines changed: 3 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import org.graalvm.visualvm.heapviewer.HeapContext;
2828
import java.util.Collection;
29-
import java.util.Collections;
3029
import java.util.Iterator;
3130
import org.graalvm.visualvm.lib.jfluid.heap.Heap;
3231
import org.graalvm.visualvm.lib.jfluid.heap.Instance;
@@ -174,18 +173,16 @@ protected void addingObject(long size, long retained, String type) {
174173
types = computer.getTypes();
175174
}
176175

177-
178-
179176

180177
protected final Iterator<Instance> instancesIterator(String javaClassFqn) {
181-
return new InstancesIterator(HeapUtils.getSubclasses(heap, javaClassFqn));
178+
return HeapUtils.instancesIterator(HeapUtils.getSubclasses(heap, javaClassFqn));
182179
}
183180

184181
protected final Iterator<Instance> instancesIterator(String[] javaClassFqns) {
185182
List classes = new ArrayList();
186183
for (String fqn : javaClassFqns)
187184
classes.addAll(HeapUtils.getSubclasses(heap, fqn));
188-
return new InstancesIterator(classes);
185+
return HeapUtils.instancesIterator(classes);
189186
}
190187

191188

@@ -194,65 +191,6 @@ protected static String fragmentDescription(Instance langID, Heap heap) {
194191
}
195192

196193

197-
protected static class InstancesIterator implements Iterator<Instance> {
198-
private final Iterator<JavaClass> classIt;
199-
private Iterator<Instance> instanceIt;
200-
201-
public InstancesIterator(Collection<JavaClass> cls) {
202-
classIt = cls.iterator();
203-
instanceIt = Collections.EMPTY_LIST.iterator();
204-
}
205-
206-
@Override
207-
public boolean hasNext() {
208-
if (instanceIt.hasNext()) {
209-
return true;
210-
}
211-
if (!classIt.hasNext()) {
212-
return false;
213-
}
214-
instanceIt = classIt.next().getInstancesIterator();
215-
return hasNext();
216-
}
217-
218-
@Override
219-
public Instance next() {
220-
return instanceIt.next();
221-
}
222-
}
223-
224-
protected static abstract class ExcludingInstancesIterator implements Iterator<Instance> {
225-
private final Iterator<Instance> instancesIt;
226-
private Instance next;
227-
228-
protected ExcludingInstancesIterator(Iterator<Instance> it) {
229-
instancesIt = it;
230-
computeNext();
231-
}
232-
233-
@Override
234-
public boolean hasNext() {
235-
return next != null;
236-
}
237-
238-
@Override
239-
public Instance next() {
240-
Instance ret = next;
241-
computeNext();
242-
return ret;
243-
}
244-
245-
private void computeNext() {
246-
while (instancesIt.hasNext()) {
247-
next = instancesIt.next();
248-
if (!exclude(next)) return;
249-
}
250-
next = null;
251-
}
252-
253-
protected abstract boolean exclude(Instance instance);
254-
}
255-
256194
protected class ObjectsIterator implements Iterator<O> {
257195
private final Iterator<Instance> instancesIter;
258196

@@ -261,7 +199,7 @@ public ObjectsIterator(Iterator<Instance> iter) {
261199
}
262200

263201
public ObjectsIterator(Collection<JavaClass> cls) {
264-
instancesIter = new InstancesIterator(cls);
202+
instancesIter = HeapUtils.instancesIterator(cls);
265203
}
266204

267205
@Override
@@ -275,36 +213,4 @@ public O next() {
275213
}
276214
}
277215

278-
protected abstract class ExcludingObjectsIterator implements Iterator<O> {
279-
private final Iterator<O> objectsIt;
280-
private O next;
281-
282-
protected ExcludingObjectsIterator(Iterator<O> it) {
283-
objectsIt = it;
284-
computeNext();
285-
}
286-
287-
@Override
288-
public boolean hasNext() {
289-
return next != null;
290-
}
291-
292-
@Override
293-
public O next() {
294-
O ret = next;
295-
computeNext();
296-
return ret;
297-
}
298-
299-
private void computeNext() {
300-
while (objectsIt.hasNext()) {
301-
next = objectsIt.next();
302-
if (!exclude(next)) return;
303-
}
304-
next = null;
305-
}
306-
307-
protected abstract boolean exclude(O object);
308-
}
309-
310216
}

0 commit comments

Comments
 (0)