--- a/hotspot/.hgignore Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/.hgignore Tue Jun 24 16:00:14 2008 -0700
@@ -2,3 +2,6 @@
^dist/
^nbproject/private/
^src/share/tools/hsdis/bin/
+^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/
+^src/share/tools/IdealGraphVisualizer/build/
+^src/share/tools/IdealGraphVisualizer/dist/
--- a/hotspot/src/os/linux/vm/hpi_linux.hpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/os/linux/vm/hpi_linux.hpp Tue Jun 24 16:00:14 2008 -0700
@@ -70,6 +70,10 @@
RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
}
+inline int hpi::raw_send(int fd, char *buf, int nBytes, int flags) {
+ return send(fd, buf, nBytes, flags);
+}
+
inline int hpi::timeout(int fd, long timeout) {
julong prevtime,newtime;
struct timeval t;
--- a/hotspot/src/os/solaris/vm/hpi_solaris.hpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/os/solaris/vm/hpi_solaris.hpp Tue Jun 24 16:00:14 2008 -0700
@@ -71,6 +71,10 @@
INTERRUPTIBLE_RETURN_INT(::send(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
}
+inline int hpi::raw_send(int fd, char *buf, int nBytes, int flags) {
+ RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
+}
+
// As both poll and select can be interrupted by signals, we have to be
// prepared to restart the system call after updating the timeout, unless
// a poll() is done with timeout == -1, in which case we repeat with this
--- a/hotspot/src/os/windows/vm/hpi_windows.hpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/os/windows/vm/hpi_windows.hpp Tue Jun 24 16:00:14 2008 -0700
@@ -102,6 +102,10 @@
fd, buf, nBytes, flags),
(fd, buf, nBytes, flags));
+inline int hpi::raw_send(int fd, char *buf, int nBytes, int flags) {
+ return send(fd, buf, nBytes, flags);
+}
+
HPIDECL(timeout, "timeout", _socket, Timeout, int, "%d",
(int fd, long timeout),
("fd = %d, timeout = %ld", fd, timeout),
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/build.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
+<!-- for some information on what you could do (e.g. targets to override). -->
+<!-- If you delete this file and reopen the project it will be recreated. -->
+<project name="com.sun.hotspot.igv.svg" default="netbeans" basedir=".">
+ <description>Builds, tests, and runs the project com.sun.hotspot.igv.svg.</description>
+ <import file="nbproject/build-impl.xml"/>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/manifest.mf Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.sun.hotspot.igv.svg
+OpenIDE-Module-Layer: com/sun/hotspot/igv/svg/layer.xml
+OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/svg/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/build-impl.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+-->
+<project name="com.sun.hotspot.igv.svg-impl" basedir="..">
+ <property file="nbproject/private/suite-private.properties"/>
+ <property file="nbproject/suite.properties"/>
+ <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
+ <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
+ <property file="${suite.dir}/nbproject/platform.properties"/>
+ <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ <property file="${user.properties.file}"/>
+ <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <nbmproject2:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
+ <condition>
+ <not>
+ <available file="${harness.dir}" type="dir"/>
+ </not>
+ </condition>
+ </fail>
+ <import file="${harness.dir}/build.xml"/>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/genfiles.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=ebcf0422
+build.xml.script.CRC32=d7a2678d
+build.xml.stylesheet.CRC32=79c3b980
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=ebcf0422
+nbproject/build-impl.xml.script.CRC32=57997f94
+nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.apisupport.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+ <code-name-base>com.sun.hotspot.igv.svg</code-name-base>
+ <suite-component/>
+ <module-dependencies/>
+ <public-packages>
+ <package>com.sun.hotspot.igv.svg</package>
+ </public-packages>
+ </data>
+ </configuration>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/suite.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,1 @@
+suite.dir=${basedir}/..
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.svg;
+
+import java.awt.Graphics2D;
+import java.io.Writer;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import org.w3c.dom.DOMImplementation;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class BatikSVG {
+
+ private static Constructor SVGGraphics2DConstructor;
+ private static Method Method_stream;
+ private static Method Method_createDefault;
+ private static Method Method_getDOMImplementation;
+ private static Method Method_setEmbeddedFontsOn;
+
+ public static Graphics2D createGraphicsObject() {
+ try {
+ if (SVGGraphics2DConstructor == null) {
+ ClassLoader cl = BatikSVG.class.getClassLoader();
+ Class Class_GenericDOMImplementation = cl.loadClass("org.apache.batik.dom.GenericDOMImplementation");
+ Class Class_SVGGeneratorContext = cl.loadClass("org.apache.batik.svggen.SVGGeneratorContext");
+ Class Class_SVGGraphics2D = cl.loadClass("org.apache.batik.svggen.SVGGraphics2D");
+ Method_getDOMImplementation = Class_GenericDOMImplementation.getDeclaredMethod("getDOMImplementation", new Class[0]);
+ Method_createDefault = Class_SVGGeneratorContext.getDeclaredMethod("createDefault", new Class[]{org.w3c.dom.Document.class});
+ Method_setEmbeddedFontsOn = Class_SVGGeneratorContext.getDeclaredMethod("setEmbeddedFontsOn", new Class[]{boolean.class});
+ Method_stream = Class_SVGGraphics2D.getDeclaredMethod("stream", Writer.class, boolean.class);
+ SVGGraphics2DConstructor = Class_SVGGraphics2D.getConstructor(Class_SVGGeneratorContext, boolean.class);
+ }
+ DOMImplementation dom = (DOMImplementation) Method_getDOMImplementation.invoke(null);
+ org.w3c.dom.Document document = dom.createDocument("http://www.w3.org/2000/svg", "svg", null);
+ Object ctx = Method_createDefault.invoke(null, document);
+ Method_setEmbeddedFontsOn.invoke(ctx, true);
+ Graphics2D svgGenerator = (Graphics2D) SVGGraphics2DConstructor.newInstance(ctx, true);
+ return svgGenerator;
+ } catch (ClassNotFoundException e) {
+ return null;
+ } catch (NoSuchMethodException e) {
+ return null;
+ } catch (IllegalAccessException e) {
+ return null;
+ } catch (InvocationTargetException e) {
+ return null;
+ } catch (InstantiationException e) {
+ return null;
+ }
+ }
+
+ public static void printToStream(Graphics2D svgGenerator, Writer stream, boolean useCSS) {
+ try {
+ Method_stream.invoke(svgGenerator, stream, useCSS);
+ } catch (IllegalAccessException e) {
+ assert false;
+ } catch (InvocationTargetException e) {
+ assert false;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/Bundle.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,1 @@
+OpenIDE-Module-Name=BatikSVGProxy
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/layer.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
+<filesystem>
+</filesystem>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/build.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
+<!-- for some information on what you could do (e.g. targets to override). -->
+<!-- If you delete this file and reopen the project it will be recreated. -->
+<project name="com.sun.hotspot.igv.bytecodes" default="netbeans" basedir=".">
+ <description>Builds, tests, and runs the project com.sun.hotspot.igv.bytecodes.</description>
+ <import file="nbproject/build-impl.xml"/>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/manifest.mf Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.sun.hotspot.igv.bytecodes
+OpenIDE-Module-Layer: com/sun/hotspot/igv/bytecodes/layer.xml
+OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/bytecodes/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/build-impl.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+-->
+<project name="com.sun.hotspot.igv.bytecodes-impl" basedir="..">
+ <property file="nbproject/private/suite-private.properties"/>
+ <property file="nbproject/suite.properties"/>
+ <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
+ <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
+ <property file="${suite.dir}/nbproject/platform.properties"/>
+ <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ <property file="${user.properties.file}"/>
+ <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <nbmproject2:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
+ <condition>
+ <not>
+ <available file="${harness.dir}" type="dir"/>
+ </not>
+ </condition>
+ </fail>
+ <import file="${harness.dir}/build.xml"/>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/genfiles.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=1dee290d
+build.xml.script.CRC32=d594034f
+build.xml.stylesheet.CRC32=79c3b980
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=1dee290d
+nbproject/build-impl.xml.script.CRC32=b4dab126
+nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/platform.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,29 @@
+# Deprecated since 5.0u1; for compatibility with 5.0:
+disabled.clusters=\
+ apisupport1,\
+ harness,\
+ ide8,\
+ java1,\
+ nb6.0,\
+ profiler2
+disabled.modules=\
+ org.netbeans.core.execution,\
+ org.netbeans.core.multiview,\
+ org.netbeans.core.output2,\
+ org.netbeans.modules.applemenu,\
+ org.netbeans.modules.autoupdate.services,\
+ org.netbeans.modules.autoupdate.ui,\
+ org.netbeans.modules.core.kit,\
+ org.netbeans.modules.favorites,\
+ org.netbeans.modules.javahelp,\
+ org.netbeans.modules.masterfs,\
+ org.netbeans.modules.options.keymap,\
+ org.netbeans.modules.sendopts,\
+ org.netbeans.modules.templates,\
+ org.openide.compat,\
+ org.openide.execution,\
+ org.openide.util.enumerations
+enabled.clusters=\
+ platform7
+nbjdk.active=JDK_1.6
+nbplatform.active=default
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.apisupport.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+ <code-name-base>com.sun.hotspot.igv.bytecodes</code-name-base>
+ <suite-component/>
+ <module-dependencies>
+ <dependency>
+ <code-name-base>com.sun.hotspot.igv.data</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.jdesktop.layout</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.4</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.explorer</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.11</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.nodes</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.2.0.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.util</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.9.0.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.windows</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.16</specification-version>
+ </run-dependency>
+ </dependency>
+ </module-dependencies>
+ <public-packages/>
+ </data>
+ </configuration>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/suite.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,1 @@
+suite.dir=${basedir}/..
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/Bundle.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,5 @@
+CTL_BytecodeViewAction=Open BytecodeView Window
+CTL_BytecodeViewTopComponent=BytecodeView Window
+CTL_SelectBytecodesAction=Select nodes
+HINT_BytecodeViewTopComponent=This is a BytecodeView window
+OpenIDE-Module-Name=Bytecodes
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.bytecodes;
+
+import com.sun.hotspot.igv.data.InputBytecode;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.InputNode;
+import com.sun.hotspot.igv.data.Properties;
+import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher;
+import java.awt.Image;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.swing.Action;
+import org.openide.nodes.AbstractNode;
+import org.openide.nodes.Children;
+import org.openide.nodes.Node;
+import org.openide.util.Utilities;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class BytecodeNode extends AbstractNode {
+
+ private Set<InputNode> nodes;
+
+ public BytecodeNode(InputBytecode bytecode, InputGraph graph, String bciValue) {
+
+ super(Children.LEAF);
+ this.setDisplayName(bytecode.getBci() + " " + bytecode.getName());
+
+ bciValue = bytecode.getBci() + " " + bciValue;
+ bciValue = bciValue.trim();
+
+ Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<InputNode>(graph.getNodes());
+ StringPropertyMatcher matcher = new StringPropertyMatcher("bci", bciValue);
+ List<InputNode> nodeList = selector.selectMultiple(matcher);
+ if (nodeList.size() > 0) {
+ nodes = new HashSet<InputNode>();
+ for (InputNode n : nodeList) {
+ nodes.add(n);
+ }
+ this.setDisplayName(this.getDisplayName() + " (" + nodes.size() + " nodes)");
+ }
+ }
+
+ @Override
+ public Image getIcon(int i) {
+ if (nodes != null) {
+ return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/link.gif");
+ } else {
+ return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/bytecode.gif");
+ }
+ }
+
+ @Override
+ public Image getOpenedIcon(int i) {
+ return getIcon(i);
+ }
+
+ @Override
+ public Action[] getActions(boolean b) {
+ return new Action[]{(Action) SelectBytecodesAction.findObject(SelectBytecodesAction.class, true)};
+ }
+
+ @Override
+ public Action getPreferredAction() {
+ return (Action) SelectBytecodesAction.findObject(SelectBytecodesAction.class, true);
+ }
+
+ @Override
+ public <T extends Node.Cookie> T getCookie(Class<T> aClass) {
+ if (aClass == SelectBytecodesCookie.class && nodes != null) {
+ return (T) (new SelectBytecodesCookie(nodes));
+ }
+ return super.getCookie(aClass);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.bytecodes;
+
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import org.openide.util.NbBundle;
+import org.openide.windows.TopComponent;
+
+/**
+ * @author Thomas Wuerthinger
+ */
+public class BytecodeViewAction extends AbstractAction {
+
+ public BytecodeViewAction() {
+ super(NbBundle.getMessage(BytecodeViewAction.class, "CTL_BytecodeViewAction"));
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ TopComponent win = BytecodeViewTopComponent.findInstance();
+ win.open();
+ win.requestActive();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.form Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="400" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="300" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+</Form>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.bytecodes;
+
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.services.InputGraphProvider;
+import java.awt.BorderLayout;
+import java.io.Serializable;
+import org.openide.ErrorManager;
+import org.openide.explorer.ExplorerManager;
+import org.openide.explorer.ExplorerUtils;
+import org.openide.explorer.view.BeanTreeView;
+import org.openide.util.Lookup;
+import org.openide.util.LookupEvent;
+import org.openide.util.LookupListener;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+import org.openide.windows.TopComponent;
+import org.openide.windows.WindowManager;
+
+/**
+ * @author Thomas Wuerthinger
+ */
+final class BytecodeViewTopComponent extends TopComponent implements ExplorerManager.Provider, LookupListener {
+
+ private static BytecodeViewTopComponent instance;
+ private static final String PREFERRED_ID = "BytecodeViewTopComponent";
+ private ExplorerManager manager;
+ private BeanTreeView treeView;
+ private Lookup.Result result = null;
+ private MethodNode rootNode;
+
+ private BytecodeViewTopComponent() {
+ initComponents();
+ setName(NbBundle.getMessage(BytecodeViewTopComponent.class, "CTL_BytecodeViewTopComponent"));
+ setToolTipText(NbBundle.getMessage(BytecodeViewTopComponent.class, "HINT_BytecodeViewTopComponent"));
+
+ manager = new ExplorerManager();
+ rootNode = new MethodNode(null, null, "");
+ manager.setRootContext(rootNode);
+
+ setLayout(new BorderLayout());
+
+ treeView = new BeanTreeView();
+ treeView.setRootVisible(false);
+ this.add(BorderLayout.CENTER, treeView);
+ associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 400, Short.MAX_VALUE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 300, Short.MAX_VALUE)
+ );
+ }// </editor-fold>//GEN-END:initComponents
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+ /**
+ * Gets default instance. Do not use directly: reserved for *.settings files only,
+ * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
+ * To obtain the singleton instance, use {@link findInstance}.
+ */
+ public static synchronized BytecodeViewTopComponent getDefault() {
+ if (instance == null) {
+ instance = new BytecodeViewTopComponent();
+ }
+ return instance;
+ }
+
+ /**
+ * Obtain the BytecodeViewTopComponent instance. Never call {@link #getDefault} directly!
+ */
+ public static synchronized BytecodeViewTopComponent findInstance() {
+ TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
+ if (win == null) {
+ ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find BytecodeView component. It will not be located properly in the window system.");
+ return getDefault();
+ }
+ if (win instanceof BytecodeViewTopComponent) {
+ return (BytecodeViewTopComponent) win;
+ }
+ ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior.");
+ return getDefault();
+ }
+
+ @Override
+ public int getPersistenceType() {
+ return TopComponent.PERSISTENCE_ALWAYS;
+ }
+
+ @Override
+ public void componentOpened() {
+ Lookup.Template tpl = new Lookup.Template(Object.class);
+ result = Utilities.actionsGlobalContext().lookup(tpl);
+ result.addLookupListener(this);
+ }
+
+ @Override
+ public void componentClosed() {
+ result.removeLookupListener(this);
+ result = null;
+ }
+
+ @Override
+ public Object writeReplace() {
+ return new ResolvableHelper();
+ }
+
+ @Override
+ protected String preferredID() {
+ return PREFERRED_ID;
+ }
+
+ public ExplorerManager getExplorerManager() {
+ return manager;
+ }
+
+ public void resultChanged(LookupEvent lookupEvent) {
+ InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class);
+ if (p != null) {
+ InputGraph graph = p.getGraph();
+ if (graph != null) {
+ Group g = graph.getGroup();
+ rootNode.update(graph, g.getMethod());
+ }
+ }
+ }
+
+ final static class ResolvableHelper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object readResolve() {
+ return BytecodeViewTopComponent.getDefault();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponentSettings.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
+<settings version="1.0">
+ <module name="com.sun.hotspot.igv.bytecodes" spec="1.0"/>
+ <instanceof class="org.openide.windows.TopComponent"/>
+ <instanceof class="com.sun.hotspot.igv.bytecodes.BytecodeViewTopComponent"/>
+ <instance class="com.sun.hotspot.igv.bytecodes.BytecodeViewTopComponent" method="getDefault"/>
+</settings>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponentWstcref.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd">
+<tc-ref version="2.0" >
+ <module name="com.sun.hotspot.igv.bytecodes" spec="1.0"/>
+ <tc-id id="BytecodeViewTopComponent"/>
+ <state opened="true"/>
+</tc-ref>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/MethodNode.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.bytecodes;
+
+import com.sun.hotspot.igv.data.InputBytecode;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.InputMethod;
+import java.awt.Image;
+import org.openide.nodes.AbstractNode;
+import org.openide.nodes.Children;
+import org.openide.nodes.Node;
+import org.openide.util.Utilities;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class MethodNode extends AbstractNode {
+
+ private static class MethodNodeChildren extends Children.Keys {
+
+ private InputMethod method;
+ private InputGraph graph;
+ private String bciString;
+
+ public MethodNodeChildren(InputMethod method, InputGraph graph, String bciString) {
+ this.method = method;
+ this.bciString = bciString;
+ this.graph = graph;
+ }
+
+ protected Node[] createNodes(Object object) {
+ assert object instanceof InputBytecode;
+ InputBytecode bc = (InputBytecode) object;
+ if (bc.getInlined() == null) {
+ return new Node[]{new BytecodeNode(bc, graph, bciString)};
+ } else {
+ return new Node[]{new BytecodeNode(bc, graph, bciString), new MethodNode(bc.getInlined(), graph, bc.getBci() + " " + bciString)};
+ }
+ }
+
+ @Override
+ public void addNotify() {
+ if (method != null) {
+ setKeys(method.getBytecodes());
+ }
+ }
+
+ public void setMethod(InputMethod method, InputGraph graph) {
+ this.method = method;
+ this.graph = graph;
+ addNotify();
+ }
+ }
+
+ /** Creates a new instance of MethodNode */
+ public MethodNode(InputMethod method, InputGraph graph, String bciString) {
+ super((method != null && method.getBytecodes().size() == 0) ? Children.LEAF : new MethodNodeChildren(method, graph, bciString));
+ if (method != null) {
+ this.setDisplayName(method.getName());
+ }
+ }
+
+ @Override
+ public Image getIcon(int i) {
+ return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/method.gif");
+ }
+
+ @Override
+ public Image getOpenedIcon(int i) {
+ return getIcon(i);
+ }
+
+ public void update(InputGraph graph, InputMethod method) {
+ ((MethodNodeChildren) this.getChildren()).setMethod(method, graph);
+ if (method != null) {
+ this.setDisplayName(method.getName());
+ }
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.bytecodes;
+
+import com.sun.hotspot.igv.data.services.InputGraphProvider;
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.CookieAction;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public final class SelectBytecodesAction extends CookieAction {
+
+ protected void performAction(Node[] activatedNodes) {
+ SelectBytecodesCookie c = activatedNodes[0].getCookie(SelectBytecodesCookie.class);
+ InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class);
+ if (p != null) {
+ p.setSelectedNodes(c.getNodes());
+ }
+ }
+
+ protected int mode() {
+ return CookieAction.MODE_EXACTLY_ONE;
+ }
+
+ public String getName() {
+ return NbBundle.getMessage(SelectBytecodesAction.class, "CTL_SelectBytecodesAction");
+ }
+
+ protected Class[] cookieClasses() {
+ return new Class[]{
+ SelectBytecodesCookie.class
+ };
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ putValue("noIconInMenu", Boolean.TRUE);
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ protected boolean asynchronous() {
+ return false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesCookie.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.bytecodes;
+
+import com.sun.hotspot.igv.data.InputNode;
+import java.util.Collections;
+import java.util.Set;
+import org.openide.nodes.Node;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class SelectBytecodesCookie implements Node.Cookie {
+
+ private Set<InputNode> nodes;
+
+ /** Creates a new instance of SelectBytecodesCookie */
+ public SelectBytecodesCookie(Set<InputNode> nodes) {
+ this.nodes = nodes;
+ }
+
+ public Set<InputNode> getNodes() {
+ return Collections.unmodifiableSet(nodes);
+ }
+}
Binary file hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/bytecode.gif has changed
Binary file hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/link.gif has changed
Binary file hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/method.gif has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/layer.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
+<filesystem>
+ <folder name="Actions">
+ <folder name="Edit">
+ <file name="com-sun-hotspot-igv-bytecodes-SelectBytecodesAction.instance"/>
+ </folder>
+ <folder name="Window">
+ <file name="com-sun-hotspot-igv-bytecodes-BytecodeViewAction.instance"/>
+ </folder>
+ </folder>
+ <folder name="Menu">
+ <folder name="Window">
+ <file name="BytecodeViewAction.shadow">
+ <attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-bytecodes-BytecodeViewAction.instance"/>
+ </file>
+ </folder>
+ </folder>
+ <folder name="Windows2">
+ <folder name="Components">
+ <file name="BytecodeViewTopComponent.settings" url="BytecodeViewTopComponentSettings.xml"/>
+ </folder>
+ <folder name="Modes">
+ <folder name="customRightTopMode">
+ <file name="BytecodeViewTopComponent.wstcref" url="BytecodeViewTopComponentWstcref.xml"/>
+ </folder>
+ </folder>
+ </folder>
+</filesystem>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/build.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
+<!-- for some information on what you could do (e.g. targets to override). -->
+<!-- If you delete this file and reopen the project it will be recreated. -->
+<project name="com.sun.hotspot.igv.controlflow" default="netbeans" basedir=".">
+ <description>Builds, tests, and runs the project com.sun.hotspot.igv.controlflow.</description>
+ <import file="nbproject/build-impl.xml"/>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/manifest.mf Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.sun.hotspot.igv.controlflow
+OpenIDE-Module-Layer: com/sun/hotspot/igv/controlflow/layer.xml
+OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/controlflow/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/build-impl.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+-->
+<project name="com.sun.hotspot.igv.controlflow-impl" basedir="..">
+ <property file="nbproject/private/suite-private.properties"/>
+ <property file="nbproject/suite.properties"/>
+ <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
+ <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
+ <property file="${suite.dir}/nbproject/platform.properties"/>
+ <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ <property file="${user.properties.file}"/>
+ <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <nbmproject2:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
+ <condition>
+ <not>
+ <available file="${harness.dir}" type="dir"/>
+ </not>
+ </condition>
+ </fail>
+ <import file="${harness.dir}/build.xml"/>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/genfiles.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=b524efb3
+build.xml.script.CRC32=79a27be9
+build.xml.stylesheet.CRC32=79c3b980
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=b524efb3
+nbproject/build-impl.xml.script.CRC32=582bdab7
+nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/platform.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,29 @@
+# Deprecated since 5.0u1; for compatibility with 5.0:
+disabled.clusters=\
+ apisupport1,\
+ harness,\
+ ide8,\
+ java1,\
+ nb6.0,\
+ profiler2
+disabled.modules=\
+ org.netbeans.core.execution,\
+ org.netbeans.core.multiview,\
+ org.netbeans.core.output2,\
+ org.netbeans.modules.applemenu,\
+ org.netbeans.modules.autoupdate.services,\
+ org.netbeans.modules.autoupdate.ui,\
+ org.netbeans.modules.core.kit,\
+ org.netbeans.modules.favorites,\
+ org.netbeans.modules.javahelp,\
+ org.netbeans.modules.masterfs,\
+ org.netbeans.modules.options.keymap,\
+ org.netbeans.modules.sendopts,\
+ org.netbeans.modules.templates,\
+ org.openide.compat,\
+ org.openide.execution,\
+ org.openide.util.enumerations
+enabled.clusters=\
+ platform7
+nbjdk.active=JDK_1.6
+nbplatform.active=default
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.apisupport.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+ <code-name-base>com.sun.hotspot.igv.controlflow</code-name-base>
+ <suite-component/>
+ <module-dependencies>
+ <dependency>
+ <code-name-base>com.sun.hotspot.igv.data</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>com.sun.hotspot.igv.hierarchicallayout</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>com.sun.hotspot.igv.layout</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.jdesktop.layout</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.4</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.api.visual</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>2.9</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.util</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.9.0.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.windows</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.16</specification-version>
+ </run-dependency>
+ </dependency>
+ </module-dependencies>
+ <public-packages/>
+ </data>
+ </configuration>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/suite.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,1 @@
+suite.dir=${basedir}/..
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.controlflow;
+
+import com.sun.hotspot.igv.data.InputBlockEdge;
+import com.sun.hotspot.igv.layout.Link;
+import com.sun.hotspot.igv.layout.Port;
+import java.awt.Point;
+import java.util.ArrayList;
+import java.util.List;
+import org.netbeans.api.visual.widget.ConnectionWidget;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class BlockConnectionWidget extends ConnectionWidget implements Link {
+
+ private BlockWidget from;
+ private BlockWidget to;
+ private Port inputSlot;
+ private Port outputSlot;
+ private List<Point> points;
+ private InputBlockEdge edge;
+
+ public BlockConnectionWidget(ControlFlowScene scene, InputBlockEdge edge) {
+ super(scene);
+
+ this.edge = edge;
+ this.from = (BlockWidget) scene.findWidget(edge.getFrom());
+ this.to = (BlockWidget) scene.findWidget(edge.getTo());
+ inputSlot = to.getInputSlot();
+ outputSlot = from.getOutputSlot();
+ points = new ArrayList<Point>();
+ }
+
+ public InputBlockEdge getEdge() {
+ return edge;
+ }
+
+ public Port getTo() {
+ return inputSlot;
+ }
+
+ public Port getFrom() {
+ return outputSlot;
+ }
+
+ public void setControlPoints(List<Point> p) {
+ this.points = p;
+ }
+
+ @Override
+ public List<Point> getControlPoints() {
+ return points;
+ }
+
+ @Override
+ public String toString() {
+ return "Connection[ " + from.toString() + " - " + to.toString() + "]";
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.controlflow;
+
+import com.sun.hotspot.igv.data.InputBlock;
+import com.sun.hotspot.igv.layout.Cluster;
+import com.sun.hotspot.igv.layout.Port;
+import com.sun.hotspot.igv.layout.Vertex;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Point;
+import org.netbeans.api.visual.border.BorderFactory;
+import org.netbeans.api.visual.model.ObjectState;
+import org.netbeans.api.visual.widget.LabelWidget;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class BlockWidget extends LabelWidget implements Vertex {
+
+ public static final Dimension SIZE = new Dimension(20, 20);
+ private InputBlock block;
+ private Port inputSlot;
+ private Port outputSlot;
+ private Cluster cluster;
+ private boolean root;
+ private static final Font font = new Font(Font.SERIF, Font.PLAIN, 12);
+ private static final Font boldFont = font.deriveFont(Font.BOLD);
+ public static final Color NORMAL_FOREGROUND_COLOR = Color.BLACK;
+ public static final Color HOVER_FOREGROUND_COLOR = Color.BLUE;
+
+ /** Creates a new instance of BlockWidget */
+ public BlockWidget(ControlFlowScene scene, InputBlock block) {
+ super(scene);
+ this.block = block;
+ this.setLabel(block.getName());
+ this.setForeground(NORMAL_FOREGROUND_COLOR);
+ this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR));
+ this.setMinimumSize(SIZE);
+ this.setMaximumSize(SIZE);
+
+ this.setFont(font);
+
+ final BlockWidget widget = this;
+ inputSlot = new Port() {
+
+ public Point getRelativePosition() {
+ return new Point((int) (SIZE.getWidth() / 2), (int) (SIZE.getHeight() / 2));
+ }
+
+ public Vertex getVertex() {
+ return widget;
+ }
+ };
+
+ outputSlot = new Port() {
+
+ public Point getRelativePosition() {
+ return new Point((int) (SIZE.getWidth() / 2), (int) (SIZE.getHeight() / 2));
+ }
+
+ public Vertex getVertex() {
+ return widget;
+ }
+ };
+ }
+
+ public Port getInputSlot() {
+ return inputSlot;
+ }
+
+ public Port getOutputSlot() {
+ return outputSlot;
+ }
+
+ public InputBlock getBlock() {
+ return block;
+ }
+
+ public Dimension getSize() {
+ return SIZE;
+ }
+
+ public void setPosition(Point p) {
+ this.setPreferredLocation(p);
+ }
+
+ @Override
+ public String toString() {
+ return block.getName();
+ }
+
+ public Point getPosition() {
+ return this.getPreferredLocation();
+ }
+
+ public Cluster getCluster() {
+ return cluster;
+ }
+
+ public boolean isRoot() {
+ return root;
+ }
+
+ public void setCluster(Cluster c) {
+ cluster = c;
+ }
+
+ public void setRoot(boolean b) {
+ root = b;
+ }
+
+ public int compareTo(Vertex o) {
+ return toString().compareTo(o.toString());
+ }
+
+ @Override
+ protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
+ super.notifyStateChanged(previousState, state);
+
+ if (previousState.isHovered() != state.isHovered()) {
+ if (state.isHovered()) {
+ this.setBorder(BorderFactory.createLineBorder(1, HOVER_FOREGROUND_COLOR));
+ } else {
+ this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR));
+ }
+ }
+
+ if (previousState.isSelected() != state.isSelected()) {
+ if (state.isSelected()) {
+ this.setFont(boldFont);
+ } else {
+ this.setFont(font);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,4 @@
+CTL_ControlFlowAction=Open ControlFlow Window
+CTL_ControlFlowTopComponent=ControlFlow Window
+HINT_ControlFlowTopComponent=This is a ControlFlow window
+OpenIDE-Module-Name=ControlFlow
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.controlflow;
+
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import org.openide.util.NbBundle;
+import org.openide.windows.TopComponent;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class ControlFlowAction extends AbstractAction {
+
+ public ControlFlowAction() {
+ super(NbBundle.getMessage(ControlFlowAction.class, "CTL_ControlFlowAction"));
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ TopComponent win = ControlFlowTopComponent.findInstance();
+ win.open();
+ win.requestActive();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,296 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.controlflow;
+
+import com.sun.hotspot.igv.data.InputBlock;
+import com.sun.hotspot.igv.data.InputBlockEdge;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.services.InputGraphProvider;
+import com.sun.hotspot.igv.data.InputNode;
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+import javax.swing.BorderFactory;
+import org.netbeans.api.visual.action.ActionFactory;
+import org.netbeans.api.visual.action.MoveProvider;
+import org.netbeans.api.visual.action.RectangularSelectDecorator;
+import org.netbeans.api.visual.action.RectangularSelectProvider;
+import org.netbeans.api.visual.action.SelectProvider;
+import org.netbeans.api.visual.action.WidgetAction;
+import org.netbeans.api.visual.anchor.AnchorFactory;
+import org.netbeans.api.visual.anchor.AnchorShape;
+import com.sun.hotspot.igv.controlflow.HierarchicalGraphLayout;
+import org.netbeans.api.visual.layout.LayoutFactory;
+import org.netbeans.api.visual.router.RouterFactory;
+import org.netbeans.api.visual.widget.LayerWidget;
+import org.netbeans.api.visual.widget.Widget;
+import org.netbeans.api.visual.graph.GraphScene;
+import org.netbeans.api.visual.graph.layout.GraphLayout;
+import org.netbeans.api.visual.layout.SceneLayout;
+import org.netbeans.api.visual.widget.ConnectionWidget;
+import org.openide.util.Lookup;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider {
+
+ private Set<BlockWidget> selection;
+ private Hashtable<InputBlock, BlockWidget> blockMap;
+ private InputGraph oldGraph;
+ private LayerWidget edgeLayer;
+ private LayerWidget mainLayer;
+ private LayerWidget selectLayer;
+ private WidgetAction hoverAction = this.createWidgetHoverAction();
+ private WidgetAction selectAction = ActionFactory.createSelectAction(this);
+ private WidgetAction moveAction = ActionFactory.createMoveAction(null, this);
+
+ public ControlFlowScene() {
+ selection = new HashSet<BlockWidget>();
+
+ this.getInputBindings().setZoomActionModifiers(0);
+ this.setLayout(LayoutFactory.createAbsoluteLayout());
+
+ mainLayer = new LayerWidget(this);
+ this.addChild(mainLayer);
+
+ edgeLayer = new LayerWidget(this);
+ this.addChild(edgeLayer);
+
+ selectLayer = new LayerWidget(this);
+ this.addChild(selectLayer);
+
+ this.getActions().addAction(hoverAction);
+ this.getActions().addAction(selectAction);
+ this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this));
+ this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1));
+ }
+
+ public void setGraph(InputGraph g) {
+ if (g == oldGraph) {
+ return;
+ }
+ oldGraph = g;
+
+ ArrayList<InputBlock> blocks = new ArrayList<InputBlock>(this.getNodes());
+ for (InputBlock b : blocks) {
+ removeNode(b);
+ }
+
+ ArrayList<InputBlockEdge> edges = new ArrayList<InputBlockEdge>(this.getEdges());
+ for (InputBlockEdge e : edges) {
+ removeEdge(e);
+ }
+
+ for (InputBlock b : g.getBlocks()) {
+ addNode(b);
+ }
+
+ for (InputBlock b : g.getBlocks()) {
+ for (InputBlockEdge e : b.getOutputs()) {
+ addEdge(e);
+ assert g.getBlocks().contains(e.getFrom());
+ assert g.getBlocks().contains(e.getTo());
+ this.setEdgeSource(e, e.getFrom());
+ this.setEdgeTarget(e, e.getTo());
+ }
+ }
+
+ GraphLayout layout = new HierarchicalGraphLayout();//GridGraphLayout();
+ SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(this, layout);
+ sceneLayout.invokeLayout();
+
+ this.validate();
+ }
+
+ public BlockWidget getBlockWidget(InputBlock b) {
+ return blockMap.get(b);
+ }
+
+ public void clearSelection() {
+ for (BlockWidget w : selection) {
+ w.setState(w.getState().deriveSelected(false));
+ }
+ selection.clear();
+ selectionChanged();
+ }
+
+ public void selectionChanged() {
+ InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class);
+ if (p != null) {
+ Set<InputNode> inputNodes = new HashSet<InputNode>();
+ for (BlockWidget w : selection) {
+ inputNodes.addAll(w.getBlock().getNodes());
+ }
+ p.setSelectedNodes(inputNodes);
+ }
+ }
+
+ public void addToSelection(BlockWidget widget) {
+ widget.setState(widget.getState().deriveSelected(true));
+ selection.add(widget);
+ selectionChanged();
+ }
+
+ public void removeFromSelection(BlockWidget widget) {
+ widget.setState(widget.getState().deriveSelected(false));
+ selection.remove(widget);
+ selectionChanged();
+ }
+
+ public boolean isAimingAllowed(Widget widget, Point point, boolean b) {
+ return false;
+ }
+
+ public boolean isSelectionAllowed(Widget widget, Point point, boolean b) {
+ return true;
+ }
+
+ public void select(Widget widget, Point point, boolean change) {
+ if (widget == this) {
+ clearSelection();
+ } else {
+
+ assert widget instanceof BlockWidget;
+ BlockWidget bw = (BlockWidget) widget;
+ if (change) {
+ if (selection.contains(bw)) {
+ removeFromSelection(bw);
+ } else {
+ addToSelection(bw);
+ }
+ } else {
+ if (!selection.contains(bw)) {
+ clearSelection();
+ addToSelection(bw);
+ }
+ }
+ }
+ }
+
+ public void movementStarted(Widget widget) {
+ }
+
+ public void movementFinished(Widget widget) {
+ }
+
+ public Point getOriginalLocation(Widget widget) {
+ return widget.getPreferredLocation();
+ }
+
+ public void setNewLocation(Widget widget, Point location) {
+ Point originalLocation = getOriginalLocation(widget);
+ int xOffset = location.x - originalLocation.x;
+ int yOffset = location.y - originalLocation.y;
+ for (Widget w : this.selection) {
+ Point p = new Point(w.getPreferredLocation());
+ p.translate(xOffset, yOffset);
+ w.setPreferredLocation(p);
+ }
+
+ }
+
+ public Widget createSelectionWidget() {
+ Widget widget = new Widget(this);
+ widget.setOpaque(false);
+ widget.setBorder(BorderFactory.createLineBorder(Color.black, 2));
+ widget.setForeground(Color.red);
+ return widget;
+ }
+
+ public void performSelection(Rectangle rectangle) {
+
+ if (rectangle.width < 0) {
+ rectangle.x += rectangle.width;
+ rectangle.width *= -1;
+ }
+
+ if (rectangle.height < 0) {
+ rectangle.y += rectangle.height;
+ rectangle.height *= -1;
+ }
+
+ boolean changed = false;
+ for (InputBlock b : this.getNodes()) {
+ BlockWidget w = (BlockWidget) findWidget(b);
+ Rectangle r = new Rectangle(w.getBounds());
+ r.setLocation(w.getLocation());
+ if (r.intersects(rectangle)) {
+ if (!selection.contains(w)) {
+ changed = true;
+ selection.add(w);
+ w.setState(w.getState().deriveSelected(true));
+ }
+ } else {
+ if (selection.contains(w)) {
+ changed = true;
+ selection.remove(w);
+ w.setState(w.getState().deriveSelected(false));
+ }
+ }
+ }
+
+ if (changed) {
+ selectionChanged();
+ }
+
+ }
+
+ protected Widget attachNodeWidget(InputBlock node) {
+ BlockWidget w = new BlockWidget(this, node);
+ mainLayer.addChild(w);
+ w.getActions().addAction(hoverAction);
+ w.getActions().addAction(selectAction);
+ w.getActions().addAction(moveAction);
+ return w;
+ }
+
+ protected Widget attachEdgeWidget(InputBlockEdge edge) {
+ ConnectionWidget w = new BlockConnectionWidget(this, edge);
+ w.setRouter(RouterFactory.createDirectRouter());
+ w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
+ edgeLayer.addChild(w);
+ return w;
+ }
+
+ protected void attachEdgeSourceAnchor(InputBlockEdge edge, InputBlock oldSourceNode, InputBlock sourceNode) {
+ Widget w = this.findWidget(edge);
+ assert w instanceof ConnectionWidget;
+ ConnectionWidget cw = (ConnectionWidget) w;
+ cw.setSourceAnchor(AnchorFactory.createRectangularAnchor(findWidget(sourceNode)));
+
+ }
+
+ protected void attachEdgeTargetAnchor(InputBlockEdge edge, InputBlock oldTargetNode, InputBlock targetNode) {
+ Widget w = this.findWidget(edge);
+ assert w instanceof ConnectionWidget;
+ ConnectionWidget cw = (ConnectionWidget) w;
+ cw.setTargetAnchor(AnchorFactory.createRectangularAnchor(findWidget(targetNode)));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="400" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <EmptySpace min="0" pref="300" max="32767" attributes="0"/>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+</Form>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.controlflow;
+
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.services.InputGraphProvider;
+import java.awt.BorderLayout;
+import java.io.Serializable;
+import javax.swing.JScrollPane;
+import org.openide.ErrorManager;
+import org.openide.util.Lookup;
+import org.openide.util.LookupEvent;
+import org.openide.util.LookupListener;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+import org.openide.windows.TopComponent;
+import org.openide.windows.WindowManager;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+final class ControlFlowTopComponent extends TopComponent implements LookupListener {
+
+ private static ControlFlowTopComponent instance;
+ private Lookup.Result result = null;
+ private static final String PREFERRED_ID = "ControlFlowTopComponent";
+ private ControlFlowScene scene;
+
+ private ControlFlowTopComponent() {
+ initComponents();
+ setName(NbBundle.getMessage(ControlFlowTopComponent.class, "CTL_ControlFlowTopComponent"));
+ setToolTipText(NbBundle.getMessage(ControlFlowTopComponent.class, "HINT_ControlFlowTopComponent"));
+
+ scene = new ControlFlowScene();
+ this.setLayout(new BorderLayout());
+ this.associateLookup(scene.getLookup());
+
+
+ JScrollPane panel = new JScrollPane(scene.createView());
+ this.add(panel, BorderLayout.CENTER);
+ }
+
+ @Override
+ public void requestFocus() {
+ super.requestFocus();
+ scene.getView().requestFocus();
+ }
+
+ @Override
+ public boolean requestFocusInWindow() {
+ super.requestFocusInWindow();
+ return scene.getView().requestFocusInWindow();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 400, Short.MAX_VALUE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 300, Short.MAX_VALUE)
+ );
+ }// </editor-fold>//GEN-END:initComponents
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+ /**
+ * Gets default instance. Do not use directly: reserved for *.settings files only,
+ * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
+ * To obtain the singleton instance, use {@link findInstance}.
+ */
+ public static synchronized ControlFlowTopComponent getDefault() {
+ if (instance == null) {
+ instance = new ControlFlowTopComponent();
+ }
+ return instance;
+ }
+
+ /**
+ * Obtain the ControlFlowTopComponent instance. Never call {@link #getDefault} directly!
+ */
+ public static synchronized ControlFlowTopComponent findInstance() {
+ TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
+ if (win == null) {
+ ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find ControlFlow component. It will not be located properly in the window system.");
+ return getDefault();
+ }
+ if (win instanceof ControlFlowTopComponent) {
+ return (ControlFlowTopComponent) win;
+ }
+ ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior.");
+ return getDefault();
+ }
+
+ @Override
+ public int getPersistenceType() {
+ return TopComponent.PERSISTENCE_ALWAYS;
+ }
+
+ @Override
+ public void componentOpened() {
+ Lookup.Template tpl = new Lookup.Template(Object.class);
+ result = Utilities.actionsGlobalContext().lookup(tpl);
+ result.addLookupListener(this);
+ }
+
+ @Override
+ public void componentClosed() {
+ result.removeLookupListener(this);
+ result = null;
+ }
+
+ public void resultChanged(LookupEvent lookupEvent) {
+
+ InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class);
+ if (p != null) {
+ InputGraph g = p.getGraph();
+ if (g != null) {
+ scene.setGraph(g);
+ }
+ }
+ }
+
+ @Override
+ public Object writeReplace() {
+ return new ResolvableHelper();
+ }
+
+ @Override
+ protected String preferredID() {
+ return PREFERRED_ID;
+ }
+
+ @Override
+ public void requestActive() {
+ scene.getView().requestFocusInWindow();
+ super.requestActive();
+ }
+
+ final static class ResolvableHelper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object readResolve() {
+ return ControlFlowTopComponent.getDefault();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentSettings.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
+<settings version="1.0">
+ <module name="com.sun.hotspot.igv.controlflow" spec="1.0"/>
+ <instanceof class="org.openide.windows.TopComponent"/>
+ <instanceof class="com.sun.hotspot.igv.controlflow.ControlFlowTopComponent"/>
+ <instance class="com.sun.hotspot.igv.controlflow.ControlFlowTopComponent" method="getDefault"/>
+</settings>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentWstcref.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd">
+<tc-ref version="2.0" >
+ <module name="com.sun.hotspot.igv.controlflow" spec="1.0"/>
+ <tc-id id="ControlFlowTopComponent"/>
+ <state opened="true"/>
+</tc-ref>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.controlflow;
+
+import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager;
+import com.sun.hotspot.igv.layout.Cluster;
+import com.sun.hotspot.igv.layout.LayoutGraph;
+import com.sun.hotspot.igv.layout.Link;
+import com.sun.hotspot.igv.layout.Port;
+import com.sun.hotspot.igv.layout.Vertex;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.netbeans.api.visual.graph.layout.GraphLayout;
+import org.netbeans.api.visual.graph.layout.UniversalGraph;
+import org.netbeans.api.visual.widget.Widget;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
+
+ public HierarchicalGraphLayout() {
+ }
+
+ private class LinkWrapper implements Link {
+
+ private VertexWrapper from;
+ private VertexWrapper to;
+
+ public LinkWrapper(VertexWrapper from, VertexWrapper to) {
+ this.from = from;
+ this.to = to;
+ }
+
+ public Port getFrom() {
+ return from.getSlot();
+ }
+
+ public Port getTo() {
+ return to.getSlot();
+ }
+
+ public List<Point> getControlPoints() {
+ return new ArrayList<Point>();
+ }
+
+ public void setControlPoints(List<Point> list) {
+ // Do nothing for now
+ }
+ }
+
+ private class VertexWrapper implements Vertex {
+
+ private N node;
+ private UniversalGraph<N, E> graph;
+ private Port slot;
+ private Point position;
+
+ public VertexWrapper(N node, UniversalGraph<N, E> graph) {
+ this.node = node;
+ this.graph = graph;
+ final VertexWrapper vertex = this;
+ this.slot = new Port() {
+
+ public Vertex getVertex() {
+ return vertex;
+ }
+
+ public Point getRelativePosition() {
+ return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2));
+ }
+ };
+
+ Widget w = graph.getScene().findWidget(node);
+ this.position = w.getPreferredLocation();
+ }
+
+ public Cluster getCluster() {
+ return null;
+ }
+
+ public Dimension getSize() {
+ Widget w = graph.getScene().findWidget(node);
+ return w.getBounds().getSize();
+ }
+
+ public Point getPosition() {
+ return position;
+ }
+
+ public void setPosition(Point p) {
+ HierarchicalGraphLayout.this.setResolvedNodeLocation(graph, node, p);
+ position = p;
+ }
+
+ public boolean isRoot() {
+ return false;
+ }
+
+ public int compareTo(Vertex o) {
+ VertexWrapper vw = (VertexWrapper) o;
+ return node.toString().compareTo(vw.node.toString());
+ }
+
+ public Port getSlot() {
+ return slot;
+ }
+ }
+
+ protected void performGraphLayout(UniversalGraph<N, E> graph) {
+
+ Set<LinkWrapper> links = new HashSet<LinkWrapper>();
+ Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
+ Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();
+
+ for (N node : graph.getNodes()) {
+ VertexWrapper v = new VertexWrapper(node, graph);
+ vertexMap.put(node, v);
+ vertices.add(v);
+ }
+
+ for (E edge : graph.getEdges()) {
+ N source = graph.getEdgeSource(edge);
+ N target = graph.getEdgeTarget(edge);
+ LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target));
+ links.add(l);
+ }
+
+ HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE);
+
+ LayoutGraph layoutGraph = new LayoutGraph(links, vertices);
+ m.doLayout(layoutGraph);
+ }
+
+ protected void performNodesLayout(UniversalGraph<N, E> graph, Collection<N> nodes) {
+ throw new UnsupportedOperationException();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/layer.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
+<filesystem>
+ <folder name="Actions">
+ <folder name="Window">
+ <file name="com-sun-hotspot-igv-controlflow-ControlFlowAction.instance"/>
+ </folder>
+ </folder>
+ <folder name="Menu">
+ <folder name="Window">
+ <file name="ControlFlowAction.shadow">
+ <attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-controlflow-ControlFlowAction.instance"/>
+ </file>
+ </folder>
+ </folder>
+ <folder name="Windows2">
+ <folder name="Components">
+ <file name="ControlFlowTopComponent.settings" url="ControlFlowTopComponentSettings.xml"/>
+ </folder>
+ <folder name="Modes">
+ <folder name="customRightTopMode">
+ <file name="ControlFlowTopComponent.wstcref" url="ControlFlowTopComponentWstcref.xml"/>
+ </folder>
+ </folder>
+ </folder>
+</filesystem>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/build.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
+<!-- for some information on what you could do (e.g. targets to override). -->
+<!-- If you delete this file and reopen the project it will be recreated. -->
+<project name="com.sun.hotspot.igv.coordinator" default="netbeans" basedir=".">
+ <description>Builds, tests, and runs the project com.sun.hotspot.igv.coordinator.</description>
+ <import file="nbproject/build-impl.xml"/>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/manifest.mf Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.sun.hotspot.igv.coordinator
+OpenIDE-Module-Layer: com/sun/hotspot/igv/coordinator/layer.xml
+OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/coordinator/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/build-impl.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+-->
+<project name="com.sun.hotspot.igv.coordinator-impl" basedir="..">
+ <property file="nbproject/private/suite-private.properties"/>
+ <property file="nbproject/suite.properties"/>
+ <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
+ <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
+ <property file="${suite.dir}/nbproject/platform.properties"/>
+ <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ <property file="${user.properties.file}"/>
+ <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <nbmproject2:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
+ <condition>
+ <not>
+ <available file="${harness.dir}" type="dir"/>
+ </not>
+ </condition>
+ </fail>
+ <import file="${harness.dir}/build.xml"/>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/genfiles.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=077de97c
+build.xml.script.CRC32=d29d586c
+build.xml.stylesheet.CRC32=79c3b980
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=077de97c
+nbproject/build-impl.xml.script.CRC32=03daa42d
+nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/platform.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,29 @@
+# Deprecated since 5.0u1; for compatibility with 5.0:
+disabled.clusters=\
+ apisupport1,\
+ harness,\
+ ide8,\
+ java1,\
+ nb6.0,\
+ profiler2
+disabled.modules=\
+ org.netbeans.core.execution,\
+ org.netbeans.core.multiview,\
+ org.netbeans.core.output2,\
+ org.netbeans.modules.applemenu,\
+ org.netbeans.modules.autoupdate.services,\
+ org.netbeans.modules.autoupdate.ui,\
+ org.netbeans.modules.core.kit,\
+ org.netbeans.modules.favorites,\
+ org.netbeans.modules.javahelp,\
+ org.netbeans.modules.masterfs,\
+ org.netbeans.modules.options.keymap,\
+ org.netbeans.modules.sendopts,\
+ org.netbeans.modules.templates,\
+ org.openide.compat,\
+ org.openide.execution,\
+ org.openide.util.enumerations
+enabled.clusters=\
+ platform7
+nbjdk.active=JDK_1.6
+nbplatform.active=default
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.apisupport.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+ <code-name-base>com.sun.hotspot.igv.coordinator</code-name-base>
+ <suite-component/>
+ <module-dependencies>
+ <dependency>
+ <code-name-base>com.sun.hotspot.igv.data</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>com.sun.hotspot.igv.difference</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>com.sun.hotspot.igv.settings</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>com.sun.hotspot.igv.util</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.0</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.api.progress</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.10.0.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.actions</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.6.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.awt</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.11.0.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.dialogs</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.5.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.explorer</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.11</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.filesystems</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.3</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.loaders</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.7</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.nodes</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.2.0.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.util</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.9.0.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.windows</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.16</specification-version>
+ </run-dependency>
+ </dependency>
+ </module-dependencies>
+ <public-packages/>
+ </data>
+ </configuration>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/suite.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,1 @@
+suite.dir=${basedir}/..
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,2 @@
+com.sun.hotspot.igv.coordinator.StandardGroupOrganizer
+com.sun.hotspot.igv.coordinator.GraphCountGroupOrganizer
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,7 @@
+
+AdvancedOption_DisplayName_Coordinator=Settings
+AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings
+CTL_OutlineTopComponent=Outline Window
+CTL_SomeAction=test
+HINT_OutlineTopComponent=This is a Outline window
+OpenIDE-Module-Name=Coordinator
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.coordinator;
+
+import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.services.GroupOrganizer;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.Pair;
+import java.awt.Image;
+import java.util.ArrayList;
+import java.util.List;
+import org.openide.nodes.AbstractNode;
+import org.openide.nodes.Children;
+import org.openide.nodes.Node;
+import org.openide.util.Utilities;
+import org.openide.util.lookup.AbstractLookup;
+import org.openide.util.lookup.InstanceContent;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class FolderNode extends AbstractNode {
+
+ private GroupOrganizer organizer;
+ private InstanceContent content;
+ private List<Pair<String, List<Group>>> structure;
+ private List<String> subFolders;
+ private FolderChildren children;
+
+ private static class FolderChildren extends Children.Keys {
+
+ private FolderNode parent;
+
+ public void setParent(FolderNode parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ protected Node[] createNodes(Object arg0) {
+
+ Pair<String, List<Group>> p = (Pair<String, List<Group>>) arg0;
+ if (p.getLeft().length() == 0) {
+
+ List<Node> curNodes = new ArrayList<Node>();
+ for (Group g : p.getRight()) {
+ for (InputGraph graph : g.getGraphs()) {
+ curNodes.add(new GraphNode(graph));
+ }
+ }
+
+ Node[] result = new Node[curNodes.size()];
+ for (int i = 0; i < curNodes.size(); i++) {
+ result[i] = curNodes.get(i);
+ }
+ return result;
+
+ } else {
+ return new Node[]{new FolderNode(p.getLeft(), parent.organizer, parent.subFolders, p.getRight())};
+ }
+ }
+
+ @Override
+ public void addNotify() {
+ this.setKeys(parent.structure);
+
+ }
+ }
+
+ protected InstanceContent getContent() {
+ return content;
+ }
+
+ @Override
+ public Image getIcon(int i) {
+ return Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.gif");
+ }
+
+ protected FolderNode(String name, GroupOrganizer organizer, List<String> subFolders, List<Group> groups) {
+ this(name, organizer, subFolders, groups, new FolderChildren(), new InstanceContent());
+ }
+
+ private FolderNode(String name, GroupOrganizer organizer, List<String> oldSubFolders, final List<Group> groups, FolderChildren children, InstanceContent content) {
+ super(children, new AbstractLookup(content));
+ children.setParent(this);
+ this.content = content;
+ this.children = children;
+ content.add(new RemoveCookie() {
+
+ public void remove() {
+ for (Group g : groups) {
+ if (g.getDocument() != null) {
+ g.getDocument().removeGroup(g);
+ }
+ }
+ }
+ });
+ init(name, organizer, oldSubFolders, groups);
+ }
+
+ public void init(String name, GroupOrganizer organizer, List<String> oldSubFolders, List<Group> groups) {
+ this.setDisplayName(name);
+ this.organizer = organizer;
+ this.subFolders = new ArrayList<String>(oldSubFolders);
+ if (name.length() > 0) {
+ this.subFolders.add(name);
+ }
+ structure = organizer.organize(subFolders, groups);
+ assert structure != null;
+ children.addNotify();
+ }
+
+ @Override
+ public Image getOpenedIcon(int i) {
+ return getIcon(i);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright 1998-2007 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.hotspot.igv.coordinator;
+
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.Pair;
+import com.sun.hotspot.igv.data.services.GroupOrganizer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class GraphCountGroupOrganizer implements GroupOrganizer {
+
+ public String getName() {
+ return "Graph count structure";
+ }
+
+ public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups) {
+
+ List<Pair<String, List<Group>>> result = new ArrayList<Pair<String, List<Group>>>();
+
+ if (subFolders.size() == 0) {
+ Map<Integer, List<Group>> map = new HashMap<Integer, List<Group>>();
+ for (Group g : groups) {
+ Integer cur = g.getGraphs().size();
+ if (!map.containsKey(cur)) {
+ map.put(cur, new ArrayList<Group>());
+ }
+ map.get(cur).add(g);
+ }
+
+ SortedSet<Integer> keys = new TreeSet<Integer>(map.keySet());
+ for (Integer i : keys) {
+ result.add(new Pair<String, List<Group>>("Graph count " + i, map.get(i)));
+ }
+
+ } else if (subFolders.size() == 1) {
+ for (Group g : groups) {
+ List<Group> children = new ArrayList<Group>();
+ children.add(g);
+ Pair<String, List<Group>> p = new Pair<String, List<Group>>();
+ p.setLeft(g.getName());
+ p.setRight(children);
+ result.add(p);
+ }
+ } else if (subFolders.size() == 2) {
+ result.add(new Pair<String, List<Group>>("", groups));
+ }
+
+ return result;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.coordinator;
+
+import com.sun.hotspot.igv.coordinator.actions.DiffGraphAction;
+import com.sun.hotspot.igv.coordinator.actions.DiffGraphCookie;
+import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.services.GraphViewer;
+import com.sun.hotspot.igv.data.services.InputGraphProvider;
+import com.sun.hotspot.igv.util.PropertiesSheet;
+import java.awt.Image;
+import javax.swing.Action;
+import org.openide.actions.OpenAction;
+import org.openide.cookies.OpenCookie;
+import org.openide.nodes.AbstractNode;
+import org.openide.nodes.Children;
+import org.openide.nodes.Node;
+import org.openide.nodes.Sheet;
+import org.openide.util.Lookup;
+import org.openide.util.Utilities;
+import org.openide.util.lookup.AbstractLookup;
+import org.openide.util.lookup.InstanceContent;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class GraphNode extends AbstractNode {
+
+ private InputGraph graph;
+
+ /** Creates a new instance of GraphNode */
+ public GraphNode(InputGraph graph) {
+ this(graph, new InstanceContent());
+ }
+
+ private GraphNode(final InputGraph graph, InstanceContent content) {
+ super(Children.LEAF, new AbstractLookup(content));
+ this.graph = graph;
+ this.setDisplayName(graph.getName());
+ content.add(graph);
+
+ final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class);
+
+ if (viewer != null) {
+ // Action for opening the graph
+ content.add(new OpenCookie() {
+
+ public void open() {
+ viewer.view(graph);
+ }
+ });
+ }
+
+ // Action for removing a graph
+ content.add(new RemoveCookie() {
+
+ public void remove() {
+ graph.getGroup().removeGraph(graph);
+ }
+ });
+ }
+
+ @Override
+ protected Sheet createSheet() {
+ Sheet s = super.createSheet();
+ PropertiesSheet.initializeSheet(graph.getProperties(), s);
+ return s;
+ }
+
+ @Override
+ public Image getIcon(int i) {
+ return Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/graph.gif");
+ }
+
+ @Override
+ public Image getOpenedIcon(int i) {
+ return getIcon(i);
+ }
+
+ @Override
+ public <T extends Node.Cookie> T getCookie(Class<T> aClass) {
+ if (aClass == DiffGraphCookie.class) {
+ InputGraphProvider graphProvider = Utilities.actionsGlobalContext().lookup(InputGraphProvider.class);
+
+ InputGraph graphA = null;
+ if (graphProvider != null) {
+ graphA = graphProvider.getGraph();
+ }
+
+ if (graphA != null && !graphA.isDifferenceGraph()) {
+ return (T) new DiffGraphCookie(graphA, graph);
+ }
+ }
+
+ return super.getCookie(aClass);
+ }
+
+ @Override
+ public Action[] getActions(boolean b) {
+ return new Action[]{(Action) DiffGraphAction.findObject(DiffGraphAction.class, true), (Action) OpenAction.findObject(OpenAction.class, true)};
+ }
+
+ @Override
+ public Action getPreferredAction() {
+ return (Action) OpenAction.findObject(OpenAction.class, true);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="jPanel2">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new BeanTreeView();"/>
+ </AuxValues>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+package com.sun.hotspot.igv.coordinator;
+
+import com.sun.hotspot.igv.coordinator.actions.ImportAction;
+import com.sun.hotspot.igv.coordinator.actions.RemoveAction;
+import com.sun.hotspot.igv.coordinator.actions.RemoveAllAction;
+import com.sun.hotspot.igv.coordinator.actions.SaveAllAction;
+import com.sun.hotspot.igv.coordinator.actions.SaveAsAction;
+import com.sun.hotspot.igv.coordinator.actions.StructuredViewAction;
+import com.sun.hotspot.igv.data.GraphDocument;
+import com.sun.hotspot.igv.data.ChangedListener;
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.services.GroupCallback;
+import com.sun.hotspot.igv.data.services.GroupOrganizer;
+import com.sun.hotspot.igv.data.services.GroupReceiver;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import org.openide.ErrorManager;
+import org.openide.awt.Toolbar;
+import org.openide.awt.ToolbarPool;
+import org.openide.explorer.ExplorerManager;
+import org.openide.explorer.ExplorerUtils;
+import org.openide.explorer.view.BeanTreeView;
+import org.openide.util.Lookup;
+import org.openide.util.LookupEvent;
+import org.openide.util.LookupListener;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.NodeAction;
+import org.openide.windows.TopComponent;
+import org.openide.windows.WindowManager;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public final class OutlineTopComponent extends TopComponent implements ExplorerManager.Provider, LookupListener {
+
+ public static OutlineTopComponent instance;
+ public static final String PREFERRED_ID = "OutlineTopComponent";
+ private ExplorerManager manager;
+ private GraphDocument document;
+ private FolderNode root;
+ private GroupOrganizer organizer;
+
+ private OutlineTopComponent() {
+ initComponents();
+
+ setName(NbBundle.getMessage(OutlineTopComponent.class, "CTL_OutlineTopComponent"));
+ setToolTipText(NbBundle.getMessage(OutlineTopComponent.class, "HINT_OutlineTopComponent"));
+
+ document = new GraphDocument();
+ initListView();
+ initToolbar();
+ initReceivers();
+ }
+
+ private void initListView() {
+ manager = new ExplorerManager();
+ organizer = new StandardGroupOrganizer();
+ root = new FolderNode("", organizer, new ArrayList<String>(), document.getGroups());
+ manager.setRootContext(root);
+ ((BeanTreeView) this.jScrollPane1).setRootVisible(false);
+
+ document.getChangedEvent().addListener(new ChangedListener<GraphDocument>() {
+
+ public void changed(GraphDocument document) {
+ updateStructure();
+ }
+ });
+
+ associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
+ }
+
+ private void initToolbar() {
+
+ Toolbar toolbar = new Toolbar();
+ Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
+ toolbar.setBorder(b);
+ this.add(toolbar, BorderLayout.NORTH);
+
+ toolbar.add(ImportAction.get(ImportAction.class));
+ toolbar.add(((NodeAction) RemoveAction.get(RemoveAction.class)).createContextAwareInstance(this.getLookup()));
+ toolbar.add(RemoveAllAction.get(RemoveAllAction.class));
+
+ toolbar.add(((NodeAction) SaveAsAction.get(SaveAsAction.class)).createContextAwareInstance(this.getLookup()));
+ toolbar.add(SaveAllAction.get(SaveAllAction.class));
+
+ toolbar.add(StructuredViewAction.get(StructuredViewAction.class).getToolbarPresenter());
+
+ for (Toolbar tb : ToolbarPool.getDefault().getToolbars()) {
+ tb.setVisible(false);
+ }
+
+ initOrganizers();
+ }
+
+ public void setOrganizer(GroupOrganizer organizer) {
+ this.organizer = organizer;
+ updateStructure();
+ }
+
+ private void initOrganizers() {
+
+ }
+
+ private void initReceivers() {
+
+ final GroupCallback callback = new GroupCallback() {
+
+ public void started(Group g) {
+ getDocument().addGroup(g);
+ }
+ };
+
+ Collection<? extends GroupReceiver> receivers = Lookup.getDefault().lookupAll(GroupReceiver.class);
+ if (receivers.size() > 0) {
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+ for (GroupReceiver r : receivers) {
+ Component c = r.init(callback);
+ panel.add(c);
+ }
+
+ jPanel2.add(panel, BorderLayout.PAGE_START);
+ }
+ }
+
+ private void updateStructure() {
+ root.init("", organizer, new ArrayList<String>(), document.getGroups());
+ }
+
+ public void clear() {
+ document.clear();
+ }
+
+ public ExplorerManager getExplorerManager() {
+ return manager;
+ }
+
+ public GraphDocument getDocument() {
+ return document;
+ }
+
+ /**
+ * Gets default instance. Do not use directly: reserved for *.settings files only,
+ * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
+ * To obtain the singleton instance, use {@link findInstance}.
+ */
+ public static synchronized OutlineTopComponent getDefault() {
+ if (instance == null) {
+ instance = new OutlineTopComponent();
+ }
+ return instance;
+ }
+
+ /**
+ * Obtain the OutlineTopComponent instance. Never call {@link #getDefault} directly!
+ */
+ public static synchronized OutlineTopComponent findInstance() {
+ TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
+ if (win == null) {
+ ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find Outline component. It will not be located properly in the window system.");
+ return getDefault();
+ }
+ if (win instanceof OutlineTopComponent) {
+ return (OutlineTopComponent) win;
+ }
+ ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior.");
+ return getDefault();
+ }
+
+ @Override
+ public int getPersistenceType() {
+ return TopComponent.PERSISTENCE_ALWAYS;
+ }
+
+ @Override
+ public void componentOpened() {
+ this.requestActive();
+ }
+
+ @Override
+ public void componentClosed() {
+ }
+
+ @Override
+ protected String preferredID() {
+ return PREFERRED_ID;
+ }
+
+ public void resultChanged(LookupEvent lookupEvent) {
+ }
+
+ @Override
+ public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException {
+ // Not called when user starts application for the first time
+ super.readExternal(objectInput);
+ ((BeanTreeView) this.jScrollPane1).setRootVisible(false);
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput objectOutput) throws IOException {
+ super.writeExternal(objectOutput);
+ }
+
+ static final class ResolvableHelper implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object readResolve() {
+ return OutlineTopComponent.getDefault();
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel2 = new javax.swing.JPanel();
+ jScrollPane1 = new BeanTreeView();
+
+ setLayout(new java.awt.BorderLayout());
+
+ jPanel2.setLayout(new java.awt.BorderLayout());
+ jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);
+
+ add(jPanel2, java.awt.BorderLayout.CENTER);
+ }// </editor-fold>//GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JScrollPane jScrollPane1;
+ // End of variables declaration//GEN-END:variables
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponentSettings.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
+<settings version="1.0">
+ <module name="com.sun.hotspot.igv.coordinator" spec="1.0"/>
+ <instanceof class="at.openide.windows.TopComponent"/>
+ <instanceof class="com.sun.hotspot.igv.coordinator.OutlineTopComponent"/>
+ <instance class="com.sun.hotspot.igv.coordinator.OutlineTopComponent" method="getDefault"/>
+</settings>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponentWstcref.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd">
+<tc-ref version="2.0" >
+ <module name="com.sun.hotspot.igv.coordinator" spec="1.0"/>
+ <tc-id id="OutlineTopComponent"/>
+ <state opened="true"/>
+</tc-ref>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configuration PUBLIC "-//NetBeans IDE//DTD toolbar//EN" "http://www.netbeans.org/dtds/toolbar.dtd">
+<Configuration>
+ <Row>
+ <Toolbar name="Edit" position="1" visible="false"/>
+ <Toolbar name="File" position="1" visible="false" />
+ <Toolbar name="Memory" position="1" visible="false" />
+ </Row>
+ <Row>
+ <Toolbar name="WorkspaceSwitcher" />
+ <Toolbar name="StatusLine" />
+ </Row>
+</Configuration>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1998-2007 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.hotspot.igv.coordinator;
+
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.services.GroupOrganizer;
+import com.sun.hotspot.igv.data.Pair;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class StandardGroupOrganizer implements GroupOrganizer {
+
+ public String getName() {
+ return "-- None --";
+ }
+
+ public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups) {
+
+ List<Pair<String, List<Group>>> result = new ArrayList<Pair<String, List<Group>>>();
+
+ if (groups.size() == 1 && subFolders.size() > 0) {
+ result.add(new Pair<String, List<Group>>("", groups));
+ } else {
+ for (Group g : groups) {
+ List<Group> children = new ArrayList<Group>();
+ children.add(g);
+ Pair<String, List<Group>> p = new Pair<String, List<Group>>();
+ p.setLeft(g.getName());
+ p.setRight(children);
+ result.add(p);
+ }
+ }
+
+ return result;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,18 @@
+CTL_EditFilterAction=Edit...
+CTL_ImportAction=Open...
+CTL_OpenGraphAction=View graph
+CTL_DiffGraphAction=Difference to current graph
+CTL_RemoveAction=Remove methods
+CTL_ApplyFilterAction=Apply
+CTL_FilterAction=Open Filter Window
+CTL_AppliedFilterAction=Open AppliedFilter Window
+CTL_OutlineAction=Open Outline Window
+CTL_MoveFilterUpAction=Move upwards
+CTL_MoveFilterDownAction=Move downwards
+CTL_RemoveFilterAction=Remove
+CTL_RemoveFilterSettingsAction=Remove filter setting
+CTL_SaveAsAction=Save selected methods...
+CTL_SaveAllAction=Save all...
+CTL_SaveFilterSettingsAction=Save filter settings...
+CTL_PropertiesAction=Open Properties Window
+CTL_NewFilterAction=New filter...
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.igv.coordinator.actions;
+
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.CookieAction;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public final class DiffGraphAction extends CookieAction {
+
+ protected void performAction(Node[] activatedNodes) {
+ DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class);
+ c.openDiff();
+ }
+
+ protected int mode() {
+ return CookieAction.MODE_EXACTLY_ONE;
+ }
+
+ public String getName() {
+ return NbBundle.getMessage(DiffGraphAction.class, "CTL_DiffGraphAction");
+ }
+
+ protected Class[] cookieClasses() {
+ return new Class[]{
+ DiffGraphCookie.class
+ };
+ }
+
+ @Override
+ protected String iconResource() {
+ return "com/sun/hotspot/igv/coordinator/images/diff.gif";
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ protected boolean asynchronous() {
+ return false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.igv.coordinator.actions;
+
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.services.GraphViewer;
+import com.sun.hotspot.igv.difference.Difference;
+import org.openide.nodes.Node;
+import org.openide.util.Lookup;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class DiffGraphCookie implements Node.Cookie {
+
+ private InputGraph a;
+ private InputGraph b;
+
+ public DiffGraphCookie(InputGraph a, InputGraph b) {
+ this.a = a;
+ this.b = b;
+ }
+
+ public void openDiff() {
+
+ final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class);
+
+ if(viewer != null) {
+ InputGraph diffGraph = Difference.createDiffGraph(a, b);
+ viewer.view(diffGraph);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.igv.coordinator.actions;
+
+import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
+import com.sun.hotspot.igv.data.GraphDocument;
+import com.sun.hotspot.igv.data.serialization.Parser;
+import com.sun.hotspot.igv.settings.Settings;
+import com.sun.hotspot.igv.data.serialization.XMLParser;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import javax.swing.Action;
+import javax.swing.JFileChooser;
+import javax.swing.KeyStroke;
+import javax.swing.filechooser.FileFilter;
+import org.netbeans.api.progress.ProgressHandle;
+import org.netbeans.api.progress.ProgressHandleFactory;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.RequestProcessor;
+import org.openide.util.actions.CallableSystemAction;
+import org.openide.xml.XMLUtil;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public final class ImportAction extends CallableSystemAction {
+
+ public static FileFilter getFileFilter() {
+ return new FileFilter() {
+
+ public boolean accept(File f) {
+ return f.getName().toLowerCase().endsWith(".xml") || f.isDirectory();
+ }
+
+ public String getDescription() {
+ return "XML files (*.xml)";
+ }
+ };
+ }
+
+ public void performAction() {
+
+ JFileChooser fc = new JFileChooser();
+ fc.setFileFilter(ImportAction.getFileFilter());
+ fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT)));
+
+ if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
+ File file = fc.getSelectedFile();
+
+ File dir = file;
+ if (!dir.isDirectory()) {
+ dir = dir.getParentFile();
+ }
+
+ Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
+
+ try {
+ final XMLReader reader = XMLUtil.createXMLReader();
+ final FileInputStream inputStream = new FileInputStream(file);
+ final InputSource is = new InputSource(inputStream);
+
+ final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName());
+ final int basis = 1000;
+ handle.start(basis);
+ final int start = inputStream.available();
+
+ final XMLParser.ParseMonitor parseMonitor = new XMLParser.ParseMonitor() {
+
+ public void setProgress(double d) {
+ try {
+ int curAvailable = inputStream.available();
+ int prog = (int) (basis * (double) (start - curAvailable) / (double) start);
+ handle.progress(prog);
+ } catch (IOException ex) {
+ }
+ }
+
+ public void setState(String state) {
+ setProgress(0.0);
+ handle.progress(state);
+ }
+ };
+ final Parser parser = new Parser();
+ final OutlineTopComponent component = OutlineTopComponent.findInstance();
+
+ component.requestActive();
+
+ RequestProcessor.getDefault().post(new Runnable() {
+
+ public void run() {
+ GraphDocument document = null;
+ try {
+ document = parser.parse(reader, is, parseMonitor);
+ parseMonitor.setState("Finishing");
+ component.getDocument().addGraphDocument(document);
+ } catch (SAXException ex) {
+ String s = "Exception during parsing the XML file, could not load document!";
+ if (ex instanceof XMLParser.MissingAttributeException) {
+ XMLParser.MissingAttributeException e = (XMLParser.MissingAttributeException) ex;
+ s += "\nMissing attribute \"" + e.getAttributeName() + "\"";
+ }
+ ex.printStackTrace();
+ NotifyDescriptor d = new NotifyDescriptor.Message(s, NotifyDescriptor.ERROR_MESSAGE);
+ DialogDisplayer.getDefault().notify(d);
+ }
+ handle.finish();
+ }
+ });
+
+ } catch (SAXException ex) {
+ ex.printStackTrace();
+ } catch (FileNotFoundException ex) {
+ ex.printStackTrace();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ public String getName() {
+ return NbBundle.getMessage(ImportAction.class, "CTL_ImportAction");
+ }
+
+ public ImportAction() {
+ putValue(Action.SHORT_DESCRIPTION, "Open an 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.gif";
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ protected boolean asynchronous() {
+ return false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.igv.coordinator.actions;
+
+import com.sun.hotspot.igv.coordinator.*;
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import org.openide.util.NbBundle;
+import org.openide.windows.TopComponent;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class OutlineAction extends AbstractAction {
+
+ public OutlineAction() {
+ super(NbBundle.getMessage(OutlineAction.class, "CTL_OutlineAction"));
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ TopComponent win = OutlineTopComponent.findInstance();
+ win.open();
+ win.requestActive();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.igv.coordinator.actions;
+
+import javax.swing.Action;
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.NodeAction;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public final class RemoveAction extends NodeAction {
+
+ protected void performAction(Node[] activatedNodes) {
+ for (Node n : activatedNodes) {
+ RemoveCookie removeCookie = n.getCookie(RemoveCookie.class);
+ if (removeCookie != null) {
+ removeCookie.remove();
+ }
+ }
+ }
+
+ public RemoveAction() {
+ putValue(Action.SHORT_DESCRIPTION, "Remove");
+ }
+
+ public String getName() {
+ return NbBundle.getMessage(RemoveAction.class, "CTL_RemoveAction");
+ }
+
+ @Override
+ protected String iconResource() {
+ return "com/sun/hotspot/igv/coordinator/images/remove.gif";
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ protected boolean asynchronous() {
+ return false;
+ }
+
+ protected boolean enable(Node[] nodes) {
+ return nodes.length > 0;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright 1998-2007 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.hotspot.igv.coordinator.actions;
+
+import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import javax.swing.Action;
+import javax.swing.KeyStroke;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.CallableSystemAction;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public final class RemoveAllAction extends CallableSystemAction {
+
+
+ public String getName() {
+ return NbBundle.getMessage(RemoveAllAction.class, "CTL_ImportAction");
+ }
+
+ public RemoveAllAction() {
+ putValue(Action.SHORT_DESCRIPTION, "Remove all methods");
+ putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SHIFT, InputEvent.CTRL_MASK));
+ }
+
+ @Override
+ protected String iconResource() {
+ return "com/sun/hotspot/igv/coordinator/images/removeall.gif";
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ protected boolean asynchronous() {
+ return false;
+ }
+
+ @Override
+ public void performAction() {
+ OutlineTopComponent.findInstance().clear();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveCookie.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 1998-2007 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.hotspot.igv.coordinator.actions;
+
+import org.openide.nodes.Node;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface RemoveCookie extends Node.Cookie {
+ void remove();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright 1998-2007 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.hotspot.igv.coordinator.actions;
+
+import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import javax.swing.Action;
+import javax.swing.KeyStroke;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.CallableSystemAction;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public final class SaveAllAction extends CallableSystemAction {
+
+ public void performAction() {
+ final OutlineTopComponent component = OutlineTopComponent.findInstance();
+ SaveAsAction.save(component.getDocument());
+ }
+
+ public String getName() {
+ return NbBundle.getMessage(SaveAllAction.class, "CTL_SaveAllAction");
+ }
+
+ public SaveAllAction() {
+ putValue(Action.SHORT_DESCRIPTION, "Save all methods to XML file");
+ putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
+ }
+
+ @Override
+ protected String iconResource() {
+ return "com/sun/hotspot/igv/coordinator/images/saveall.gif";
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ protected boolean asynchronous() {
+ return false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.igv.coordinator.actions;
+
+import com.sun.hotspot.igv.data.GraphDocument;
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.serialization.Printer;
+import com.sun.hotspot.igv.settings.Settings;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import javax.swing.JFileChooser;
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.CookieAction;
+import org.openide.util.actions.NodeAction;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public final class SaveAsAction extends NodeAction {
+
+ protected void performAction(Node[] activatedNodes) {
+
+ GraphDocument doc = new GraphDocument();
+ for (Node n : activatedNodes) {
+ Group group = n.getLookup().lookup(Group.class);
+ doc.addGroup(group);
+ }
+
+ save(doc);
+ }
+
+ public static void save(GraphDocument doc) {
+ JFileChooser fc = new JFileChooser();
+ fc.setFileFilter(ImportAction.getFileFilter());
+ fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT)));
+
+ if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
+ File file = fc.getSelectedFile();
+ if (!file.getName().contains(".")) {
+ file = new File(file.getAbsolutePath() + ".xml");
+ }
+
+ File dir = file;
+ if (!dir.isDirectory()) {
+ dir = dir.getParentFile();
+ }
+ Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
+ try {
+ Writer writer = new OutputStreamWriter(new FileOutputStream(file));
+ Printer p = new Printer();
+ p.export(writer, doc);
+ writer.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+
+ }
+ }
+ }
+
+ protected int mode() {
+ return CookieAction.MODE_SOME;
+ }
+
+ public String getName() {
+ return NbBundle.getMessage(SaveAsAction.class, "CTL_SaveAsAction");
+ }
+
+ @Override
+ protected String iconResource() {
+ return "com/sun/hotspot/igv/coordinator/images/save.gif";
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ protected boolean asynchronous() {
+ return false;
+ }
+
+ protected boolean enable(Node[] nodes) {
+
+ int cnt = 0;
+ for (Node n : nodes) {
+ cnt += n.getLookup().lookupAll(Group.class).size();
+ }
+
+ return cnt > 0;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/StructuredViewAction.java Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,180 @@
+/*
+ * Copyright 1998-2007 Sun Microsystems, Inc. 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.hotspot.igv.coordinator.actions;
+
+import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
+import com.sun.hotspot.igv.data.services.GroupOrganizer;
+import java.awt.Component;
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.swing.Action;
+import javax.swing.ButtonGroup;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+import org.openide.awt.DropDownButtonFactory;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+import org.openide.util.Utilities;
+import org.openide.util.actions.CallableSystemAction;
+
+public class StructuredViewAction extends CallableSystemAction {
+
+ private static JButton dropDownButton;
+ private static ButtonGroup buttonGroup;
+ private static JPopupMenu popup;
+ private MyMenuItemListener menuItemListener;
+ private Map<JMenuItem, GroupOrganizer> map;
+
+ public StructuredViewAction() {
+
+ putValue(Action.SHORT_DESCRIPTION, "Cluster nodes into blocks");
+ }
+
+ @Override
+ public Component getToolbarPresenter() {
+
+ Image iconImage = Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/structure.gif");
+ ImageIcon icon = new ImageIcon(iconImage);
+
+ popup = new JPopupMenu();
+
+ menuItemListener = new MyMenuItemListener();
+
+ buttonGroup = new ButtonGroup();
+
+ Collection<? extends GroupOrganizer> organizersCollection = Lookup.getDefault().lookupAll(GroupOrganizer.class);
+
+ List<GroupOrganizer> organizers = new ArrayList<GroupOrganizer>(organizersCollection);
+ Collections.sort(organizers, new Comparator<GroupOrganizer>() {
+ public int compare(GroupOrganizer a, GroupOrganizer b) {
+ return a.getName().compareTo(b.getName());
+ }
+ });
+
+ map = new HashMap<JMenuItem, GroupOrganizer>();
+
+ boolean first = true;
+ for(GroupOrganizer organizer : organizers) {
+ JCheckBoxMenuItem item = new JCheckBoxMenuItem(organizer.getName());
+ map.put(item, organizer);
+ item.addActionListener(menuItemListener);
+ buttonGroup.add(item);
+ popup.add(item);
+ if(first) {
+ item.setSelected(true);
+ first = false;
+ }
+ }
+
+ dropDownButton = DropDownButtonFactory.createDropDownButton(
+ new ImageIcon(
+ new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)),
+ popup);
+
+ dropDownButton.setIcon(icon);
+
+ dropDownButton.setToolTipText("Insert Layer Registration");
+
+ dropDownButton.addItemListener(new ItemListener() {
+
+ public void itemStateChanged(ItemEvent e) {
+ int state = e.getStateChange();
+ if (state == ItemEvent.SELECTED) {
+ performAction();
+ }
+ }
+ });
+
+ dropDownButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ performAction();
+ }
+ });
+
+ popup.addPopupMenuListener(new PopupMenuListener() {
+
+ public void popupMenuCanceled(PopupMenuEvent e) {
+ dropDownButton.setSelected(false);
+ }
+
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
+ dropDownButton.setSelected(false);
+ }
+
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+ dropDownButton.setSelected(true);
+ }
+ });
+
+ return dropDownButton;
+
+ }
+
+ private class MyMenuItemListener implements ActionListener {
+
+ public void actionPerformed(ActionEvent ev) {
+ JMenuItem item = (JMenuItem) ev.getSource();
+ GroupOrganizer organizer = map.get(item);
+ assert organizer != null : "Organizer must exist!";
+ OutlineTopComponent.findInstance().setOrganizer(organizer);
+ }
+ }
+
+
+ @Override
+ public void performAction() {
+ popup.show(dropDownButton, 0, dropDownButton.getHeight());
+ }
+
+ public String getName() {
+ return "Structured View";
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ protected boolean asynchronous() {
+ return false;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/customLeftWsmode.xml Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mode version="2.1">
+ <name unique="customLeft" />
+ <kind type="view" />
+ <state type="joined" />
+ <constraints>
+ <path orientation="horizontal" number="0" weight="0.779245283018868"/>
+ <path orientation="vertical" number="0" weight="0.7511825922421949"/>
+ <path orientation="horizontal" number="0" weight="0.5"/>
+ <path orientation="vertical" number="20" weight="0.7"/>
+ <path orientation="horizontal" number="40" weight="0.55"/>
+ <path orientation="horizontal" number="0" weight="0.2711864406779661"/>
+ </constraints>
+ <bounds x="0" y="0" width="0" height="0" />
+ <frame state="0"/>
+ <active-tc id="OutlineTopComponent"/>
+ <empty-behavior permanent="false"/>
+</mode>
Binary file hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/diff.gif has changed
Binary file hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/folder.gif has changed
Binary file hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/graph.gif has changed
Binary file hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.gif has changed
Binary file hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.gif has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/tools/IdealGraphVisualizer/README Tue Jun 24 16:00:14 2008 -0700
@@ -0,0 +1,45 @@
+The Ideal Graph Visualizer is a tool developed to help examine the
+intermediate representation of C2 which is commonly referred to as the
+"ideal graph". It was developed in collaboration with the University
+of Linz in Austria and has been included as part of hotspot since that
+was the primary target of the tool. The tool itself is fairly general
+with only a few modules that contain C2 specific elements.
+
+The tool is built on top of the NetBeans 6.0 rich client
+infrastructure and so requires NetBeans to build. It currently
+requires Java 6 to run as it needs support for JavaScript for its
+filtering mechanism and assumes it's built into the platform. It
+should build out of the box whit NetBeans 6 and Java 6 or later. It's
+possible to run it on 1.5 by including Rhino on the classpath though
+that currently isn't working correctly. Support for exporting graphs
+as SVG can be enabled by adding batik to the classpath which isn't
+included by default.
+
+It can be built on top of NetBeans 6.1 if you change the required
+modules to be platform8 instead of platform7. The tool could run on
+JDK 1.5 with some reworking of the how the JavaScript support is
+enabled but currently it requires some tweaking of the setup. This
+will be fixed in a later setup.
+
+The JVM support is controlled by the flag -XX:PrintIdealGraphLevel=#
+where # is:
+
+ 0: no output, the default
+ 1: dumps graph after parsing, before matching, and final code.
+ also dumps graph for failed compiles, if available
+ 2: more detail, including after loop opts
+ 3: even more detail
+ 4: prints graph after parsing every bytecode (very slow)
+
+By default the JVM expects that it will connect to a visualizer on the
+local host on port 4444. This can be configured using the options
+-XX:PrintIdealGraphAddress= and -XX:PrintIdealGraphPort=.
+PrintIdealGraphAddress can actually be a hostname.
+
+Alternatively the output can be sent to a file using
+-XX:PrintIdealGraphFile=filename. Each compiler thread will get it's
+own file with unique names being generated by adding a number onto the
+provided file name.
+
+More information about the tool is available at
+http://wikis.sun.com/display/HotSpotInternals/IdealGraphVisualizer.
--- a/hotspot/src/share/vm/includeDB_compiler2 Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/includeDB_compiler2 Tue Jun 24 16:00:14 2008 -0700
@@ -1084,6 +1084,7 @@
idealGraphPrinter.hpp vectset.hpp
idealGraphPrinter.hpp growableArray.hpp
idealGraphPrinter.hpp ostream.hpp
+idealGraphPrinter.hpp xmlstream.hpp
idealGraphPrinter.cpp idealGraphPrinter.hpp
idealGraphPrinter.cpp chaitin.hpp
--- a/hotspot/src/share/vm/oops/symbolKlass.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/oops/symbolKlass.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -209,10 +209,7 @@
void symbolKlass::oop_print_on(oop obj, outputStream* st) {
st->print("Symbol: '");
- symbolOop sym = symbolOop(obj);
- for (int i = 0; i < sym->utf8_length(); i++) {
- st->print("%c", sym->byte_at(i));
- }
+ symbolOop(obj)->print_symbol_on(st);
st->print("'");
}
--- a/hotspot/src/share/vm/oops/symbolOop.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/oops/symbolOop.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -68,8 +68,17 @@
void symbolOopDesc::print_symbol_on(outputStream* st) {
st = st ? st : tty;
- for (int index = 0; index < utf8_length(); index++)
- st->put((char)byte_at(index));
+ int length = UTF8::unicode_length((const char*)bytes(), utf8_length());
+ const char *ptr = (const char *)bytes();
+ jchar value;
+ for (int index = 0; index < length; index++) {
+ ptr = UTF8::next(ptr, &value);
+ if (value >= 32 && value < 127 || value == '\'' || value == '\\') {
+ st->put(value);
+ } else {
+ st->print("\\u%04x", value);
+ }
+ }
}
jchar* symbolOopDesc::as_unicode(int& length) const {
--- a/hotspot/src/share/vm/opto/compile.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/compile.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -313,9 +313,6 @@
_compile->begin_method();
}
CompileWrapper::~CompileWrapper() {
- if (_compile->failing()) {
- _compile->print_method("Failed");
- }
_compile->end_method();
if (_compile->scratch_buffer_blob() != NULL)
BufferBlob::free(_compile->scratch_buffer_blob());
@@ -604,6 +601,8 @@
if (failing()) return;
NOT_PRODUCT( verify_graph_edges(); )
+ print_method("Before Matching");
+
#ifndef PRODUCT
if (PrintIdeal) {
ttyLocker ttyl; // keep the following output all in one block
@@ -1481,7 +1480,7 @@
NOT_PRODUCT( verify_graph_edges(); )
- print_method("Start");
+ print_method("After Parsing");
{
// Iterative Global Value Numbering, including ideal transforms
@@ -1688,7 +1687,7 @@
Output();
}
- print_method("End");
+ print_method("Final Code");
// He's dead, Jim.
_cfg = (PhaseCFG*)0xdeadbeef;
@@ -2466,6 +2465,9 @@
// Record the first failure reason.
_failure_reason = reason;
}
+ if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) {
+ C->print_method(_failure_reason);
+ }
_root = NULL; // flush the graph, too
}
--- a/hotspot/src/share/vm/opto/idealGraphPrinter.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/idealGraphPrinter.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -100,16 +100,18 @@
// Constructor, either file or network output
IdealGraphPrinter::IdealGraphPrinter() {
- _traverse_outs = false;
+ // By default dump both ins and outs since dead or unreachable code
+ // needs to appear in the graph. There are also some special cases
+ // in the mach where kill projections have no users but should
+ // appear in the dump.
+ _traverse_outs = true;
_should_send_method = true;
_output = NULL;
buffer[0] = 0;
_depth = 0;
_current_method = NULL;
assert(!_current_method, "current method must be initialized to NULL");
- _arena = new Arena();
-
- _stream = new (ResourceObj::C_HEAP) networkStream();
+ _stream = NULL;
if (PrintIdealGraphFile != NULL) {
ThreadCritical tc;
@@ -124,12 +126,16 @@
} else {
st.print("%s%d", PrintIdealGraphFile, _file_count);
}
- _output = new (ResourceObj::C_HEAP) fileStream(st.as_string());
+ fileStream *stream = new (ResourceObj::C_HEAP) fileStream(st.as_string());
+ _output = stream;
} else {
- _output = new (ResourceObj::C_HEAP) fileStream(PrintIdealGraphFile);
+ fileStream *stream = new (ResourceObj::C_HEAP) fileStream(PrintIdealGraphFile);
+ _output = stream;
}
_file_count++;
} else {
+ _stream = new (ResourceObj::C_HEAP) networkStream();
+
// Try to connect to visualizer
if (_stream->connect(PrintIdealGraphAddress, PrintIdealGraphPort)) {
char c = 0;
@@ -149,13 +155,24 @@
}
}
- start_element(TOP_ELEMENT);
+ _xml = new (ResourceObj::C_HEAP) xmlStream(_output);
+
+ head(TOP_ELEMENT);
}
// Destructor, close file or network stream
IdealGraphPrinter::~IdealGraphPrinter() {
- end_element(TOP_ELEMENT);
+ tail(TOP_ELEMENT);
+
+ // tty->print_cr("Walk time: %d", (int)_walk_time.milliseconds());
+ // tty->print_cr("Output time: %d", (int)_output_time.milliseconds());
+ // tty->print_cr("Build blocks time: %d", (int)_build_blocks_time.milliseconds());
+
+ if(_xml) {
+ delete _xml;
+ _xml = NULL;
+ }
if (_stream) {
delete _stream;
@@ -171,94 +188,93 @@
}
}
-void IdealGraphPrinter::print_ifg(PhaseIFG* ifg) {
-
- // Code to print an interference graph to tty, currently not used
- /*
- if (!_current_method) return;
- // Remove neighbor colors
+void IdealGraphPrinter::begin_elem(const char *s) {
+ _xml->begin_elem(s);
+}
+
+void IdealGraphPrinter::end_elem() {
+ _xml->end_elem();
+}
- for (uint i = 0; i < ifg._maxlrg; i++) {
+void IdealGraphPrinter::begin_head(const char *s) {
+ _xml->begin_head(s);
+}
- IndexSet *s = ifg.neighbors(i);
- IndexSetIterator elements(s);
- uint neighbor;
- while ((neighbor = elements.next()) != 0) {
- tty->print_cr("Edge between %d and %d\n", i, neighbor);
- }
- }
+void IdealGraphPrinter::end_head() {
+ _xml->end_head();
+}
+void IdealGraphPrinter::print_attr(const char *name, intptr_t val) {
+ stringStream stream;
+ stream.print(INTX_FORMAT, val);
+ print_attr(name, stream.as_string());
+}
- for (uint i = 0; i < ifg._maxlrg; i++) {
- LRG &l = ifg.lrgs(i);
- if (l._def) {
- OptoReg::Name name = l.reg();
- tty->print("OptoReg::dump: ");
- OptoReg::dump(name);
- tty->print_cr("");
- tty->print_cr("name=%d\n", name);
- if (name) {
- if (OptoReg::is_stack(name)) {
- tty->print_cr("Stack number %d\n", OptoReg::reg2stack(name));
+void IdealGraphPrinter::print_attr(const char *name, const char *val) {
+ _xml->print(" %s='", name);
+ text(val);
+ _xml->print("'");
+}
- } else if (!OptoReg::is_valid(name)) {
- tty->print_cr("BAD!!!");
- } else {
+void IdealGraphPrinter::head(const char *name) {
+ _xml->head(name);
+}
+
+void IdealGraphPrinter::tail(const char *name) {
+ _xml->tail(name);
+}
- if (OptoReg::is_reg(name)) {
- tty->print_cr(OptoReg::regname(name));
- } else {
- int x = 0;
- }
- }
- int x = 0;
- }
+void IdealGraphPrinter::text(const char *s) {
+ _xml->text(s);
+}
+
+void IdealGraphPrinter::print_prop(const char *name, int val) {
- if (l._def == NodeSentinel) {
- tty->print("multiple mapping from %d: ", i);
- for (int j=0; j<l._defs->length(); j++) {
- tty->print("%d ", l._defs->at(j)->_idx);
- }
- tty->print_cr("");
- } else {
- tty->print_cr("mapping between %d and %d\n", i, l._def->_idx);
- }
- }
- }*/
+ stringStream stream;
+ stream.print("%d", val);
+ print_prop(name, stream.as_string());
+}
+
+void IdealGraphPrinter::print_prop(const char *name, const char *val) {
+ begin_head(PROPERTY_ELEMENT);
+ print_attr(PROPERTY_NAME_PROPERTY, name);
+ end_head();
+ text(val);
+ tail(PROPERTY_ELEMENT);
}
void IdealGraphPrinter::print_method(ciMethod *method, int bci, InlineTree *tree) {
+ begin_head(METHOD_ELEMENT);
- Properties properties;
stringStream str;
method->print_name(&str);
stringStream shortStr;
method->print_short_name(&shortStr);
+ print_attr(METHOD_NAME_PROPERTY, str.as_string());
+ print_attr(METHOD_SHORT_NAME_PROPERTY, shortStr.as_string());
+ print_attr(METHOD_BCI_PROPERTY, bci);
- properties.add(new Property(METHOD_NAME_PROPERTY, str.as_string()));
- properties.add(new Property(METHOD_SHORT_NAME_PROPERTY, shortStr.as_string()));
- properties.add(new Property(METHOD_BCI_PROPERTY, bci));
- start_element(METHOD_ELEMENT, &properties);
+ end_head();
- start_element(BYTECODES_ELEMENT);
+ head(BYTECODES_ELEMENT);
output()->print_cr("<![CDATA[");
method->print_codes_on(output());
output()->print_cr("]]>");
- end_element(BYTECODES_ELEMENT);
+ tail(BYTECODES_ELEMENT);
- start_element(INLINE_ELEMENT);
+ head(INLINE_ELEMENT);
if (tree != NULL) {
GrowableArray<InlineTree *> subtrees = tree->subtrees();
for (int i = 0; i < subtrees.length(); i++) {
print_inline_tree(subtrees.at(i));
}
}
- end_element(INLINE_ELEMENT);
+ tail(INLINE_ELEMENT);
- end_element(METHOD_ELEMENT);
+ tail(METHOD_ELEMENT);
output()->flush();
}
@@ -271,12 +287,6 @@
}
-void IdealGraphPrinter::clear_nodes() {
- // for (int i = 0; i < _nodes.length(); i++) {
- // _nodes.at(i)->clear_node();
- // }
-}
-
void IdealGraphPrinter::print_inlining(Compile* compile) {
// Print inline tree
@@ -298,143 +308,56 @@
assert(method, "null methods are not allowed!");
assert(!_current_method, "current method must be null!");
- _arena->destruct_contents();
+ head(GROUP_ELEMENT);
- start_element(GROUP_ELEMENT);
+ head(PROPERTIES_ELEMENT);
// Print properties
- Properties properties;
-
// Add method name
stringStream strStream;
method->print_name(&strStream);
- properties.add(new Property(METHOD_NAME_PROPERTY, strStream.as_string()));
+ print_prop(METHOD_NAME_PROPERTY, strStream.as_string());
if (method->flags().is_public()) {
- properties.add(new Property(METHOD_IS_PUBLIC_PROPERTY, TRUE_VALUE));
+ print_prop(METHOD_IS_PUBLIC_PROPERTY, TRUE_VALUE);
}
if (method->flags().is_static()) {
- properties.add(new Property(METHOD_IS_STATIC_PROPERTY, TRUE_VALUE));
+ print_prop(METHOD_IS_STATIC_PROPERTY, TRUE_VALUE);
}
- properties.print(this);
+ tail(PROPERTIES_ELEMENT);
if (_stream) {
char answer = 0;
- _stream->flush();
+ _xml->flush();
int result = _stream->read(&answer, 1);
_should_send_method = (answer == 'y');
}
- this->_nodes = GrowableArray<NodeDescription *>(_arena, 2, 0, NULL);
- this->_edges = GrowableArray< EdgeDescription * >(_arena, 2, 0, NULL);
-
-
this->_current_method = method;
-
-
- _output->flush();
+ _xml->flush();
}
// Has to be called whenever a method has finished compilation
void IdealGraphPrinter::end_method() {
-// if (finish && !in_method) return;
-
nmethod* method = (nmethod*)this->_current_method->code();
- start_element(ASSEMBLY_ELEMENT);
- // Disassembler::decode(method, _output);
- end_element(ASSEMBLY_ELEMENT);
-
-
- end_element(GROUP_ELEMENT);
+ tail(GROUP_ELEMENT);
_current_method = NULL;
- _output->flush();
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc) {
- delete desc;
- _nodes.at_put(i, NULL);
- }
- }
- this->_nodes.clear();
-
-
- for (int i = 0; i < _edges.length(); i++) {
- // for (int j=0; j<_edges.at(i)->length(); j++) {
- EdgeDescription *conn = _edges.at(i);
- conn->print(this);
- if (conn) {
- delete conn;
- _edges.at_put(i, NULL);
- }
- //}
- //_edges.at(i)->clear();
- //delete _edges.at(i);
- //_edges.at_put(i, NULL);
- }
- this->_edges.clear();
-
-// in_method = false;
-}
-
-// Outputs an XML start element
-void IdealGraphPrinter::start_element(const char *s, Properties *properties /* = NULL */, bool print_indent /* = false */, bool print_return /* = true */) {
-
- start_element_helper(s, properties, false, print_indent, print_return);
- _depth++;
-
-}
-
-// Outputs an XML start element without body
-void IdealGraphPrinter::simple_element(const char *s, Properties *properties /* = NULL */, bool print_indent /* = false */) {
- start_element_helper(s, properties, true, print_indent, true);
-}
-
-// Outputs an XML start element. If outputEnd is true, the element has no body.
-void IdealGraphPrinter::start_element_helper(const char *s, Properties *properties, bool outputEnd, bool print_indent /* = false */, bool print_return /* = true */) {
-
- assert(_output, "output stream must exist!");
-
- if (print_indent) this->print_indent();
- _output->print("<");
- _output->print(s);
- if (properties) properties->print_as_attributes(this);
-
- if (outputEnd) {
- _output->print("/");
- }
-
- _output->print(">");
- if (print_return) _output->print_cr("");
-
+ _xml->flush();
}
// Print indent
void IdealGraphPrinter::print_indent() {
+ tty->print_cr("printing ident %d", _depth);
for (int i = 0; i < _depth; i++) {
- _output->print(INDENT);
+ _xml->print(INDENT);
}
}
-// Outputs an XML end element
-void IdealGraphPrinter::end_element(const char *s, bool print_indent /* = true */, bool print_return /* = true */) {
-
- assert(_output, "output stream must exist!");
-
- _depth--;
-
- if (print_indent) this->print_indent();
- _output->print("</");
- _output->print(s);
- _output->print(">");
- if (print_return) _output->print_cr("");
-
-}
-
bool IdealGraphPrinter::traverse_outs() {
return _traverse_outs;
}
@@ -443,7 +366,255 @@
_traverse_outs = b;
}
-void IdealGraphPrinter::walk(Node *start) {
+intptr_t IdealGraphPrinter::get_node_id(Node *n) {
+ return (intptr_t)(n);
+}
+
+void IdealGraphPrinter::visit_node(Node *n, void *param) {
+
+ if(param) {
+
+ // Output edge
+ intptr_t dest_id = get_node_id(n);
+ for ( uint i = 0; i < n->len(); i++ ) {
+ if ( n->in(i) ) {
+ Node *source = n->in(i);
+ begin_elem(EDGE_ELEMENT);
+ intptr_t source_id = get_node_id(source);
+ print_attr(FROM_PROPERTY, source_id);
+ print_attr(TO_PROPERTY, dest_id);
+ print_attr(INDEX_PROPERTY, i);
+ end_elem();
+ }
+ }
+
+ } else {
+
+ // Output node
+ begin_head(NODE_ELEMENT);
+ print_attr(NODE_ID_PROPERTY, get_node_id(n));
+ end_head();
+
+ head(PROPERTIES_ELEMENT);
+
+ Node *node = n;
+#ifndef PRODUCT
+ node->_in_dump_cnt++;
+ print_prop(NODE_NAME_PROPERTY, (const char *)node->Name());
+ const Type *t = node->bottom_type();
+ print_prop("type", (const char *)Type::msg[t->base()]);
+ print_prop("idx", node->_idx);
+#ifdef ASSERT
+ print_prop("debug_idx", node->_debug_idx);
+#endif
+
+ if(C->cfg() != NULL) {
+ Block *block = C->cfg()->_bbs[node->_idx];
+ if(block == NULL) {
+ print_prop("block", C->cfg()->_blocks[0]->_pre_order);
+ } else {
+ print_prop("block", block->_pre_order);
+ }
+ }
+
+ const jushort flags = node->flags();
+ if (flags & Node::Flag_is_Copy) {
+ print_prop("is_copy", "true");
+ }
+ if (flags & Node::Flag_is_Call) {
+ print_prop("is_call", "true");
+ }
+ if (flags & Node::Flag_rematerialize) {
+ print_prop("rematerialize", "true");
+ }
+ if (flags & Node::Flag_needs_anti_dependence_check) {
+ print_prop("needs_anti_dependence_check", "true");
+ }
+ if (flags & Node::Flag_is_macro) {
+ print_prop("is_macro", "true");
+ }
+ if (flags & Node::Flag_is_Con) {
+ print_prop("is_con", "true");
+ }
+ if (flags & Node::Flag_is_cisc_alternate) {
+ print_prop("is_cisc_alternate", "true");
+ }
+ if (flags & Node::Flag_is_Branch) {
+ print_prop("is_branch", "true");
+ }
+ if (flags & Node::Flag_is_block_start) {
+ print_prop("is_block_start", "true");
+ }
+ if (flags & Node::Flag_is_Goto) {
+ print_prop("is_goto", "true");
+ }
+ if (flags & Node::Flag_is_dead_loop_safe) {
+ print_prop("is_dead_loop_safe", "true");
+ }
+ if (flags & Node::Flag_may_be_short_branch) {
+ print_prop("may_be_short_branch", "true");
+ }
+ if (flags & Node::Flag_is_safepoint_node) {
+ print_prop("is_safepoint_node", "true");
+ }
+ if (flags & Node::Flag_is_pc_relative) {
+ print_prop("is_pc_relative", "true");
+ }
+
+ if (C->matcher() != NULL) {
+ if (C->matcher()->is_shared(node)) {
+ print_prop("is_shared", "true");
+ } else {
+ print_prop("is_shared", "false");
+ }
+ if (C->matcher()->is_dontcare(node)) {
+ print_prop("is_dontcare", "true");
+ } else {
+ print_prop("is_dontcare", "false");
+ }
+
+ Node* old = C->matcher()->find_old_node(node);
+ if (old != NULL) {
+ print_prop("old_node_idx", old->_idx);
+ }
+ }
+
+ if (node->is_Proj()) {
+ print_prop("con", (int)node->as_Proj()->_con);
+ }
+
+ if (node->is_Mach()) {
+ print_prop("idealOpcode", (const char *)NodeClassNames[node->as_Mach()->ideal_Opcode()]);
+ }
+
+ buffer[0] = 0;
+ stringStream s2(buffer, sizeof(buffer) - 1);
+
+ node->dump_spec(&s2);
+ if (t != NULL && (t->isa_instptr() || t->isa_klassptr())) {
+ const TypeInstPtr *toop = t->isa_instptr();
+ const TypeKlassPtr *tkls = t->isa_klassptr();
+ ciKlass* klass = toop ? toop->klass() : (tkls ? tkls->klass() : NULL );
+ if( klass && klass->is_loaded() && klass->is_interface() ) {
+ s2.print(" Interface:");
+ } else if( toop ) {
+ s2.print(" Oop:");
+ } else if( tkls ) {
+ s2.print(" Klass:");
+ }
+ t->dump_on(&s2);
+ } else if( t == Type::MEMORY ) {
+ s2.print(" Memory:");
+ MemNode::dump_adr_type(node, node->adr_type(), &s2);
+ }
+
+ assert(s2.size() < sizeof(buffer), "size in range");
+ print_prop("dump_spec", buffer);
+
+ if (node->is_block_proj()) {
+ print_prop("is_block_proj", "true");
+ }
+
+ if (node->is_block_start()) {
+ print_prop("is_block_start", "true");
+ }
+
+ const char *short_name = "short_name";
+ if (strcmp(node->Name(), "Parm") == 0 && node->as_Proj()->_con >= TypeFunc::Parms) {
+ int index = node->as_Proj()->_con - TypeFunc::Parms;
+ if (index >= 10) {
+ print_prop(short_name, "PA");
+ } else {
+ sprintf(buffer, "P%d", index);
+ print_prop(short_name, buffer);
+ }
+ } else if (strcmp(node->Name(), "IfTrue") == 0) {
+ print_prop(short_name, "T");
+ } else if (strcmp(node->Name(), "IfFalse") == 0) {
+ print_prop(short_name, "F");
+ } else if ((node->is_Con() && node->is_Type()) || node->is_Proj()) {
+
+ if (t->base() == Type::Int && t->is_int()->is_con()) {
+ const TypeInt *typeInt = t->is_int();
+ assert(typeInt->is_con(), "must be constant");
+ jint value = typeInt->get_con();
+
+ // max. 2 chars allowed
+ if (value >= -9 && value <= 99) {
+ sprintf(buffer, "%d", value);
+ print_prop(short_name, buffer);
+ } else {
+ print_prop(short_name, "I");
+ }
+ } else if (t == Type::TOP) {
+ print_prop(short_name, "^");
+ } else if (t->base() == Type::Long && t->is_long()->is_con()) {
+ const TypeLong *typeLong = t->is_long();
+ assert(typeLong->is_con(), "must be constant");
+ jlong value = typeLong->get_con();
+
+ // max. 2 chars allowed
+ if (value >= -9 && value <= 99) {
+ sprintf(buffer, "%d", value);
+ print_prop(short_name, buffer);
+ } else {
+ print_prop(short_name, "L");
+ }
+ } else if (t->base() == Type::KlassPtr) {
+ const TypeKlassPtr *typeKlass = t->is_klassptr();
+ print_prop(short_name, "CP");
+ } else if (t->base() == Type::Control) {
+ print_prop(short_name, "C");
+ } else if (t->base() == Type::Memory) {
+ print_prop(short_name, "M");
+ } else if (t->base() == Type::Abio) {
+ print_prop(short_name, "IO");
+ } else if (t->base() == Type::Return_Address) {
+ print_prop(short_name, "RA");
+ } else if (t->base() == Type::AnyPtr) {
+ print_prop(short_name, "P");
+ } else if (t->base() == Type::RawPtr) {
+ print_prop(short_name, "RP");
+ } else if (t->base() == Type::AryPtr) {
+ print_prop(short_name, "AP");
+ }
+ }
+
+ JVMState* caller = NULL;
+ if (node->is_SafePoint()) {
+ caller = node->as_SafePoint()->jvms();
+ } else {
+ Node_Notes* notes = C->node_notes_at(node->_idx);
+ if (notes != NULL) {
+ caller = notes->jvms();
+ }
+ }
+
+ if (caller != NULL) {
+ stringStream bciStream;
+ while(caller) {
+ bciStream.print("%d ", caller->bci());
+ caller = caller->caller();
+ }
+ print_prop("bci", bciStream.as_string());
+ }
+
+ if (_chaitin && _chaitin != (PhaseChaitin *)0xdeadbeef) {
+ buffer[0] = 0;
+ _chaitin->dump_register(node, buffer);
+ print_prop("reg", buffer);
+ print_prop("lrg", _chaitin->n2lidx(node));
+ }
+
+ node->_in_dump_cnt--;
+#endif
+
+ tail(PROPERTIES_ELEMENT);
+ tail(NODE_ELEMENT);
+ }
+}
+
+void IdealGraphPrinter::walk_nodes(Node *start, void *param) {
VectorSet visited(Thread::current()->resource_area());
@@ -453,7 +624,7 @@
while(nodeStack.length() > 0) {
Node *n = nodeStack.pop();
- IdealGraphPrinter::pre_node(n, this);
+ visit_node(n, param);
if (_traverse_outs) {
for (DUIterator i = n->outs(); n->has_out(i); i++) {
@@ -474,573 +645,6 @@
}
}
-void IdealGraphPrinter::compress(int index, GrowableArray<Block>* blocks) {
- Block *block = blocks->adr_at(index);
-
- int ancestor = block->ancestor();
- assert(ancestor != -1, "");
-
- Block *ancestor_block = blocks->adr_at(ancestor);
- if (ancestor_block->ancestor() != -1) {
- compress(ancestor, blocks);
-
- int label = block->label();
- Block *label_block = blocks->adr_at(label);
-
- int ancestor_label = ancestor_block->label();
- Block *ancestor_label_block = blocks->adr_at(label);
- if (ancestor_label_block->semi() < label_block->semi()) {
- block->set_label(ancestor_label);
- }
-
- block->set_ancestor(ancestor_block->ancestor());
- }
-}
-
-int IdealGraphPrinter::eval(int index, GrowableArray<Block>* blocks) {
- Block *block = blocks->adr_at(index);
- if (block->ancestor() == -1) {
- return index;
- } else {
- compress(index, blocks);
- return block->label();
- }
-}
-
-void IdealGraphPrinter::link(int index1, int index2, GrowableArray<Block>* blocks) {
- Block *block2 = blocks->adr_at(index2);
- block2->set_ancestor(index1);
-}
-
-void IdealGraphPrinter::build_dominators(GrowableArray<Block>* blocks) {
-
- if (blocks->length() == 0) return;
-
- GrowableArray<int> stack;
- stack.append(0);
-
- GrowableArray<Block *> array;
-
- assert(blocks->length() > 0, "");
- blocks->adr_at(0)->set_dominator(0);
-
- int n = 0;
- while(!stack.is_empty()) {
- int index = stack.pop();
- Block *block = blocks->adr_at(index);
- block->set_semi(n);
- array.append(block);
- n = n + 1;
- for (int i = 0; i < block->succs()->length(); i++) {
- int succ_index = block->succs()->at(i);
- Block *succ = blocks->adr_at(succ_index);
- if (succ->semi() == -1) {
- succ->set_parent(index);
- stack.push(succ_index);
- }
- succ->add_pred(index);
- }
- }
-
- for (int i=n-1; i>0; i--) {
- Block *block = array.at(i);
- int block_index = block->index();
- for (int j=0; j<block->pred()->length(); j++) {
- int pred_index = block->pred()->at(j);
- int cur_index = eval(pred_index, blocks);
-
- Block *cur_block = blocks->adr_at(cur_index);
- if (cur_block->semi() < block->semi()) {
- block->set_semi(cur_block->semi());
- }
- }
-
- int semi_index = block->semi();
- Block *semi_block = array.at(semi_index);
- semi_block->add_to_bucket(block_index);
-
- link(block->parent(), block_index, blocks);
- Block *parent_block = blocks->adr_at(block->parent());
-
- for (int j=0; j<parent_block->bucket()->length(); j++) {
- int cur_index = parent_block->bucket()->at(j);
- int new_index = eval(cur_index, blocks);
- Block *cur_block = blocks->adr_at(cur_index);
- Block *new_block = blocks->adr_at(new_index);
- int dom = block->parent();
-
- if (new_block->semi() < cur_block->semi()) {
- dom = new_index;
- }
-
- cur_block->set_dominator(dom);
- }
-
- parent_block->clear_bucket();
- }
-
- for (int i=1; i < n; i++) {
-
- Block *block = array.at(i);
- int block_index = block->index();
-
- int semi_index = block->semi();
- Block *semi_block = array.at(semi_index);
-
- if (block->dominator() != semi_block->index()) {
- int new_dom = blocks->adr_at(block->dominator())->dominator();
- block->set_dominator(new_dom);
- }
- }
-
- for (int i = 0; i < blocks->length(); i++) {
- if (blocks->adr_at(i)->dominator() == -1) {
- blocks->adr_at(i)->set_dominator(0);
- }
- }
-
- // Build dominates array
- for (int i=1; i < blocks->length(); i++) {
- Block *block = blocks->adr_at(i);
- int dominator = block->dominator();
- Block *dom_block = blocks->adr_at(dominator);
- dom_block->add_dominates(i);
- dom_block->add_child(i);
-
- while(dominator != 0) {
- dominator = dom_block->dominator();
- dom_block = blocks->adr_at(dominator);
- dom_block->add_child(i);
- }
- }
-}
-
-void IdealGraphPrinter::build_common_dominator(int **common_dominator, int index, GrowableArray<Block>* blocks) {
-
- common_dominator[index][index] = index;
- Block *block = blocks->adr_at(index);
- for (int i = 0; i < block->dominates()->length(); i++) {
- Block *dominated = blocks->adr_at(block->dominates()->at(i));
-
- for (int j=0; j<dominated->children()->length(); j++) {
- Block *child = blocks->adr_at(dominated->children()->at(j));
- common_dominator[index][child->index()] = common_dominator[child->index()][index] = index;
-
- for (int k=0; k<i; k++) {
- Block *other_dominated = blocks->adr_at(block->dominates()->at(k));
- common_dominator[child->index()][other_dominated->index()] = common_dominator[other_dominated->index()][child->index()] = index;
-
- for (int l=0 ; l<other_dominated->children()->length(); l++) {
- Block *other_child = blocks->adr_at(other_dominated->children()->at(l));
- common_dominator[child->index()][other_child->index()] = common_dominator[other_child->index()][child->index()] = index;
- }
- }
- }
-
- build_common_dominator(common_dominator, dominated->index(), blocks);
- }
-}
-
-void IdealGraphPrinter::schedule_latest(int **common_dominator, GrowableArray<Block>* blocks) {
-
- int queue_size = _nodes.length() + 1;
- NodeDescription **queue = NEW_RESOURCE_ARRAY(NodeDescription *, queue_size);
- int queue_start = 0;
- int queue_end = 0;
- Arena *a = new Arena();
- VectorSet on_queue(a);
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc) {
- desc->init_succs();
- }
- }
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc) {
- for (uint j=0; j<desc->node()->len(); j++) {
- Node *n = desc->node()->in(j);
- if (n) {
- NodeDescription *other_desc = _nodes.at(n->_idx);
- other_desc->add_succ(desc);
- }
- }
- }
- }
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc && desc->block_index() == -1) {
-
- // Put Phi into same block as region
- if (desc->node()->is_Phi() && desc->node()->in(0) && _nodes.at(desc->node()->in(0)->_idx)->block_index() != -1) {
- int index = _nodes.at(desc->node()->in(0)->_idx)->block_index();
- desc->set_block_index(index);
- blocks->adr_at(index)->add_node(desc);
-
- // Put Projections to same block as parent
- } else if (desc->node()->is_block_proj() && _nodes.at(desc->node()->is_block_proj()->_idx)->block_index() != -1) {
- int index = _nodes.at(desc->node()->is_block_proj()->_idx)->block_index();
- desc->set_block_index(index);
- blocks->adr_at(index)->add_node(desc);
- } else {
- queue[queue_end] = desc;
- queue_end++;
- on_queue.set(desc->node()->_idx);
- }
- }
- }
-
-
- int z = 0;
- while(queue_start != queue_end && z < 10000) {
-
- NodeDescription *desc = queue[queue_start];
- queue_start = (queue_start + 1) % queue_size;
- on_queue >>= desc->node()->_idx;
-
- Node* node = desc->node();
-
- if (desc->succs()->length() == 0) {
- int x = 0;
- }
-
- int block_index = -1;
- if (desc->succs()->length() != 0) {
- for (int i = 0; i < desc->succs()->length(); i++) {
- NodeDescription *cur_desc = desc->succs()->at(i);
- if (cur_desc != desc) {
- if (cur_desc->succs()->length() == 0) {
-
- // Ignore nodes with 0 successors
-
- } else if (cur_desc->block_index() == -1) {
-
- // Let this node schedule first
- block_index = -1;
- break;
-
- } else if (cur_desc->node()->is_Phi()){
-
- // Special treatment for Phi functions
- PhiNode *phi = cur_desc->node()->as_Phi();
- assert(phi->in(0) && phi->in(0)->is_Region(), "Must have region node in first input");
- RegionNode *region = phi->in(0)->as_Region();
-
- for (uint j=1; j<phi->len(); j++) {
- Node *cur_phi_input = phi->in(j);
- if (cur_phi_input == desc->node() && region->in(j)) {
- NodeDescription *cur_region_input = _nodes.at(region->in(j)->_idx);
- if (cur_region_input->block_index() == -1) {
-
- // Let this node schedule first
- block_index = -1;
- break;
- } else {
- if (block_index == -1) {
- block_index = cur_region_input->block_index();
- } else {
- block_index = common_dominator[block_index][cur_region_input->block_index()];
- }
- }
- }
- }
-
- } else {
- if (block_index == -1) {
- block_index = cur_desc->block_index();
- } else {
- block_index = common_dominator[block_index][cur_desc->block_index()];
- }
- }
- }
- }
- }
-
- if (block_index == -1) {
- queue[queue_end] = desc;
- queue_end = (queue_end + 1) % queue_size;
- on_queue.set(desc->node()->_idx);
- z++;
- } else {
- assert(desc->block_index() == -1, "");
- desc->set_block_index(block_index);
- blocks->adr_at(block_index)->add_node(desc);
- z = 0;
- }
- }
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc && desc->block_index() == -1) {
-
- //if (desc->node()->is_Proj() || desc->node()->is_Con()) {
- Node *parent = desc->node()->in(0);
- uint cur = 1;
- while(!parent && cur < desc->node()->len()) {
- parent = desc->node()->in(cur);
- cur++;
- }
-
- if (parent && _nodes.at(parent->_idx)->block_index() != -1) {
- int index = _nodes.at(parent->_idx)->block_index();
- desc->set_block_index(index);
- blocks->adr_at(index)->add_node(desc);
- } else {
- desc->set_block_index(0);
- blocks->adr_at(0)->add_node(desc);
- //ShouldNotReachHere();
- }
- //}
- /*
- if (desc->node()->is_block_proj() && _nodes.at(desc->node()->is_block_proj()->_idx)->block_index() != -1) {
- int index = _nodes.at(desc->node()->is_block_proj()->_idx)->block_index();
- desc->set_block_index(index);
- blocks->adr_at(index)->add_node(desc);
- } */
- }
- }
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc) {
- desc->clear_succs();
- }
- }
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc) {
- int block_index = desc->block_index();
-
- assert(block_index >= 0 && block_index < blocks->length(), "Block index must be in range");
- assert(blocks->adr_at(block_index)->nodes()->contains(desc), "Node must be child of block");
- }
- }
- a->destruct_contents();
-}
-
-void IdealGraphPrinter::build_blocks(Node *root) {
-
- Arena *a = new Arena();
- Node_Stack stack(a, 100);
-
- VectorSet visited(a);
- stack.push(root, 0);
- GrowableArray<Block> blocks(a, 2, 0, Block(0));
-
- for (int i = 0; i < _nodes.length(); i++) {
- if (_nodes.at(i)) _nodes.at(i)->set_block_index(-1);
- }
-
-
- // Order nodes such that node index is equal to idx
- for (int i = 0; i < _nodes.length(); i++) {
-
- if (_nodes.at(i)) {
- NodeDescription *node = _nodes.at(i);
- int index = node->node()->_idx;
- if (index != i) {
- _nodes.at_grow(index);
- NodeDescription *tmp = _nodes.at(index);
- *(_nodes.adr_at(index)) = node;
- *(_nodes.adr_at(i)) = tmp;
- i--;
- }
- }
- }
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *node = _nodes.at(i);
- if (node) {
- assert(node->node()->_idx == (uint)i, "");
- }
- }
-
- while(stack.is_nonempty()) {
-
- //Node *n = stack.node();
- //int index = stack.index();
- Node *proj = stack.node();//n->in(index);
- const Node *parent = proj->is_block_proj();
- if (parent == NULL) {
- parent = proj;
- }
-
- if (!visited.test_set(parent->_idx)) {
-
- NodeDescription *end_desc = _nodes.at(parent->_idx);
- int block_index = blocks.length();
- Block block(block_index);
- blocks.append(block);
- Block *b = blocks.adr_at(block_index);
- b->set_start(end_desc);
- // assert(end_desc->block_index() == -1, "");
- end_desc->set_block_index(block_index);
- b->add_node(end_desc);
-
- // Skip any control-pinned middle'in stuff
- Node *p = proj;
- NodeDescription *start_desc = NULL;
- do {
- proj = p; // Update pointer to last Control
- if (p->in(0) == NULL) {
- start_desc = end_desc;
- break;
- }
- p = p->in(0); // Move control forward
- start_desc = _nodes.at(p->_idx);
- assert(start_desc, "");
-
- if (start_desc != end_desc && start_desc->block_index() == -1) {
- assert(start_desc->block_index() == -1, "");
- assert(block_index < blocks.length(), "");
- start_desc->set_block_index(block_index);
- b->add_node(start_desc);
- }
- } while( !p->is_block_proj() &&
- !p->is_block_start() );
-
- for (uint i = 0; i < start_desc->node()->len(); i++) {
-
- Node *pred_node = start_desc->node()->in(i);
-
-
- if (pred_node && pred_node != start_desc->node()) {
- const Node *cur_parent = pred_node->is_block_proj();
- if (cur_parent != NULL) {
- pred_node = (Node *)cur_parent;
- }
-
- NodeDescription *pred_node_desc = _nodes.at(pred_node->_idx);
- if (pred_node_desc->block_index() != -1) {
- blocks.adr_at(pred_node_desc->block_index())->add_succ(block_index);
- }
- }
- }
-
- for (DUIterator_Fast dmax, i = end_desc->node()->fast_outs(dmax); i < dmax; i++) {
- Node* cur_succ = end_desc->node()->fast_out(i);
- NodeDescription *cur_succ_desc = _nodes.at(cur_succ->_idx);
-
- DUIterator_Fast dmax2, i2 = cur_succ->fast_outs(dmax2);
- if (cur_succ->is_block_proj() && i2 < dmax2 && !cur_succ->is_Root()) {
-
- for (; i2<dmax2; i2++) {
- Node *cur_succ2 = cur_succ->fast_out(i2);
- if (cur_succ2) {
- cur_succ_desc = _nodes.at(cur_succ2->_idx);
- if (cur_succ_desc == NULL) {
- // dead node so skip it
- continue;
- }
- if (cur_succ2 != end_desc->node() && cur_succ_desc->block_index() != -1) {
- b->add_succ(cur_succ_desc->block_index());
- }
- }
- }
-
- } else {
-
- if (cur_succ != end_desc->node() && cur_succ_desc && cur_succ_desc->block_index() != -1) {
- b->add_succ(cur_succ_desc->block_index());
- }
- }
- }
-
-
- int num_preds = p->len();
- int bottom = -1;
- if (p->is_Region() || p->is_Phi()) {
- bottom = 0;
- }
-
- int pushed = 0;
- for (int i=num_preds - 1; i > bottom; i--) {
- if (p->in(i) != NULL && p->in(i) != p) {
- stack.push(p->in(i), 0);
- pushed++;
- }
- }
-
- if (pushed == 0 && p->is_Root() && !_matcher) {
- // Special case when backedges to root are not yet built
- for (int i = 0; i < _nodes.length(); i++) {
- if (_nodes.at(i) && _nodes.at(i)->node()->is_SafePoint() && _nodes.at(i)->node()->outcnt() == 0) {
- stack.push(_nodes.at(i)->node(), 0);
- }
- }
- }
-
- } else {
- stack.pop();
- }
- }
-
- build_dominators(&blocks);
-
- int **common_dominator = NEW_RESOURCE_ARRAY(int *, blocks.length());
- for (int i = 0; i < blocks.length(); i++) {
- int *cur = NEW_RESOURCE_ARRAY(int, blocks.length());
- common_dominator[i] = cur;
-
- for (int j=0; j<blocks.length(); j++) {
- cur[j] = 0;
- }
- }
-
- for (int i = 0; i < blocks.length(); i++) {
- blocks.adr_at(i)->add_child(blocks.adr_at(i)->index());
- }
- build_common_dominator(common_dominator, 0, &blocks);
-
- schedule_latest(common_dominator, &blocks);
-
- start_element(CONTROL_FLOW_ELEMENT);
-
- for (int i = 0; i < blocks.length(); i++) {
- Block *block = blocks.adr_at(i);
-
- Properties props;
- props.add(new Property(BLOCK_NAME_PROPERTY, i));
- props.add(new Property(BLOCK_DOMINATOR_PROPERTY, block->dominator()));
- start_element(BLOCK_ELEMENT, &props);
-
- if (block->succs()->length() > 0) {
- start_element(SUCCESSORS_ELEMENT);
- for (int j=0; j<block->succs()->length(); j++) {
- int cur_index = block->succs()->at(j);
- if (cur_index != 0 /* start_block has must not have inputs */) {
- Properties properties;
- properties.add(new Property(BLOCK_NAME_PROPERTY, cur_index));
- simple_element(SUCCESSOR_ELEMENT, &properties);
- }
- }
- end_element(SUCCESSORS_ELEMENT);
- }
-
- start_element(NODES_ELEMENT);
-
- for (int j=0; j<block->nodes()->length(); j++) {
- NodeDescription *n = block->nodes()->at(j);
- Properties properties;
- properties.add(new Property(NODE_ID_PROPERTY, n->id()));
- simple_element(NODE_ELEMENT, &properties);
- }
-
- end_element(NODES_ELEMENT);
-
- end_element(BLOCK_ELEMENT);
- }
-
-
- end_element(CONTROL_FLOW_ELEMENT);
-
- a->destruct_contents();
-}
-
void IdealGraphPrinter::print_method(Compile* compile, const char *name, int level, bool clear_nodes) {
print(compile, name, (Node *)compile->root(), level, clear_nodes);
}
@@ -1048,872 +652,53 @@
// Print current ideal graph
void IdealGraphPrinter::print(Compile* compile, const char *name, Node *node, int level, bool clear_nodes) {
-// if (finish && !in_method) return;
if (!_current_method || !_should_send_method || level > PrintIdealGraphLevel) return;
- assert(_current_method, "newMethod has to be called first!");
-
- if (clear_nodes) {
- int x = 0;
- }
-
- _clear_nodes = clear_nodes;
+ this->C = compile;
// Warning, unsafe cast?
- _chaitin = (PhaseChaitin *)compile->regalloc();
- _matcher = compile->matcher();
-
-
- // Update nodes
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc) {
- desc->set_state(Invalid);
- }
- }
- Node *n = node;
- walk(n);
-
- // Update edges
- for (int i = 0; i < _edges.length(); i++) {
- _edges.at(i)->set_state(Invalid);
- }
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc && desc->state() != Invalid) {
-
- int to = desc->id();
- uint len = desc->node()->len();
- for (uint j=0; j<len; j++) {
- Node *n = desc->node()->in(j);
-
- if (n) {
-
-
- intptr_t from = (intptr_t)n;
+ _chaitin = (PhaseChaitin *)C->regalloc();
- // Assert from node is valid
- /*
- bool ok = false;
- for (int k=0; k<_nodes.length(); k++) {
- NodeDescription *desc = _nodes.at(k);
- if (desc && desc->id() == from) {
- assert(desc->state() != Invalid, "");
- ok = true;
- }
- }
- assert(ok, "");*/
-
- uint index = j;
- if (index >= desc->node()->req()) {
- index = desc->node()->req();
- }
+ begin_head(GRAPH_ELEMENT);
+ print_attr(GRAPH_NAME_PROPERTY, (const char *)name);
+ end_head();
- print_edge(from, to, index);
- }
- }
- }
- }
-
- bool is_different = false;
-
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc && desc->state() != Valid) {
- is_different = true;
- break;
- }
- }
-
- if (!is_different) {
- for (int i = 0; i < _edges.length(); i++) {
- EdgeDescription *conn = _edges.at(i);
- if (conn && conn->state() != Valid) {
- is_different = true;
- break;
- }
- }
- }
+ head(NODES_ELEMENT);
+ walk_nodes(node, NULL);
+ tail(NODES_ELEMENT);
- // No changes -> do not print graph
- if (!is_different) return;
-
- Properties properties;
- properties.add(new Property(GRAPH_NAME_PROPERTY, (const char *)name));
- start_element(GRAPH_ELEMENT, &properties);
-
- start_element(NODES_ELEMENT);
- for (int i = 0; i < _nodes.length(); i++) {
- NodeDescription *desc = _nodes.at(i);
- if (desc) {
- desc->print(this);
- if (desc->state() == Invalid) {
- delete desc;
- _nodes.at_put(i, NULL);
- } else {
- desc->set_state(Valid);
- }
- }
- }
- end_element(NODES_ELEMENT);
-
- build_blocks(node);
-
- start_element(EDGES_ELEMENT);
- for (int i = 0; i < _edges.length(); i++) {
- EdgeDescription *conn = _edges.at(i);
-
- // Assert from and to nodes are valid
- /*
- if (!conn->state() == Invalid) {
- bool ok1 = false;
- bool ok2 = false;
- for (int j=0; j<_nodes.length(); j++) {
- NodeDescription *desc = _nodes.at(j);
- if (desc && desc->id() == conn->from()) {
- ok1 = true;
- }
+ head(EDGES_ELEMENT);
+ walk_nodes(node, (void *)1);
+ tail(EDGES_ELEMENT);
+ if (C->cfg() != NULL) {
+ head(CONTROL_FLOW_ELEMENT);
+ for (uint i = 0; i < C->cfg()->_blocks.size(); i++) {
+ Block *b = C->cfg()->_blocks[i];
+ begin_head(BLOCK_ELEMENT);
+ print_attr(BLOCK_NAME_PROPERTY, b->_pre_order);
+ end_head();
- if (desc && desc->id() == conn->to()) {
- ok2 = true;
- }
+ head(SUCCESSORS_ELEMENT);
+ for (uint s = 0; s < C->cfg()->_blocks[i]->_num_succs; s++) {
+ begin_elem(SUCCESSOR_ELEMENT);
+ print_attr(BLOCK_NAME_PROPERTY, b->_succs[s]->_pre_order);
+ end_elem();
}
-
- assert(ok1, "from node not found!");
- assert(ok2, "to node not found!");
- }*/
-
- conn->print(this);
- if (conn->state() == Invalid) {
- _edges.remove_at(i);
- delete conn;
- i--;
- }
- }
-
- end_element(EDGES_ELEMENT);
+ tail(SUCCESSORS_ELEMENT);
- end_element(GRAPH_ELEMENT);
-
- _output->flush();
-}
-
-// Print edge
-void IdealGraphPrinter::print_edge(int from, int to, int index) {
+ tail(BLOCK_ELEMENT);
+ }
- EdgeDescription *conn = new EdgeDescription(from, to, index);
- for (int i = 0; i < _edges.length(); i++) {
- if (_edges.at(i)->equals(conn)) {
- conn->set_state(Valid);
- delete _edges.at(i);
- _edges.at_put(i, conn);
- return;
- }
+ tail(CONTROL_FLOW_ELEMENT);
}
-
- _edges.append(conn);
+ tail(GRAPH_ELEMENT);
+ output()->flush();
}
extern const char *NodeClassNames[];
-// Create node description
-IdealGraphPrinter::NodeDescription *IdealGraphPrinter::create_node_description(Node* node) {
-
-#ifndef PRODUCT
- node->_in_dump_cnt++;
- NodeDescription *desc = new NodeDescription(node);
- desc->properties()->add(new Property(NODE_NAME_PROPERTY, (const char *)node->Name()));
-
- const Type *t = node->bottom_type();
- desc->properties()->add(new Property("type", (const char *)Type::msg[t->base()]));
-
- desc->properties()->add(new Property("idx", node->_idx));
-#ifdef ASSERT
- desc->properties()->add(new Property("debug_idx", node->_debug_idx));
-#endif
-
-
- const jushort flags = node->flags();
- if (flags & Node::Flag_is_Copy) {
- desc->properties()->add(new Property("is_copy", "true"));
- }
- if (flags & Node::Flag_is_Call) {
- desc->properties()->add(new Property("is_call", "true"));
- }
- if (flags & Node::Flag_rematerialize) {
- desc->properties()->add(new Property("rematerialize", "true"));
- }
- if (flags & Node::Flag_needs_anti_dependence_check) {
- desc->properties()->add(new Property("needs_anti_dependence_check", "true"));
- }
- if (flags & Node::Flag_is_macro) {
- desc->properties()->add(new Property("is_macro", "true"));
- }
- if (flags & Node::Flag_is_Con) {
- desc->properties()->add(new Property("is_con", "true"));
- }
- if (flags & Node::Flag_is_cisc_alternate) {
- desc->properties()->add(new Property("is_cisc_alternate", "true"));
- }
- if (flags & Node::Flag_is_Branch) {
- desc->properties()->add(new Property("is_branch", "true"));
- }
- if (flags & Node::Flag_is_block_start) {
- desc->properties()->add(new Property("is_block_start", "true"));
- }
- if (flags & Node::Flag_is_Goto) {
- desc->properties()->add(new Property("is_goto", "true"));
- }
- if (flags & Node::Flag_is_dead_loop_safe) {
- desc->properties()->add(new Property("is_dead_loop_safe", "true"));
- }
- if (flags & Node::Flag_may_be_short_branch) {
- desc->properties()->add(new Property("may_be_short_branch", "true"));
- }
- if (flags & Node::Flag_is_safepoint_node) {
- desc->properties()->add(new Property("is_safepoint_node", "true"));
- }
- if (flags & Node::Flag_is_pc_relative) {
- desc->properties()->add(new Property("is_pc_relative", "true"));
- }
-
- if (_matcher) {
- if (_matcher->is_shared(desc->node())) {
- desc->properties()->add(new Property("is_shared", "true"));
- } else {
- desc->properties()->add(new Property("is_shared", "false"));
- }
-
- if (_matcher->is_dontcare(desc->node())) {
- desc->properties()->add(new Property("is_dontcare", "true"));
- } else {
- desc->properties()->add(new Property("is_dontcare", "false"));
- }
- }
-
- if (node->is_Proj()) {
- desc->properties()->add(new Property("con", (int)node->as_Proj()->_con));
- }
-
- if (node->is_Mach()) {
- desc->properties()->add(new Property("idealOpcode", (const char *)NodeClassNames[node->as_Mach()->ideal_Opcode()]));
- }
-
-
-
-
-
- outputStream *oldTty = tty;
- buffer[0] = 0;
- stringStream s2(buffer, sizeof(buffer) - 1);
-
- node->dump_spec(&s2);
- assert(s2.size() < sizeof(buffer), "size in range");
- desc->properties()->add(new Property("dump_spec", buffer));
-
- if (node->is_block_proj()) {
- desc->properties()->add(new Property("is_block_proj", "true"));
- }
-
- if (node->is_block_start()) {
- desc->properties()->add(new Property("is_block_start", "true"));
- }
-
- const char *short_name = "short_name";
- if (strcmp(node->Name(), "Parm") == 0 && node->as_Proj()->_con >= TypeFunc::Parms) {
- int index = node->as_Proj()->_con - TypeFunc::Parms;
- if (index >= 10) {
- desc->properties()->add(new Property(short_name, "PA"));
- } else {
- sprintf(buffer, "P%d", index);
- desc->properties()->add(new Property(short_name, buffer));
- }
- } else if (strcmp(node->Name(), "IfTrue") == 0) {
- desc->properties()->add(new Property(short_name, "T"));
- } else if (strcmp(node->Name(), "IfFalse") == 0) {
- desc->properties()->add(new Property(short_name, "F"));
- } else if ((node->is_Con() && node->is_Type()) || node->is_Proj()) {
-
- if (t->base() == Type::Int && t->is_int()->is_con()) {
- const TypeInt *typeInt = t->is_int();
- assert(typeInt->is_con(), "must be constant");
- jint value = typeInt->get_con();
-
- // max. 2 chars allowed
- if (value >= -9 && value <= 99) {
- sprintf(buffer, "%d", value);
- desc->properties()->add(new Property(short_name, buffer));
- }
- else
- {
- desc->properties()->add(new Property(short_name, "I"));
- }
- } else if (t == Type::TOP) {
- desc->properties()->add(new Property(short_name, "^"));
- } else if (t->base() == Type::Long && t->is_long()->is_con()) {
- const TypeLong *typeLong = t->is_long();
- assert(typeLong->is_con(), "must be constant");
- jlong value = typeLong->get_con();
-
- // max. 2 chars allowed
- if (value >= -9 && value <= 99) {
- sprintf(buffer, "%d", value);
- desc->properties()->add(new Property(short_name, buffer));
- }
- else
- {
- desc->properties()->add(new Property(short_name, "L"));
- }
- } else if (t->base() == Type::KlassPtr) {
- const TypeKlassPtr *typeKlass = t->is_klassptr();
- desc->properties()->add(new Property(short_name, "CP"));
- } else if (t->base() == Type::Control) {
- desc->properties()->add(new Property(short_name, "C"));
- } else if (t->base() == Type::Memory) {
- desc->properties()->add(new Property(short_name, "M"));
- } else if (t->base() == Type::Abio) {
- desc->properties()->add(new Property(short_name, "IO"));
- } else if (t->base() == Type::Return_Address) {
- desc->properties()->add(new Property(short_name, "RA"));
- } else if (t->base() == Type::AnyPtr) {
- desc->properties()->add(new Property(short_name, "P"));
- } else if (t->base() == Type::RawPtr) {
- desc->properties()->add(new Property(short_name, "RP"));
- } else if (t->base() == Type::AryPtr) {
- desc->properties()->add(new Property(short_name, "AP"));
- }
- }
-
- if (node->is_SafePoint()) {
- SafePointNode *safePointNode = node->as_SafePoint();
- if (safePointNode->jvms()) {
- stringStream bciStream;
- bciStream.print("%d ", safePointNode->jvms()->bci());
- JVMState *caller = safePointNode->jvms()->caller();
- while(caller) {
- bciStream.print("%d ", caller->bci());
-
- caller = caller->caller();
- }
- desc->properties()->add(new Property("bci", bciStream.as_string()));
- }
- }
-
- if (_chaitin && _chaitin != (PhaseChaitin *)0xdeadbeef) {
- buffer[0] = 0;
- _chaitin->dump_register(node, buffer);
- desc->properties()->add(new Property("reg", buffer));
- desc->properties()->add(new Property("lrg", _chaitin->n2lidx(node)));
- }
-
-
- node->_in_dump_cnt--;
- return desc;
-#else
- return NULL;
-#endif
-}
-
-void IdealGraphPrinter::pre_node(Node* node, void *env) {
-
- IdealGraphPrinter *printer = (IdealGraphPrinter *)env;
-
- NodeDescription *newDesc = printer->create_node_description(node);
-
- if (printer->_clear_nodes) {
-
- printer->_nodes.append(newDesc);
- } else {
-
- NodeDescription *desc = printer->_nodes.at_grow(node->_idx, NULL);
-
- if (desc && desc->equals(newDesc)) {
- //desc->set_state(Valid);
- //desc->set_node(node);
- delete desc;
- printer->_nodes.at_put(node->_idx, NULL);
- newDesc->set_state(Valid);
- //printer->_nodes.at_put(node->_idx, newDesc);
- } else {
-
- if (desc && desc->id() == newDesc->id()) {
- delete desc;
- printer->_nodes.at_put(node->_idx, NULL);
- newDesc->set_state(New);
-
- }
-
- //if (desc) {
- // delete desc;
- //}
-
- //printer->_nodes.at_put(node->_idx, newDesc);
- }
-
- printer->_nodes.append(newDesc);
- }
-}
-
-void IdealGraphPrinter::post_node(Node* node, void *env) {
-}
-
outputStream *IdealGraphPrinter::output() {
- return _output;
-}
-
-IdealGraphPrinter::Description::Description() {
- _state = New;
-}
-
-void IdealGraphPrinter::Description::print(IdealGraphPrinter *printer) {
- if (_state == Invalid) {
- print_removed(printer);
- } else if (_state == New) {
- print_changed(printer);
- }
-}
-
-void IdealGraphPrinter::Description::set_state(State s) {
- _state = s;
-}
-
-IdealGraphPrinter::State IdealGraphPrinter::Description::state() {
- return _state;
-}
-
-void IdealGraphPrinter::Block::set_proj(NodeDescription *n) {
- _proj = n;
-}
-
-void IdealGraphPrinter::Block::set_start(NodeDescription *n) {
- _start = n;
-}
-
-int IdealGraphPrinter::Block::semi() {
- return _semi;
-}
-
-int IdealGraphPrinter::Block::parent() {
- return _parent;
-}
-
-GrowableArray<int>* IdealGraphPrinter::Block::bucket() {
- return &_bucket;
-}
-
-GrowableArray<int>* IdealGraphPrinter::Block::children() {
- return &_children;
-}
-
-void IdealGraphPrinter::Block::add_child(int i) {
- _children.append(i);
-}
-
-GrowableArray<int>* IdealGraphPrinter::Block::dominates() {
- return &_dominates;
-}
-
-void IdealGraphPrinter::Block::add_dominates(int i) {
- _dominates.append(i);
-}
-
-void IdealGraphPrinter::Block::add_to_bucket(int i) {
- _bucket.append(i);
-}
-
-void IdealGraphPrinter::Block::clear_bucket() {
- _bucket.clear();
-}
-
-void IdealGraphPrinter::Block::set_dominator(int i) {
- _dominator = i;
-}
-
-void IdealGraphPrinter::Block::set_label(int i) {
- _label = i;
-}
-
-int IdealGraphPrinter::Block::label() {
- return _label;
-}
-
-int IdealGraphPrinter::Block::ancestor() {
- return _ancestor;
-}
-
-void IdealGraphPrinter::Block::set_ancestor(int i) {
- _ancestor = i;
-}
-
-int IdealGraphPrinter::Block::dominator() {
- return _dominator;
-}
-
-int IdealGraphPrinter::Block::index() {
- return _index;
-}
-
-void IdealGraphPrinter::Block::set_parent(int i) {
- _parent = i;
-}
-
-GrowableArray<int>* IdealGraphPrinter::Block::pred() {
- return &_pred;
-}
-
-void IdealGraphPrinter::Block::set_semi(int i) {
- _semi = i;
-}
-
-IdealGraphPrinter::Block::Block() {
-}
-
-IdealGraphPrinter::Block::Block(int index) {
- _index = index;
- _label = index;
- _semi = -1;
- _ancestor = -1;
- _dominator = -1;
-}
-
-void IdealGraphPrinter::Block::add_pred(int i) {
- _pred.append(i);
-}
-
-IdealGraphPrinter::NodeDescription *IdealGraphPrinter::Block::proj() {
- return _proj;
-}
-
-IdealGraphPrinter::NodeDescription *IdealGraphPrinter::Block::start() {
- return _start;
-}
-
-GrowableArray<int>* IdealGraphPrinter::Block::succs() {
- return &_succs;
-}
-
-void IdealGraphPrinter::Block::add_succ(int index) {
-
- if (this->_index == 16 && index == 15) {
- int x = 0;
- }
-
- if (!_succs.contains(index)) {
- _succs.append(index);
- }
-}
-
-
-void IdealGraphPrinter::Block::add_node(NodeDescription *n) {
- if (!_nodes.contains(n)) {
- _nodes.append(n);
- }
-}
-
-GrowableArray<IdealGraphPrinter::NodeDescription *>* IdealGraphPrinter::Block::nodes() {
- return &_nodes;
-}
-
-int IdealGraphPrinter::NodeDescription::count = 0;
-
-IdealGraphPrinter::NodeDescription::NodeDescription(Node* node) : _node(node) {
- _id = (intptr_t)(node);
- _block_index = -1;
-}
-
-IdealGraphPrinter::NodeDescription::~NodeDescription() {
- _properties.clean();
-}
-
-// void IdealGraphPrinter::NodeDescription::set_node(Node* node) {
-// //this->_node = node;
-// }
-
-int IdealGraphPrinter::NodeDescription::block_index() {
- return _block_index;
-}
-
-
-GrowableArray<IdealGraphPrinter::NodeDescription *>* IdealGraphPrinter::NodeDescription::succs() {
- return &_succs;
-}
-
-void IdealGraphPrinter::NodeDescription::clear_succs() {
- _succs.clear();
-}
-
-void IdealGraphPrinter::NodeDescription::init_succs() {
- _succs = GrowableArray<NodeDescription *>();
-}
-
-void IdealGraphPrinter::NodeDescription::add_succ(NodeDescription *desc) {
- _succs.append(desc);
-}
-
-void IdealGraphPrinter::NodeDescription::set_block_index(int i) {
- _block_index = i;
-}
-
-bool IdealGraphPrinter::NodeDescription::equals(NodeDescription *desc) {
- if (desc == NULL) return false;
- if (desc->id() != id()) return false;
- return properties()->equals(desc->properties());
-}
-
-Node* IdealGraphPrinter::NodeDescription::node() {
- return _node;
-}
-
-IdealGraphPrinter::Properties* IdealGraphPrinter::NodeDescription::properties() {
- return &_properties;
-}
-
-uint IdealGraphPrinter::NodeDescription::id() {
- return _id;
-}
-
-void IdealGraphPrinter::NodeDescription::print_changed(IdealGraphPrinter *printer) {
-
-
- Properties properties;
- properties.add(new Property(NODE_ID_PROPERTY, id()));
- printer->start_element(NODE_ELEMENT, &properties);
-
- this->properties()->print(printer);
-
-
- printer->end_element(NODE_ELEMENT);
-}
-
-void IdealGraphPrinter::NodeDescription::print_removed(IdealGraphPrinter *printer) {
-
- Properties properties;
- properties.add(new Property(NODE_ID_PROPERTY, id()));
- printer->simple_element(REMOVE_NODE_ELEMENT, &properties);
-}
-
-IdealGraphPrinter::EdgeDescription::EdgeDescription(int from, int to, int index) {
- this->_from = from;
- this->_to = to;
- this->_index = index;
-}
-
-IdealGraphPrinter::EdgeDescription::~EdgeDescription() {
-}
-
-int IdealGraphPrinter::EdgeDescription::from() {
- return _from;
-}
-
-int IdealGraphPrinter::EdgeDescription::to() {
- return _to;
-}
-
-void IdealGraphPrinter::EdgeDescription::print_changed(IdealGraphPrinter *printer) {
-
- Properties properties;
- properties.add(new Property(INDEX_PROPERTY, _index));
- properties.add(new Property(FROM_PROPERTY, _from));
- properties.add(new Property(TO_PROPERTY, _to));
- printer->simple_element(EDGE_ELEMENT, &properties);
-}
-
-void IdealGraphPrinter::EdgeDescription::print_removed(IdealGraphPrinter *printer) {
-
- Properties properties;
- properties.add(new Property(INDEX_PROPERTY, _index));
- properties.add(new Property(FROM_PROPERTY, _from));
- properties.add(new Property(TO_PROPERTY, _to));
- printer->simple_element(REMOVE_EDGE_ELEMENT, &properties);
-}
-
-bool IdealGraphPrinter::EdgeDescription::equals(IdealGraphPrinter::EdgeDescription *desc) {
- if (desc == NULL) return false;
- return (_from == desc->_from && _to == desc->_to && _index == desc->_index);
-}
-
-IdealGraphPrinter::Properties::Properties() : list(new (ResourceObj::C_HEAP) GrowableArray<Property *>(2, 0, NULL, true)) {
-}
-
-IdealGraphPrinter::Properties::~Properties() {
- clean();
- delete list;
-}
-
-void IdealGraphPrinter::Properties::add(Property *p) {
- assert(p != NULL, "Property not NULL");
- list->append(p);
-}
-
-void IdealGraphPrinter::Properties::print(IdealGraphPrinter *printer) {
- printer->start_element(PROPERTIES_ELEMENT);
-
- for (int i = 0; i < list->length(); i++) {
- list->at(i)->print(printer);
- }
-
- printer->end_element(PROPERTIES_ELEMENT);
-}
-
-void IdealGraphPrinter::Properties::clean() {
- for (int i = 0; i < list->length(); i++) {
- delete list->at(i);
- list->at_put(i, NULL);
- }
- list->clear();
- assert(list->length() == 0, "List cleared");
-}
-
-void IdealGraphPrinter::Properties::remove(const char *name) {
- for (int i = 0; i < list->length(); i++) {
- if (strcmp(list->at(i)->name(), name) == 0) {
- delete list->at(i);
- list->remove_at(i);
- i--;
- }
- }
-}
-
-void IdealGraphPrinter::Properties::print_as_attributes(IdealGraphPrinter *printer) {
-
- for (int i = 0; i < list->length(); i++) {
- assert(list->at(i) != NULL, "Property not null!");
- printer->output()->print(" ");
- list->at(i)->print_as_attribute(printer);
- }
-}
-
-bool IdealGraphPrinter::Properties::equals(Properties* p) {
- if (p->list->length() != this->list->length()) return false;
-
- for (int i = 0; i < list->length(); i++) {
- assert(list->at(i) != NULL, "Property not null!");
- if (!list->at(i)->equals(p->list->at(i))) return false;
- }
-
- return true;
-}
-
-IdealGraphPrinter::Property::Property() {
- _name = NULL;
- _value = NULL;
-}
-
-const char *IdealGraphPrinter::Property::name() {
- return _name;
-}
-
-IdealGraphPrinter::Property::Property(const Property* p) {
-
- this->_name = NULL;
- this->_value = NULL;
-
- if (p->_name != NULL) {
- _name = dup(p->_name);
- }
-
- if (p->_value) {
- _value = dup(p->_value);
- }
-}
-
-IdealGraphPrinter::Property::~Property() {
-
- clean();
-}
-
-IdealGraphPrinter::Property::Property(const char *name, const char *value) {
-
- assert(name, "Name must not be null!");
- assert(value, "Value must not be null!");
-
- _name = dup(name);
- _value = dup(value);
-}
-
-IdealGraphPrinter::Property::Property(const char *name, int intValue) {
- _name = dup(name);
-
- stringStream stream;
- stream.print("%d", intValue);
- _value = dup(stream.as_string());
-}
-
-void IdealGraphPrinter::Property::clean() {
- if (_name) {
- delete _name;
- _name = NULL;
- }
-
- if (_value) {
- delete _value;
- _value = NULL;
- }
-}
-
-
-bool IdealGraphPrinter::Property::is_null() {
- return _name == NULL;
-}
-
-void IdealGraphPrinter::Property::print(IdealGraphPrinter *printer) {
-
- assert(!is_null(), "null properties cannot be printed!");
- Properties properties;
- properties.add(new Property(PROPERTY_NAME_PROPERTY, _name));
- printer->start_element(PROPERTY_ELEMENT, &properties, false, false);
- printer->print_xml(_value);
- printer->end_element(PROPERTY_ELEMENT, false, true);
-}
-
-void IdealGraphPrinter::Property::print_as_attribute(IdealGraphPrinter *printer) {
-
- printer->output()->print(_name);
- printer->output()->print("=\"");
- printer->print_xml(_value);
- printer->output()->print("\"");
-}
-
-
-bool IdealGraphPrinter::Property::equals(Property* p) {
-
- if (is_null() && p->is_null()) return true;
- if (is_null()) return false;
- if (p->is_null()) return false;
-
- int cmp1 = strcmp(p->_name, _name);
- if (cmp1 != 0) return false;
-
- int cmp2 = strcmp(p->_value, _value);
- if (cmp2 != 0) return false;
-
- return true;
-}
-
-void IdealGraphPrinter::print_xml(const char *value) {
- size_t len = strlen(value);
-
- char buf[2];
- buf[1] = 0;
- for (size_t i = 0; i < len; i++) {
- char c = value[i];
-
- switch(c) {
- case '<':
- output()->print("<");
- break;
-
- case '>':
- output()->print(">");
- break;
-
- default:
- buf[0] = c;
- output()->print(buf);
- break;
- }
- }
+ return _xml;
}
#endif
--- a/hotspot/src/share/vm/opto/idealGraphPrinter.hpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/idealGraphPrinter.hpp Tue Jun 24 16:00:14 2008 -0700
@@ -82,222 +82,42 @@
static const char *METHOD_SHORT_NAME_PROPERTY;
static const char *ASSEMBLY_ELEMENT;
- class Property {
-
- private:
-
- const char *_name;
- const char *_value;
-
- public:
-
- Property();
- Property(const Property* p);
- ~Property();
- Property(const char *name, const char *value);
- Property(const char *name, int value);
- bool equals(Property* p);
- void print(IdealGraphPrinter *printer);
- void print_as_attribute(IdealGraphPrinter *printer);
- bool is_null();
- void clean();
- const char *name();
-
- static const char* dup(const char *str) {
- char * copy = new char[strlen(str)+1];
- strcpy(copy, str);
- return copy;
- }
-
- };
-
- class Properties {
-
- private:
-
- GrowableArray<Property *> *list;
-
- public:
-
- Properties();
- ~Properties();
- void add(Property *p);
- void remove(const char *name);
- bool equals(Properties* p);
- void print(IdealGraphPrinter *printer);
- void print_as_attributes(IdealGraphPrinter *printer);
- void clean();
-
- };
-
-
- class Description {
-
- private:
-
- State _state;
-
- public:
-
- Description();
-
- State state();
- void set_state(State s);
- void print(IdealGraphPrinter *printer);
- virtual void print_changed(IdealGraphPrinter *printer) = 0;
- virtual void print_removed(IdealGraphPrinter *printer) = 0;
-
- };
-
- class NodeDescription : public Description{
-
- public:
-
- static int count;
-
- private:
-
- GrowableArray<NodeDescription *> _succs;
- int _block_index;
- uintptr_t _id;
- Properties _properties;
- Node* _node;
-
- public:
-
- NodeDescription(Node* node);
- ~NodeDescription();
- Node* node();
-
- // void set_node(Node* node);
- GrowableArray<NodeDescription *>* succs();
- void init_succs();
- void clear_succs();
- void add_succ(NodeDescription *desc);
- int block_index();
- void set_block_index(int i);
- Properties* properties();
- virtual void print_changed(IdealGraphPrinter *printer);
- virtual void print_removed(IdealGraphPrinter *printer);
- bool equals(NodeDescription *desc);
- uint id();
-
- };
-
- class Block {
-
- private:
-
- NodeDescription *_start;
- NodeDescription *_proj;
- GrowableArray<int> _succs;
- GrowableArray<NodeDescription *> _nodes;
- GrowableArray<int> _dominates;
- GrowableArray<int> _children;
- int _semi;
- int _parent;
- GrowableArray<int> _pred;
- GrowableArray<int> _bucket;
- int _index;
- int _dominator;
- int _ancestor;
- int _label;
-
- public:
-
- Block();
- Block(int index);
-
- void add_node(NodeDescription *n);
- GrowableArray<NodeDescription *>* nodes();
- GrowableArray<int>* children();
- void add_child(int i);
- void add_succ(int index);
- GrowableArray<int>* succs();
- GrowableArray<int>* dominates();
- void add_dominates(int i);
- NodeDescription *start();
- NodeDescription *proj();
- void set_start(NodeDescription *n);
- void set_proj(NodeDescription *n);
-
- int label();
- void set_label(int i);
- int ancestor();
- void set_ancestor(int i);
- int index();
- int dominator();
- void set_dominator(int i);
- int parent();
- void set_parent(int i);
- int semi();
- GrowableArray<int>* bucket();
- void add_to_bucket(int i);
- void clear_bucket();
- GrowableArray<int>* pred();
- void set_semi(int i);
- void add_pred(int i);
-
- };
-
- class EdgeDescription : public Description {
-
- private:
-
- int _from;
- int _to;
- int _index;
- public:
-
- EdgeDescription(int from, int to, int index);
- ~EdgeDescription();
-
- virtual void print_changed(IdealGraphPrinter *printer);
- virtual void print_removed(IdealGraphPrinter *printer);
- bool equals(EdgeDescription *desc);
- int from();
- int to();
- };
-
+ elapsedTimer _walk_time;
+ elapsedTimer _output_time;
+ elapsedTimer _build_blocks_time;
static int _file_count;
networkStream *_stream;
+ xmlStream *_xml;
outputStream *_output;
ciMethod *_current_method;
- GrowableArray<NodeDescription *> _nodes;
- GrowableArray<EdgeDescription *> _edges;
int _depth;
- Arena *_arena;
char buffer[128];
bool _should_send_method;
PhaseChaitin* _chaitin;
- bool _clear_nodes;
- Matcher* _matcher;
bool _traverse_outs;
-
- void start_element_helper(const char *name, Properties *properties, bool endElement, bool print_indent = false, bool print_return = true);
- NodeDescription *create_node_description(Node* node);
+ Compile *C;
static void pre_node(Node* node, void *env);
static void post_node(Node* node, void *env);
- void schedule_latest(int **common_dominator, GrowableArray<Block>* blocks);
- void build_common_dominator(int **common_dominator, int index, GrowableArray<Block>* blocks);
- void compress(int index, GrowableArray<Block>* blocks);
- int eval(int index, GrowableArray<Block>* blocks);
- void link(int index1, int index2, GrowableArray<Block>* blocks);
- void build_dominators(GrowableArray<Block>* blocks);
- void build_blocks(Node *node);
- void walk(Node *n);
- void start_element(const char *name, Properties *properties = NULL, bool print_indent = false, bool print_return = true);
- void simple_element(const char *name, Properties *properties = NULL, bool print_indent = false);
- void end_element(const char *name, bool print_indent = false, bool print_return = true);
- void print_edge(int from, int to, int index);
void print_indent();
void print_method(ciMethod *method, int bci, InlineTree *tree);
void print_inline_tree(InlineTree *tree);
- void clear_nodes();
-
+ void visit_node(Node *n, void *param);
+ void walk_nodes(Node *start, void *param);
+ void begin_elem(const char *s);
+ void end_elem();
+ void begin_head(const char *s);
+ void end_head();
+ void print_attr(const char *name, const char *val);
+ void print_attr(const char *name, intptr_t val);
+ void print_prop(const char *name, const char *val);
+ void print_prop(const char *name, int val);
+ void tail(const char *name);
+ void head(const char *name);
+ void text(const char *s);
+ intptr_t get_node_id(Node *n);
IdealGraphPrinter();
~IdealGraphPrinter();
@@ -308,7 +128,6 @@
bool traverse_outs();
void set_traverse_outs(bool b);
- void print_ifg(PhaseIFG* ifg);
outputStream *output();
void print_inlining(Compile* compile);
void begin_method(Compile* compile);
--- a/hotspot/src/share/vm/opto/loopnode.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/loopnode.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -1072,8 +1072,6 @@
phase->_igvn.add_users_to_worklist(l->fast_out(i));
}
- phase->C->print_method("After beautify loops", 3);
-
// Now recursively beautify nested loops
if( _child ) result |= _child->beautify_loops( phase );
if( _next ) result |= _next ->beautify_loops( phase );
@@ -1470,6 +1468,8 @@
}
// Reset loop nesting depth
_ltree_root->set_nest( 0 );
+
+ C->print_method("After beautify loops", 3);
}
}
--- a/hotspot/src/share/vm/opto/matcher.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/matcher.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -51,6 +51,7 @@
PhaseTransform( Phase::Ins_Select ),
#ifdef ASSERT
_old2new_map(C->comp_arena()),
+ _new2old_map(C->comp_arena()),
#endif
_shared_nodes(C->comp_arena()),
_reduceOp(reduceOp), _leftOp(leftOp), _rightOp(rightOp),
@@ -835,10 +836,16 @@
if( n->is_Proj() && n->in(0)->is_Multi()) { // Projections?
// Convert to machine-dependent projection
m = n->in(0)->as_Multi()->match( n->as_Proj(), this );
+#ifdef ASSERT
+ _new2old_map.map(m->_idx, n);
+#endif
if (m->in(0) != NULL) // m might be top
collect_null_checks(m);
} else { // Else just a regular 'ol guy
m = n->clone(); // So just clone into new-space
+#ifdef ASSERT
+ _new2old_map.map(m->_idx, n);
+#endif
// Def-Use edges will be added incrementally as Uses
// of this node are matched.
assert(m->outcnt() == 0, "no Uses of this clone yet");
@@ -887,6 +894,9 @@
// || op == Op_BoxLock // %%%% enable this and remove (+++) in chaitin.cpp
) {
m = m->clone();
+#ifdef ASSERT
+ _new2old_map.map(m->_idx, n);
+#endif
mstack.push(m, Post_Visit, n, i); // Don't neet to visit
mstack.push(m->in(0), Visit, m, 0);
} else {
@@ -1190,6 +1200,7 @@
MachNode *m = ReduceInst( s, s->_rule[mincost], mem );
#ifdef ASSERT
_old2new_map.map(n->_idx, m);
+ _new2old_map.map(m->_idx, (Node*)n);
#endif
// Add any Matcher-ignored edges
@@ -1491,6 +1502,9 @@
for( uint i=0; i<mach->req(); i++ ) {
mach->set_req(i,NULL);
}
+#ifdef ASSERT
+ _new2old_map.map(ex->_idx, s->_leaf);
+#endif
}
// PhaseChaitin::fixup_spills will sometimes generate spill code
--- a/hotspot/src/share/vm/opto/matcher.hpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/matcher.hpp Tue Jun 24 16:00:14 2008 -0700
@@ -84,6 +84,7 @@
Node_Array _shared_nodes;
debug_only(Node_Array _old2new_map;) // Map roots of ideal-trees to machine-roots
+ debug_only(Node_Array _new2old_map;) // Maps machine nodes back to ideal
// Accessors for the inherited field PhaseTransform::_nodes:
void grow_new_node_array(uint idx_limit) {
@@ -390,5 +391,9 @@
#ifdef ASSERT
void dump_old2new_map(); // machine-independent to machine-dependent
+
+ Node* find_old_node(Node* new_node) {
+ return _new2old_map[new_node->_idx];
+ }
#endif
};
--- a/hotspot/src/share/vm/opto/node.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/node.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -1387,7 +1387,7 @@
}
#ifdef ASSERT
// Search along debug_orig edges last:
- for (Node* orig = n->debug_orig(); orig != NULL; orig = orig->debug_orig()) {
+ for (Node* orig = n->debug_orig(); orig != NULL && n != orig; orig = orig->debug_orig()) {
if (NotANode(orig)) break;
find_recur( result, orig, idx, only_ctrl, old_space, new_space );
}
--- a/hotspot/src/share/vm/opto/output.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/output.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -447,6 +447,7 @@
// We've got a winner. Replace this branch.
MachNode *replacement = mach->short_branch_version(this);
b->_nodes.map(j, replacement);
+ mach->subsume_by(replacement);
// Update the jmp_end size to save time in our
// next pass.
--- a/hotspot/src/share/vm/opto/parse2.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/opto/parse2.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -2220,7 +2220,7 @@
sprintf(buffer, "Bytecode %d: %s", bci(), Bytecodes::name(bc()));
bool old = printer->traverse_outs();
printer->set_traverse_outs(true);
- printer->print_method(C, buffer, 3);
+ printer->print_method(C, buffer, 4);
printer->set_traverse_outs(old);
}
#endif
--- a/hotspot/src/share/vm/runtime/hpi.hpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/runtime/hpi.hpp Tue Jun 24 16:00:14 2008 -0700
@@ -66,6 +66,8 @@
static inline int socket_shutdown(int fd, int howto);
static inline int recv(int fd, char *buf, int nBytes, int flags);
static inline int send(int fd, char *buf, int nBytes, int flags);
+ // Variant of send that doesn't support interruptible I/O
+ static inline int raw_send(int fd, char *buf, int nBytes, int flags);
static inline int timeout(int fd, long timeout);
static inline int listen(int fd, int count);
static inline int connect(int fd, struct sockaddr *him, int len);
--- a/hotspot/src/share/vm/utilities/ostream.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/utilities/ostream.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -753,21 +753,28 @@
write(str, len);
}
-bufferedStream::bufferedStream(size_t initial_size) : outputStream() {
+bufferedStream::bufferedStream(size_t initial_size, size_t bufmax) : outputStream() {
buffer_length = initial_size;
buffer = NEW_C_HEAP_ARRAY(char, buffer_length);
buffer_pos = 0;
buffer_fixed = false;
+ buffer_max = bufmax;
}
-bufferedStream::bufferedStream(char* fixed_buffer, size_t fixed_buffer_size) : outputStream() {
+bufferedStream::bufferedStream(char* fixed_buffer, size_t fixed_buffer_size, size_t bufmax) : outputStream() {
buffer_length = fixed_buffer_size;
buffer = fixed_buffer;
buffer_pos = 0;
buffer_fixed = true;
+ buffer_max = bufmax;
}
void bufferedStream::write(const char* s, size_t len) {
+
+ if(buffer_pos + len > buffer_max) {
+ flush();
+ }
+
size_t end = buffer_pos + len;
if (end >= buffer_length) {
if (buffer_fixed) {
@@ -811,7 +818,7 @@
#endif
// Network access
-networkStream::networkStream() {
+networkStream::networkStream() : bufferedStream(1024*10, 1024*10) {
_socket = -1;
@@ -831,7 +838,9 @@
void networkStream::flush() {
if (size() != 0) {
- hpi::send(_socket, (char *)base(), (int)size(), 0);
+ int result = hpi::raw_send(_socket, (char *)base(), (int)size(), 0);
+ assert(result != -1, "connection error");
+ assert(result == (int)size(), "didn't send enough data");
}
reset();
}
--- a/hotspot/src/share/vm/utilities/ostream.hpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/utilities/ostream.hpp Tue Jun 24 16:00:14 2008 -0700
@@ -206,11 +206,12 @@
protected:
char* buffer;
size_t buffer_pos;
+ size_t buffer_max;
size_t buffer_length;
bool buffer_fixed;
public:
- bufferedStream(size_t initial_bufsize = 256);
- bufferedStream(char* fixed_buffer, size_t fixed_buffer_size);
+ bufferedStream(size_t initial_bufsize = 256, size_t bufmax = 1024*1024*10);
+ bufferedStream(char* fixed_buffer, size_t fixed_buffer_size, size_t bufmax = 1024*1024*10);
~bufferedStream();
virtual void write(const char* c, size_t len);
size_t size() { return buffer_pos; }
--- a/hotspot/src/share/vm/utilities/xmlstream.cpp Tue Jun 24 10:43:29 2008 -0700
+++ b/hotspot/src/share/vm/utilities/xmlstream.cpp Tue Jun 24 16:00:14 2008 -0700
@@ -59,6 +59,7 @@
if (!is_open()) return;
out()->write(s, len);
+ update_position(s, len);
}