# HG changeset patch
# User never
# Date 1461860847 25200
# Thu Apr 28 09:27:27 2016 -0700
# Node ID 5f993d45eae7a78580200bba947a299946427de0
# Parent 9e21d8c18a7d181e5aeeaa989073171b2896f47b
8154483: update IGV with improvements from Graal
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,13 @@
import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
import com.sun.hotspot.igv.data.*;
+import com.sun.hotspot.igv.util.PropertiesSheet;
import java.awt.Image;
import java.util.List;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
+import org.openide.nodes.Sheet;
import org.openide.util.ImageUtilities;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
@@ -75,6 +77,16 @@
}
@Override
+ protected Sheet createSheet() {
+ Sheet s = super.createSheet();
+ if (children.folder instanceof Properties.Entity) {
+ Properties.Entity p = (Properties.Entity) children.folder;
+ PropertiesSheet.initializeSheet(p.getProperties(), s);
+ }
+ return s;
+ }
+
+ @Override
public Image getIcon(int i) {
return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png");
}
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -124,6 +124,8 @@
public void clear() {
document.clear();
+ root = new FolderNode(document);
+ manager.setRootContext(root);
}
@Override
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,31 +31,47 @@
import com.sun.hotspot.igv.data.serialization.ParseMonitor;
import com.sun.hotspot.igv.data.serialization.Parser;
import com.sun.hotspot.igv.settings.Settings;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
+import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;
-import javax.swing.Action;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.JFileChooser;
-import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.Exceptions;
+import org.openide.util.RequestProcessor;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
-import org.openide.util.RequestProcessor;
-import org.openide.util.actions.CallableSystemAction;
+import org.openide.util.actions.SystemAction;
/**
*
* @author Thomas Wuerthinger
*/
-public final class ImportAction extends CallableSystemAction {
+
+@ActionID(
+ category = "File",
+ id = "com.sun.hotspot.igv.coordinator.actions.ImportAction"
+)
+@ActionRegistration(
+ iconBase = "com/sun/hotspot/igv/coordinator/images/import.png",
+ displayName = "#CTL_ImportAction"
+)
+@ActionReferences({
+ @ActionReference(path = "Menu/File", position = 0),
+ @ActionReference(path = "Shortcuts", name = "C-O")
+})
+public final class ImportAction extends SystemAction {
private static final int WORKUNITS = 10000;
public static FileFilter getFileFilter() {
@@ -74,74 +90,77 @@
}
@Override
- public void performAction() {
-
+ public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
fc.setFileFilter(ImportAction.getFileFilter());
fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT)));
+ fc.setMultiSelectionEnabled(true);
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
+ for (final File file : fc.getSelectedFiles()) {
+ File dir = file;
+ if (!dir.isDirectory()) {
+ dir = dir.getParentFile();
+ }
- File dir = file;
- if (!dir.isDirectory()) {
- dir = dir.getParentFile();
- }
-
- Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
- try {
- final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
- final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName());
- handle.start(WORKUNITS);
- final long start = channel.size();
- ParseMonitor monitor = new ParseMonitor() {
- @Override
- public void updateProgress() {
- try {
- int prog = (int) (WORKUNITS * (double) channel.position() / (double) start);
- handle.progress(prog);
- } catch (IOException ex) {
- }
+ Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
+ try {
+ final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
+ final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName());
+ handle.start(WORKUNITS);
+ final long startTime = System.currentTimeMillis();
+ final long start = channel.size();
+ ParseMonitor monitor = new ParseMonitor() {
+ @Override
+ public void updateProgress() {
+ try {
+ int prog = (int) (WORKUNITS * (double) channel.position() / (double) start);
+ handle.progress(prog);
+ } catch (IOException ex) {
+ }
+ }
+ @Override
+ public void setState(String state) {
+ updateProgress();
+ handle.progress(state);
+ }
+ };
+ final GraphParser parser;
+ final OutlineTopComponent component = OutlineTopComponent.findInstance();
+ if (file.getName().endsWith(".xml")) {
+ parser = new Parser(channel, monitor, null);
+ } else if (file.getName().endsWith(".bgv")) {
+ parser = new BinaryParser(channel, monitor, component.getDocument(), null);
+ } else {
+ parser = null;
}
- @Override
- public void setState(String state) {
- updateProgress();
- handle.progress(state);
- }
- };
- final GraphParser parser;
- final OutlineTopComponent component = OutlineTopComponent.findInstance();
- if (file.getName().endsWith(".xml")) {
- parser = new Parser(channel, monitor, null);
- } else if (file.getName().endsWith(".bgv")) {
- parser = new BinaryParser(channel, monitor, component.getDocument(), null);
- } else {
- parser = null;
+ RequestProcessor.getDefault().post(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ final GraphDocument document = parser.parse();
+ if (document != null) {
+ SwingUtilities.invokeLater(new Runnable(){
+ @Override
+ public void run() {
+ component.requestActive();
+ component.getDocument().addGraphDocument(document);
+ }
+ });
+ }
+ } catch (IOException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ handle.finish();
+ long stop = System.currentTimeMillis();
+ Logger.getLogger(getClass().getName()).log(Level.INFO, "Loaded in " + file + " in " + ((stop - startTime) / 1000.0) + " seconds");
+ }
+ });
+ } catch (FileNotFoundException ex) {
+ Exceptions.printStackTrace(ex);
+ } catch (IOException ex) {
+ Exceptions.printStackTrace(ex);
}
- RequestProcessor.getDefault().post(new Runnable() {
- @Override
- public void run() {
- try {
- final GraphDocument document = parser.parse();
- if (document != null) {
- SwingUtilities.invokeLater(new Runnable(){
- @Override
- public void run() {
- component.requestActive();
- component.getDocument().addGraphDocument(document);
- }
- });
- }
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
- }
- handle.finish();
- }
- });
- } catch (FileNotFoundException ex) {
- Exceptions.printStackTrace(ex);
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
}
}
}
@@ -151,11 +170,6 @@
return NbBundle.getMessage(ImportAction.class, "CTL_ImportAction");
}
- public ImportAction() {
- putValue(Action.SHORT_DESCRIPTION, "Open XML graph document...");
- putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
- }
-
@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/import.png";
@@ -165,9 +179,4 @@
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
-
- @Override
- protected boolean asynchronous() {
- return false;
- }
}
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,14 +29,30 @@
import java.awt.event.KeyEvent;
import javax.swing.Action;
import javax.swing.KeyStroke;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
+import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.CallableSystemAction;
/**
*
* @author Thomas Wuerthinger
*/
+@ActionID(
+ category = "File",
+ id = "com.sun.hotspot.igv.coordinator.actions.SaveAllAction"
+)
+@ActionRegistration(
+ displayName = "#CTL_SaveAllAction"
+)
+@ActionReferences({
+ @ActionReference(path = "Menu/File", position = 0),
+ @ActionReference(path = "Shortcuts", name = "C-S")
+})
public final class SaveAllAction extends CallableSystemAction {
@Override
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml
@@ -18,6 +18,8 @@
+
+
@@ -43,11 +45,11 @@
-
+
-
+
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,11 +51,13 @@
}
public void addGraphDocument(GraphDocument document) {
- for (FolderElement e : document.elements) {
- e.setParent(this);
- this.addElement(e);
+ if (document != this) {
+ for (FolderElement e : document.elements) {
+ e.setParent(this);
+ this.addElement(e);
+ }
+ document.clear();
}
- document.clear();
getChangedEvent().fire();
}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -90,7 +90,9 @@
public void addNode(int id) {
InputNode node = graph.getNode(id);
assert node != null;
- assert !nodes.contains(node) : "duplicate : " + node;
+ // nodes.contains(node) is too expensive for large graphs so
+ // just make sure the Graph doesn't know it yet.
+ assert graph.getBlock(id) == null : "duplicate : " + node;
graph.setBlock(node, this);
nodes.add(node);
}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,9 @@
package com.sun.hotspot.igv.data;
import java.io.Serializable;
+import java.lang.ref.WeakReference;
import java.util.*;
+import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -36,7 +38,7 @@
public class Properties implements Serializable, Iterable {
public static final long serialVersionUID = 1L;
- private String[] map = new String[4];
+ protected String[] map = new String[4];
public Properties() {
}
@@ -102,6 +104,59 @@
System.arraycopy(p.map, 0, map, 0, p.map.length);
}
+ protected Properties(String[] map) {
+ this.map = map;
+ }
+
+ static class SharedProperties extends Properties {
+ int hashCode;
+
+ SharedProperties(String[] map) {
+ super(map);
+ this.hashCode = Arrays.hashCode(map);
+ }
+
+ @Override
+ protected void setPropertyInternal(String name, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof SharedProperties)) {
+ return super.equals(other);
+ }
+ SharedProperties props2 = (SharedProperties) other;
+ return Arrays.equals(map, props2.map);
+ }
+
+ @Override
+ public int hashCode() {
+ return hashCode;
+ }
+ }
+
+ private static class PropertyCache {
+ static WeakHashMap> immutableCache = new WeakHashMap<>();
+
+ static synchronized SharedProperties intern(Properties properties) {
+ String[] map = properties.map;
+ SharedProperties key = new SharedProperties(map);
+ WeakReference entry = immutableCache.get(key);
+ if (entry != null) {
+ SharedProperties props = entry.get();
+ if (props != null) {
+ return props;
+ }
+ }
+ immutableCache.put(key, new WeakReference<>(key));
+ return key;
+ }
+ }
+
public static class Entity implements Provider {
private Properties properties;
@@ -118,6 +173,10 @@
public Properties getProperties() {
return properties;
}
+
+ public void internProperties() {
+ properties = PropertyCache.intern(properties);
+ }
}
public interface PropertyMatcher {
@@ -322,8 +381,8 @@
public void setProperty(String name, String value) {
setPropertyInternal(name.intern(), value != null ? value.intern() : null);
}
- private void setPropertyInternal(String name, String value) {
+ protected void setPropertyInternal(String name, String value) {
for (int i = 0; i < map.length; i += 2) {
if (map[i] != null && map[i].equals(name)) {
String p = map[i + 1];
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.Charset;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -68,6 +69,8 @@
private static final String NO_BLOCK = "noBlock";
+ private static final Charset utf8 = Charset.forName("UTF-8");
+
private final GroupCallback callback;
private final List
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java
+++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
import com.sun.hotspot.igv.graph.Figure;
import com.sun.hotspot.igv.graph.InputSlot;
import com.sun.hotspot.igv.graph.OutputSlot;
+import com.sun.hotspot.igv.util.StringUtils;
import com.sun.hotspot.igv.view.DiagramScene;
import java.awt.*;
import java.awt.geom.Line2D;
@@ -148,7 +149,7 @@
private String generateToolTipText(List conn) {
StringBuilder sb = new StringBuilder();
for (Connection c : conn) {
- sb.append(c.getToolTipText());
+ sb.append(StringUtils.escapeHTML(c.getToolTipText()));
sb.append("
");
}
return sb.toString();
diff --git a/src/share/tools/IdealGraphVisualizer/nbproject/project.properties b/src/share/tools/IdealGraphVisualizer/nbproject/project.properties
--- a/src/share/tools/IdealGraphVisualizer/nbproject/project.properties
+++ b/src/share/tools/IdealGraphVisualizer/nbproject/project.properties
@@ -48,5 +48,5 @@
# Disable assertions for RequestProcessor to prevent annoying messages in case
# of multiple SceneAnimator update tasks in the default RequestProcessor.
-run.args.extra = -J-server -J-da:org.openide.util.RequestProcessor -J-Xms2g -J-Xmx8g -J-Djava.lang.Integer.IntegerCache.high=20000
+run.args.extra = -J-server -J-da:org.openide.util.RequestProcessor -J-Xms2g -J-Xmx8g -J-Djava.lang.Integer.IntegerCache.high=200000
debug.args.extra = -J-server -J-da:org.openide.util.RequestProcessor