diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.gif b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.gif
new file mode 100644
index 0000000000000000000000000000000000000000..9eeab3cad6d41d9398254672379395a82f6ddf13
Binary files /dev/null and b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.gif differ
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.gif b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.gif
new file mode 100644
index 0000000000000000000000000000000000000000..954f1accde64db9e98e9a6e528b459f3027b018c
Binary files /dev/null and b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.gif differ
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif
new file mode 100644
index 0000000000000000000000000000000000000000..2d31c8b2ccd48d32acf35dccf6c5689a38a04a36
Binary files /dev/null and b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif differ
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.gif b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.gif
new file mode 100644
index 0000000000000000000000000000000000000000..2be848748743d34bba27e3a697ebac3ff8ec552c
Binary files /dev/null and b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.gif differ
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structured.gif b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structured.gif
new file mode 100644
index 0000000000000000000000000000000000000000..71aa946d53918697f7043a6c255611b50d5d11cd
Binary files /dev/null and b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structured.gif differ
diff --git a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml
new file mode 100644
index 0000000000000000000000000000000000000000..999997db9f617eb884f61d0c1716edb8a2ceab3b
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Data/build.xml b/src/share/tools/IdealGraphVisualizer/Data/build.xml
new file mode 100644
index 0000000000000000000000000000000000000000..dd626066c85e933b7ed6eaa8ec8d25a919dcada8
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/build.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+ Builds, tests, and runs the project com.sun.hotspot.igv.data.
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Data/manifest.mf b/src/share/tools/IdealGraphVisualizer/Data/manifest.mf
new file mode 100644
index 0000000000000000000000000000000000000000..702ae8764a2289521993d10db34b34c9d522ca33
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/manifest.mf
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.sun.hotspot.igv.data
+OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/data/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
diff --git a/src/share/tools/IdealGraphVisualizer/Data/nbproject/build-impl.xml b/src/share/tools/IdealGraphVisualizer/Data/nbproject/build-impl.xml
new file mode 100644
index 0000000000000000000000000000000000000000..942d7a628fcfa5959b63b84046095c1b558fbacc
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/build-impl.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+ You must set 'suite.dir' to point to your containing module suite
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Data/nbproject/genfiles.properties b/src/share/tools/IdealGraphVisualizer/Data/nbproject/genfiles.properties
new file mode 100644
index 0000000000000000000000000000000000000000..621e413c962281f120f1ad9192ede58e1221b104
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=a403efd8
+build.xml.script.CRC32=b87f73ba
+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=a403efd8
+nbproject/build-impl.xml.script.CRC32=cc649146
+nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
diff --git a/src/share/tools/IdealGraphVisualizer/Data/nbproject/platform.properties b/src/share/tools/IdealGraphVisualizer/Data/nbproject/platform.properties
new file mode 100644
index 0000000000000000000000000000000000000000..68ad75e5766f33be5a65a19d28cc7605c5b50a1c
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/platform.properties
@@ -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
diff --git a/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties b/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties
new file mode 100644
index 0000000000000000000000000000000000000000..152f44eca60ab831869539ffae9192aa03915f3b
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
diff --git a/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml b/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..dce4d28a7c307a91e17bd4284fb82d5c27889007
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml
@@ -0,0 +1,16 @@
+
+
+ org.netbeans.modules.apisupport.project
+
+
+ com.sun.hotspot.igv.data
+
+
+
+ com.sun.hotspot.igv.data
+ com.sun.hotspot.igv.data.serialization
+ com.sun.hotspot.igv.data.services
+
+
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Data/nbproject/suite.properties b/src/share/tools/IdealGraphVisualizer/Data/nbproject/suite.properties
new file mode 100644
index 0000000000000000000000000000000000000000..29d7cc9bd6fdd81453543cdf1bcf1dab301e3a92
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/suite.properties
@@ -0,0 +1 @@
+suite.dir=${basedir}/..
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Bundle.properties b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Bundle.properties
new file mode 100644
index 0000000000000000000000000000000000000000..f17788c7ff4ef389166ae04a7b0994a36d8992a4
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Bundle.properties
@@ -0,0 +1 @@
+OpenIDE-Module-Name=Data
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..18a8cedbabfbafe7e972eb7f31536baadf41a477
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java
@@ -0,0 +1,44 @@
+/*
+ * 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.data;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class ChangedEvent extends Event> {
+
+ private T object;
+
+ public ChangedEvent() {
+ }
+
+ public ChangedEvent(T object) {
+ this.object = object;
+ }
+
+ protected void fire(ChangedListener l) {
+ l.changed(object);
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..5e2978e82604d6911b6d42680027e7ef57be26ba
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java
@@ -0,0 +1,34 @@
+/*
+ * 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.data;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface ChangedEventProvider {
+
+ public ChangedEvent getChangedEvent();
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java
new file mode 100644
index 0000000000000000000000000000000000000000..806b339be1731ec7dd0fb8b50600cb4abfd0d3f9
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java
@@ -0,0 +1,33 @@
+/*
+ * 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.data;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface ChangedListener {
+
+ public void changed(T source);
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java
new file mode 100644
index 0000000000000000000000000000000000000000..c31e5935a1297acaeb95bbabf2d814797ab9dd17
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java
@@ -0,0 +1,57 @@
+/*
+ * 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.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public abstract class Event {
+
+ private List listener;
+
+ public Event() {
+ listener = new ArrayList();
+ }
+
+ public void addListener(L l) {
+ listener.add(l);
+ }
+
+ public void removeListener(L l) {
+ listener.remove(l);
+ }
+
+ public void fire() {
+ List tmpList = new ArrayList(listener);
+ for (L l : tmpList) {
+ fire(l);
+ }
+ }
+
+ protected abstract void fire(L l);
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java
new file mode 100644
index 0000000000000000000000000000000000000000..27d09c38f712b644897b8fde3dbad0cce3224e29
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java
@@ -0,0 +1,91 @@
+/*
+ * 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.data;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class GraphDocument extends Properties.Object implements ChangedEventProvider {
+
+ private List groups;
+ private ChangedEvent changedEvent;
+
+ public GraphDocument() {
+ groups = new ArrayList();
+ changedEvent = new ChangedEvent(this);
+ }
+
+ public void clear() {
+ groups.clear();
+ getChangedEvent().fire();
+ }
+
+ public ChangedEvent getChangedEvent() {
+ return changedEvent;
+ }
+
+ public List getGroups() {
+ return Collections.unmodifiableList(groups);
+ }
+
+ public void addGroup(Group group) {
+ group.setDocument(this);
+ groups.add(group);
+ getChangedEvent().fire();
+ }
+
+ public void removeGroup(Group group) {
+ if (groups.contains(group)) {
+ group.setDocument(null);
+ groups.remove(group);
+ getChangedEvent().fire();
+ }
+ }
+
+ public void addGraphDocument(GraphDocument document) {
+ for (Group g : document.groups) {
+ this.addGroup(g);
+ }
+ document.clear();
+ getChangedEvent().fire();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("GraphDocument: " + getProperties().toString() + " \n\n");
+ for (Group g : getGroups()) {
+ sb.append(g.toString());
+ sb.append("\n\n");
+ }
+
+ return sb.toString();
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java
new file mode 100644
index 0000000000000000000000000000000000000000..8f0aa15e9928f58b1a608d9fecc9c7455c6ef776
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java
@@ -0,0 +1,141 @@
+/*
+ * 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.data;
+
+import com.sun.hotspot.igv.data.ChangedEvent;
+import com.sun.hotspot.igv.data.ChangedEventProvider;
+import com.sun.hotspot.igv.data.Properties;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class Group extends Properties.Object implements ChangedEventProvider {
+
+ private List graphs;
+ private transient ChangedEvent changedEvent;
+ private GraphDocument document;
+ private InputMethod method;
+ private String assembly;
+
+ public Group() {
+ graphs = new ArrayList();
+ init();
+ }
+
+ private void init() {
+ changedEvent = new ChangedEvent(this);
+ }
+
+ public void fireChangedEvent() {
+ changedEvent.fire();
+ }
+
+ public void setAssembly(String s) {
+ this.assembly = s;
+ }
+
+ public String getAssembly() {
+ return assembly;
+ }
+
+ public void setMethod(InputMethod method) {
+ this.method = method;
+ }
+
+ public InputMethod getMethod() {
+ return method;
+ }
+
+ void setDocument(GraphDocument document) {
+ this.document = document;
+ }
+
+ public GraphDocument getDocument() {
+ return document;
+ }
+
+ public ChangedEvent getChangedEvent() {
+ return changedEvent;
+ }
+
+ public List getGraphs() {
+ return Collections.unmodifiableList(graphs);
+ }
+
+ public void addGraph(InputGraph g) {
+ assert g != null;
+ assert !graphs.contains(g);
+ graphs.add(g);
+ changedEvent.fire();
+ }
+
+ public void removeGraph(InputGraph g) {
+ int index = graphs.indexOf(g);
+ if (index != -1) {
+ graphs.remove(g);
+ changedEvent.fire();
+ }
+ }
+
+ public Set getAllNodes() {
+ Set result = new HashSet();
+ for (InputGraph g : graphs) {
+ Set ids = g.getNodesAsSet();
+ result.addAll(g.getNodesAsSet());
+ for (Integer i : ids) {
+ result.add(-i);
+ }
+ }
+ return result;
+ }
+
+ public InputGraph getLastAdded() {
+ if (graphs.size() == 0) {
+ return null;
+ }
+ return graphs.get(graphs.size() - 1);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Group " + getProperties().toString() + "\n");
+ for (InputGraph g : graphs) {
+ sb.append(g.toString());
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+ public String getName() {
+ return getProperties().get("name");
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java
new file mode 100644
index 0000000000000000000000000000000000000000..1c1367738afcfa64caf3f57d9033a321bb4a13a9
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java
@@ -0,0 +1,140 @@
+/*
+ * 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.data;
+
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class InputBlock {
+
+ private List nodes;
+ private List successorNames;
+ private String name;
+ private InputGraph graph;
+ private Rectangle bounds;
+ private Set successors;
+ private Set predecessors;
+ private Set inputs;
+ private Set outputs;
+
+ public InputBlock(InputGraph graph, String name) {
+ this.graph = graph;
+ this.name = name;
+ nodes = new ArrayList();
+ successorNames = new ArrayList();
+ successors = new HashSet();
+ predecessors = new HashSet();
+ inputs = new HashSet();
+ outputs = new HashSet();
+ }
+
+ public void removeSuccessor(InputBlock b) {
+ if (successors.contains(b)) {
+ successors.remove(b);
+ b.predecessors.remove(this);
+ InputBlockEdge e = new InputBlockEdge(this, b);
+ assert outputs.contains(e);
+ outputs.remove(e);
+ assert b.inputs.contains(e);
+ b.inputs.remove(e);
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String s) {
+ name = s;
+ }
+
+ public List getNodes() {
+ return Collections.unmodifiableList(nodes);
+ }
+
+ public void addNode(int id) {
+ InputNode n = graph.getNode(id);
+ assert n != null;
+ graph.setBlock(n, this);
+ addNode(graph.getNode(id));
+ }
+
+ public void addNode(InputNode node) {
+ assert !nodes.contains(node);
+ nodes.add(node);
+ }
+
+ public Set getPredecessors() {
+ return Collections.unmodifiableSet(predecessors);
+ }
+
+ public Set getSuccessors() {
+ return Collections.unmodifiableSet(successors);
+ }
+
+ public Set getInputs() {
+ return Collections.unmodifiableSet(inputs);
+ }
+
+ public Set getOutputs() {
+ return Collections.unmodifiableSet(outputs);
+ }
+
+ // resolveBlockLinks must be called afterwards
+ public void addSuccessor(String name) {
+ successorNames.add(name);
+ }
+
+ public void resolveBlockLinks() {
+ for (String s : successorNames) {
+ InputBlock b = graph.getBlock(s);
+ addSuccessor(b);
+ }
+
+ successorNames.clear();
+ }
+
+ public void addSuccessor(InputBlock b) {
+ if (!successors.contains(b)) {
+ successors.add(b);
+ b.predecessors.add(this);
+ InputBlockEdge e = new InputBlockEdge(this, b);
+ outputs.add(e);
+ b.inputs.add(e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.getName();
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java
new file mode 100644
index 0000000000000000000000000000000000000000..10cac158a4a1e1315a102650339f561bfb03a1ce
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java
@@ -0,0 +1,65 @@
+/*
+ * 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.data;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class InputBlockEdge {
+
+ private InputBlock from;
+ private InputBlock to;
+
+ public InputBlockEdge(InputBlock from, InputBlock to) {
+ assert from != null;
+ assert to != null;
+ this.from = from;
+ this.to = to;
+ }
+
+ public InputBlock getFrom() {
+ return from;
+ }
+
+ public InputBlock getTo() {
+ return to;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof InputBlockEdge && obj != null) {
+ InputBlockEdge e = (InputBlockEdge) obj;
+ return e.from.equals(from) && e.to.equals(to);
+ }
+ return super.equals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = from.hashCode();
+ hash = 59 * hash + to.hashCode();
+ return hash;
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java
new file mode 100644
index 0000000000000000000000000000000000000000..14ab1f340599acc212fafad76a8fc1b99534db9b
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java
@@ -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.data;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class InputBytecode {
+
+ private int bci;
+ private String name;
+ private InputMethod inlined;
+
+ public InputBytecode(int bci, String name) {
+ this.bci = bci;
+ this.name = name;
+ }
+
+ public InputMethod getInlined() {
+ return inlined;
+ }
+
+ public void setInlined(InputMethod inlined) {
+ this.inlined = inlined;
+ }
+
+ public int getBci() {
+ return bci;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java
new file mode 100644
index 0000000000000000000000000000000000000000..d1c440ec09a3da8803982847119a85da26b80c17
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java
@@ -0,0 +1,92 @@
+/*
+ * 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.data;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class InputEdge {
+
+ public enum State {
+
+ SAME,
+ NEW,
+ DELETED
+ }
+ private char toIndex;
+ private int from;
+ private int to;
+ private State state;
+
+ public InputEdge(char toIndex, int from, int to) {
+ this.toIndex = toIndex;
+ this.from = from;
+ this.to = to;
+ this.state = State.SAME;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public void setState(State x) {
+ this.state = x;
+ }
+
+ public char getToIndex() {
+ return toIndex;
+ }
+
+ public String getName() {
+ return "in" + toIndex;
+ }
+
+ public int getFrom() {
+ return from;
+ }
+
+ public int getTo() {
+ return to;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || !(o instanceof InputEdge)) {
+ return false;
+ }
+ InputEdge conn2 = (InputEdge) o;
+ return conn2.toIndex == toIndex && conn2.from == from && conn2.to == to;
+ }
+
+ @Override
+ public String toString() {
+ return "Edge from " + from + " to " + to + "(" + (int) toIndex + ") ";
+ }
+
+ @Override
+ public int hashCode() {
+ return (from << 20 | to << 8 | toIndex);
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java
new file mode 100644
index 0000000000000000000000000000000000000000..b929fd627c6ab793cd09162aa5e52d4bd18341ec
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java
@@ -0,0 +1,249 @@
+/*
+ * 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.data;
+
+import com.sun.hotspot.igv.data.Properties;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class InputGraph extends Properties.Object {
+
+ private Map nodes;
+ private Set edges;
+ private Group parent;
+ private Map blocks;
+ private Map nodeToBlock;
+ private boolean isDifferenceGraph;
+
+ public InputGraph(Group parent) {
+ this(parent, null);
+ }
+
+ public InputGraph(Group parent, InputGraph last) {
+ this(parent, last, "");
+ }
+
+ private void clearBlocks() {
+ blocks.clear();
+ nodeToBlock.clear();
+ }
+
+ public InputGraph(Group parent, InputGraph last, String name) {
+ this.parent = parent;
+ setName(name);
+ nodes = new Hashtable();
+ edges = new HashSet();
+ blocks = new Hashtable();
+ nodeToBlock = new Hashtable();
+ if (last != null) {
+
+ for (InputNode n : last.getNodes()) {
+ addNode(n);
+ }
+
+ for (InputEdge c : last.getEdges()) {
+ addEdge(c);
+ }
+ }
+ }
+
+ public void schedule(Collection newBlocks) {
+ clearBlocks();
+ InputBlock noBlock = new InputBlock(this, "no block");
+ Set scheduledNodes = new HashSet();
+
+ for (InputBlock b : newBlocks) {
+ for (InputNode n : b.getNodes()) {
+ assert !scheduledNodes.contains(n);
+ scheduledNodes.add(n);
+ }
+ }
+
+ for (InputNode n : this.getNodes()) {
+ assert nodes.get(n.getId()) == n;
+ if (!scheduledNodes.contains(n)) {
+ noBlock.addNode(n.getId());
+ }
+ }
+
+ if (noBlock.getNodes().size() != 0) {
+ newBlocks.add(noBlock);
+ }
+ for (InputBlock b : newBlocks) {
+ addBlock(b);
+ }
+
+ for (InputNode n : this.getNodes()) {
+ assert this.getBlock(n) != null;
+ }
+ }
+
+ public void setBlock(InputNode node, InputBlock block) {
+ nodeToBlock.put(node.getId(), block);
+ }
+
+ public InputBlock getBlock(int nodeId) {
+ return nodeToBlock.get(nodeId);
+ }
+
+ public InputBlock getBlock(InputNode node) {
+ return getBlock(node.getId());
+ }
+
+ public InputGraph getNext() {
+ List list = parent.getGraphs();
+ if (!list.contains(this)) {
+ return null;
+ }
+ int index = list.indexOf(this);
+ if (index == list.size() - 1) {
+ return null;
+ } else {
+ return list.get(index + 1);
+ }
+ }
+
+ public InputGraph getPrev() {
+ List list = parent.getGraphs();
+ if (!list.contains(this)) {
+ return null;
+ }
+ int index = list.indexOf(this);
+ if (index == 0) {
+ return null;
+ } else {
+ return list.get(index - 1);
+ }
+ }
+
+ public String getName() {
+ return getProperties().get("name");
+ }
+
+ public String getAbsoluteName() {
+ String result = getName();
+ if (this.parent != null) {
+ result = parent.getName() + ": " + result;
+ }
+ return result;
+ }
+
+ public Collection getNodes() {
+ return Collections.unmodifiableCollection(nodes.values());
+ }
+
+ public Set getNodesAsSet() {
+ return Collections.unmodifiableSet(nodes.keySet());
+ }
+
+ public Collection getBlocks() {
+ return Collections.unmodifiableCollection(blocks.values());
+ }
+
+ public void addNode(InputNode node) {
+ nodes.put(node.getId(), node);
+ }
+
+ public InputNode getNode(int id) {
+ return nodes.get(id);
+ }
+
+ public InputNode removeNode(int index) {
+ return nodes.remove(index);
+ }
+
+ public Set getEdges() {
+ return Collections.unmodifiableSet(edges);
+ }
+
+ public void removeEdge(InputEdge c) {
+ assert edges.contains(c);
+ edges.remove(c);
+ assert !edges.contains(c);
+ }
+
+ public void addEdge(InputEdge c) {
+ assert !edges.contains(c);
+ edges.add(c);
+ assert edges.contains(c);
+ }
+
+ public Group getGroup() {
+ return parent;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Graph " + getName() + " " + getProperties().toString() + "\n");
+ for (InputNode n : nodes.values()) {
+ sb.append(n.toString());
+ sb.append("\n");
+ }
+
+ for (InputEdge c : edges) {
+ sb.append(c.toString());
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+ public void addBlock(InputBlock b) {
+ blocks.put(b.getName(), b);
+ for (InputNode n : b.getNodes()) {
+ this.nodeToBlock.put(n.getId(), b);
+ }
+ }
+
+ public void resolveBlockLinks() {
+ for (InputBlock b : blocks.values()) {
+ b.resolveBlockLinks();
+ }
+ }
+
+ public void setName(String s) {
+ getProperties().setProperty("name", s);
+ }
+
+ public InputBlock getBlock(String s) {
+ return blocks.get(s);
+ }
+
+ public boolean isDifferenceGraph() {
+ return this.isDifferenceGraph;
+ }
+
+ public void setIsDifferenceGraph(boolean b) {
+ isDifferenceGraph = b;
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java
new file mode 100644
index 0000000000000000000000000000000000000000..eac6b1a03085e1637e9681db100b582be458be3d
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java
@@ -0,0 +1,127 @@
+/*
+ * 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.data;
+
+import com.sun.hotspot.igv.data.Properties;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class InputMethod extends Properties.Object {
+
+ private String name;
+ private int bci;
+ private String shortName;
+ private List inlined;
+ private InputMethod parentMethod;
+ private Group group;
+ private List bytecodes;
+
+ /** Creates a new instance of InputMethod */
+ public InputMethod(Group parent, String name, String shortName, int bci) {
+ this.group = parent;
+ this.name = name;
+ this.bci = bci;
+ this.shortName = shortName;
+ inlined = new ArrayList();
+ bytecodes = new ArrayList();
+ }
+
+ public List getBytecodes() {
+ return Collections.unmodifiableList(bytecodes);
+ }
+
+ public List getInlined() {
+ return Collections.unmodifiableList(inlined);
+ }
+
+ public void addInlined(InputMethod m) {
+
+ // assert bci unique
+ for (InputMethod m2 : inlined) {
+ assert m2.getBci() != m.getBci();
+ }
+
+ inlined.add(m);
+ assert m.parentMethod == null;
+ m.parentMethod = this;
+
+ for (InputBytecode bc : bytecodes) {
+ if (bc.getBci() == m.getBci()) {
+ bc.setInlined(m);
+ }
+ }
+ }
+
+ public Group getGroup() {
+ return group;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+ public void setBytecodes(String text) {
+
+ String[] strings = text.split("\n");
+ int oldNumber = -1;
+ for (String s : strings) {
+
+ if (s.length() > 0 && Character.isDigit(s.charAt(0))) {
+ s = s.trim();
+ int spaceIndex = s.indexOf(' ');
+ String numberString = s.substring(0, spaceIndex);
+ String tmpName = s.substring(spaceIndex + 1, s.length());
+
+ int number = -1;
+ number = Integer.parseInt(numberString);
+
+ // assert correct order of bytecodes
+ assert number > oldNumber;
+
+ InputBytecode bc = new InputBytecode(number, tmpName);
+ bytecodes.add(bc);
+
+ for (InputMethod m : inlined) {
+ if (m.getBci() == number) {
+ bc.setInlined(m);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getBci() {
+ return bci;
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..ad15d141ac9c61f98adfebb080e3ef4d9ed28cf7
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java
@@ -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.data;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class InputNode extends Properties.Object {
+
+ private int id;
+
+ public InputNode(InputNode n) {
+ super(n);
+ setId(n.id);
+ }
+
+ public InputNode(int id) {
+ setId(id);
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ getProperties().setProperty("id", "" + id);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof InputNode)) {
+ return false;
+ }
+ InputNode n = (InputNode) o;
+ if (n.id != id) {
+ return false;
+ }
+ return getProperties().equals(n.getProperties());
+ }
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return "Node " + id + " " + getProperties().toString();
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java
new file mode 100644
index 0000000000000000000000000000000000000000..3becd18cbc5819bb585aebae847b00f16fa18bb7
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java
@@ -0,0 +1,72 @@
+/*
+ * 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.data;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class Pair {
+
+ private L l;
+ private R r;
+
+ public Pair() {
+ }
+
+ public Pair(L l, R r) {
+ this.l = l;
+ this.r = r;
+ }
+
+ public L getLeft() {
+ return l;
+ }
+
+ public void setLeft(L l) {
+ this.l = l;
+ }
+
+ public R getRight() {
+ return r;
+ }
+
+ public void setRight(R r) {
+ this.r = r;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof Pair)) {
+ return false;
+ }
+ Pair obj = (Pair) o;
+ return l.equals(obj.l) && r.equals(obj.r);
+ }
+
+ @Override
+ public int hashCode() {
+ return l.hashCode() * 71 + r.hashCode();
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java
new file mode 100644
index 0000000000000000000000000000000000000000..07a29962f9ff8643e853507490cf0e7eb1c7638e
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java
@@ -0,0 +1,288 @@
+/*
+ * 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.data;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class Properties implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+ private Map map;
+
+ public Properties() {
+ map = new HashMap(5);
+ }
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (!(o instanceof Properties)) {
+ return false;
+ }
+
+ Properties p = (Properties) o;
+
+ if (getProperties().size() != p.getProperties().size()) {
+ return false;
+ }
+ for (Property prop : getProperties()) {
+ String value = p.get(prop.getName());
+ if (value == null || !value.equals(prop.getValue())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 83 * hash + (this.map != null ? this.map.hashCode() : 0);
+ return hash;
+ }
+
+ public Properties(String name, String value) {
+ this();
+ this.add(new Property(name, value));
+ }
+
+ public Properties(String name, String value, String name1, String value1) {
+ this(name, value);
+ this.add(new Property(name1, value1));
+ }
+
+ public Properties(String name, String value, String name1, String value1, String name2, String value2) {
+ this(name, value, name1, value1);
+ this.add(new Property(name2, value2));
+ }
+
+ public Properties(Properties p) {
+ map = new HashMap(p.map);
+ }
+
+ public static class Object implements Provider {
+
+ private Properties properties;
+
+ public Object() {
+ properties = new Properties();
+ }
+
+ public Object(Properties.Object object) {
+ properties = new Properties(object.getProperties());
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+ }
+
+ public interface PropertyMatcher {
+
+ String getName();
+
+ boolean match(String value);
+ }
+
+ public static class InvertPropertyMatcher implements PropertyMatcher {
+
+ private PropertyMatcher matcher;
+
+ public InvertPropertyMatcher(PropertyMatcher matcher) {
+ this.matcher = matcher;
+ }
+
+ public String getName() {
+ return matcher.getName();
+ }
+
+ public boolean match(String p) {
+ return !matcher.match(p);
+ }
+ }
+
+ public static class StringPropertyMatcher implements PropertyMatcher {
+
+ private String name;
+ private String value;
+
+ public StringPropertyMatcher(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean match(String p) {
+ return p.equals(value);
+ }
+ }
+
+ public static class RegexpPropertyMatcher implements PropertyMatcher {
+
+ private String name;
+ private Pattern valuePattern;
+
+ public RegexpPropertyMatcher(String name, String value) {
+ this.name = name;
+ valuePattern = Pattern.compile(value);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean match(String p) {
+ Matcher m = valuePattern.matcher(p);
+ return m.matches();
+ }
+ }
+
+ public Property selectSingle(PropertyMatcher matcher) {
+
+ Property p = this.map.get(matcher.getName());
+ if (p == null) {
+ return null;
+ }
+ if (matcher.match(p.getValue())) {
+ return p;
+ } else {
+ return null;
+ }
+ }
+
+ public interface Provider {
+
+ public Properties getProperties();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("[");
+ for (Property p : map.values()) {
+ sb.append(p.toString());
+ }
+ return sb.append("]").toString();
+ }
+
+ public static class PropertySelector {
+
+ private Collection objects;
+
+ public PropertySelector(Collection objects) {
+ this.objects = objects;
+ }
+
+ public T selectSingle(final String name, final String value) {
+ return selectSingle(new StringPropertyMatcher(name, value));
+ }
+
+ public T selectSingle(PropertyMatcher matcher) {
+
+ for (T t : objects) {
+ Property p = t.getProperties().selectSingle(matcher);
+ if (p != null) {
+ return t;
+ }
+ }
+
+ return null;
+ }
+
+ public List selectMultiple(final String name, final String value) {
+ return selectMultiple(new StringPropertyMatcher(name, value));
+ }
+
+ public List selectMultiple(PropertyMatcher matcher) {
+ List result = new ArrayList();
+ for (T t : objects) {
+ Property p = t.getProperties().selectSingle(matcher);
+ if (p != null) {
+ result.add(t);
+ }
+ }
+ return result;
+ }
+ }
+
+ public String get(String key) {
+ Property p = map.get(key);
+ if (p == null) {
+ return null;
+ } else {
+ return p.getValue();
+ }
+ }
+
+ public String getProperty(String string) {
+ return get(string);
+ }
+
+ public Property setProperty(String name, String value) {
+
+ if (value == null) {
+ // remove this property
+ return map.remove(name);
+ } else {
+ Property p = map.get(name);
+ if (p == null) {
+ p = new Property(name, value);
+ map.put(name, p);
+ } else {
+ p.setValue(value);
+ }
+ return p;
+ }
+ }
+
+ public Collection getProperties() {
+ return Collections.unmodifiableCollection(map.values());
+ }
+
+ public void add(Properties properties) {
+ for (Property p : properties.getProperties()) {
+ add(p);
+ }
+ }
+
+ public void add(Property property) {
+ assert property.getName() != null;
+ assert property.getValue() != null;
+ map.put(property.getName(), property);
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java
new file mode 100644
index 0000000000000000000000000000000000000000..6694153d3b7f237fef27c14ff288d8a217af88bc
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java
@@ -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.data;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class Property implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+ private String name;
+ private String value;
+
+ public Property() {
+ this(null, null);
+ }
+
+ public Property(Property p) {
+ this(p.getName(), p.getValue());
+ }
+
+ public Property(String name) {
+ this(name, null);
+ }
+
+ public Property(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setName(String s) {
+ this.name = s;
+ }
+
+ public void setValue(String s) {
+ this.value = s;
+ }
+
+ @Override
+ public String toString() {
+ return name + " = " + value + "; ";
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java
new file mode 100644
index 0000000000000000000000000000000000000000..410ee7c41a854b9c547af4f86242e4448975ac00
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java
@@ -0,0 +1,422 @@
+/*
+ * 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.data.serialization;
+
+import com.sun.hotspot.igv.data.GraphDocument;
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.InputBlock;
+import com.sun.hotspot.igv.data.InputEdge;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.InputMethod;
+import com.sun.hotspot.igv.data.InputNode;
+import com.sun.hotspot.igv.data.Properties;
+import com.sun.hotspot.igv.data.Property;
+import com.sun.hotspot.igv.data.services.GroupCallback;
+import com.sun.hotspot.igv.data.serialization.XMLParser.ElementHandler;
+import com.sun.hotspot.igv.data.serialization.XMLParser.HandoverElementHandler;
+import com.sun.hotspot.igv.data.serialization.XMLParser.ParseMonitor;
+import com.sun.hotspot.igv.data.serialization.XMLParser.TopElementHandler;
+import java.io.IOException;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class Parser {
+
+ public static final String INDENT = " ";
+ public static final String TOP_ELEMENT = "graphDocument";
+ public static final String GROUP_ELEMENT = "group";
+ public static final String GRAPH_ELEMENT = "graph";
+ public static final String ROOT_ELEMENT = "graphDocument";
+ public static final String PROPERTIES_ELEMENT = "properties";
+ public static final String EDGES_ELEMENT = "edges";
+ public static final String PROPERTY_ELEMENT = "p";
+ public static final String EDGE_ELEMENT = "edge";
+ public static final String NODE_ELEMENT = "node";
+ public static final String NODES_ELEMENT = "nodes";
+ public static final String REMOVE_EDGE_ELEMENT = "removeEdge";
+ public static final String REMOVE_NODE_ELEMENT = "removeNode";
+ public static final String METHOD_NAME_PROPERTY = "name";
+ public static final String METHOD_IS_PUBLIC_PROPERTY = "public";
+ public static final String METHOD_IS_STATIC_PROPERTY = "static";
+ public static final String TRUE_VALUE = "true";
+ public static final String NODE_NAME_PROPERTY = "name";
+ public static final String EDGE_NAME_PROPERTY = "name";
+ public static final String NODE_ID_PROPERTY = "id";
+ public static final String FROM_PROPERTY = "from";
+ public static final String TO_PROPERTY = "to";
+ public static final String PROPERTY_NAME_PROPERTY = "name";
+ public static final String GRAPH_NAME_PROPERTY = "name";
+ public static final String TO_INDEX_PROPERTY = "index";
+ public static final String METHOD_ELEMENT = "method";
+ public static final String INLINE_ELEMENT = "inline";
+ public static final String BYTECODES_ELEMENT = "bytecodes";
+ public static final String METHOD_BCI_PROPERTY = "bci";
+ public static final String METHOD_SHORT_NAME_PROPERTY = "shortName";
+ public static final String CONTROL_FLOW_ELEMENT = "controlFlow";
+ public static final String BLOCK_NAME_PROPERTY = "name";
+ public static final String BLOCK_ELEMENT = "block";
+ public static final String SUCCESSORS_ELEMENT = "successors";
+ public static final String SUCCESSOR_ELEMENT = "successor";
+ public static final String ASSEMBLY_ELEMENT = "assembly";
+ public static final String DIFFERENCE_PROPERTY = "difference";
+ private TopElementHandler xmlDocument = new TopElementHandler();
+ private boolean difference;
+ private GroupCallback groupCallback;
+ //
+ private ElementHandler topHandler = new ElementHandler(TOP_ELEMENT) {
+
+ @Override
+ protected GraphDocument start() throws SAXException {
+ return new GraphDocument();
+ }
+ };
+ //
+ private ElementHandler groupHandler = new XMLParser.ElementHandler(GROUP_ELEMENT) {
+
+ @Override
+ protected Group start() throws SAXException {
+ Group group = new Group();
+ Parser.this.difference = false;
+ String differenceProperty = this.readAttribute(DIFFERENCE_PROPERTY);
+ if (differenceProperty != null && (differenceProperty.equals("1") || differenceProperty.equals("true"))) {
+ Parser.this.difference = true;
+ }
+
+ ParseMonitor monitor = getMonitor();
+ if (monitor != null) {
+ monitor.setState(group.getName());
+ }
+
+ return group;
+ }
+
+ @Override
+ protected void end(String text) throws SAXException {
+ if (groupCallback == null) {
+ getParentObject().addGroup(getObject());
+ }
+ }
+ };
+ private HandoverElementHandler assemblyHandler = new XMLParser.HandoverElementHandler(ASSEMBLY_ELEMENT, true) {
+
+ @Override
+ protected void end(String text) throws SAXException {
+ getParentObject().setAssembly(text);
+ }
+ };
+ //
+ private ElementHandler methodHandler = new XMLParser.ElementHandler(METHOD_ELEMENT) {
+
+ @Override
+ protected InputMethod start() throws SAXException {
+
+ InputMethod method = parseMethod(this, getParentObject());
+ getParentObject().setMethod(method);
+ return method;
+ }
+ };
+
+ private InputMethod parseMethod(XMLParser.ElementHandler handler, Group group) throws SAXException {
+ String s = handler.readRequiredAttribute(METHOD_BCI_PROPERTY);
+ int bci = 0;
+ try {
+ bci = Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ throw new SAXException(e);
+ }
+ InputMethod method = new InputMethod(group, handler.readRequiredAttribute(METHOD_NAME_PROPERTY), handler.readRequiredAttribute(METHOD_SHORT_NAME_PROPERTY), bci);
+ return method;
+ }
+ //
+ private HandoverElementHandler bytecodesHandler = new XMLParser.HandoverElementHandler(BYTECODES_ELEMENT, true) {
+
+ @Override
+ protected void end(String text) throws SAXException {
+ getParentObject().setBytecodes(text);
+ }
+ };
+ //
+ private HandoverElementHandler inlinedHandler = new XMLParser.HandoverElementHandler(INLINE_ELEMENT);
+ //
+ private ElementHandler inlinedMethodHandler = new XMLParser.ElementHandler(METHOD_ELEMENT) {
+
+ @Override
+ protected InputMethod start() throws SAXException {
+ InputMethod method = parseMethod(this, getParentObject().getGroup());
+ getParentObject().addInlined(method);
+ return method;
+ }
+ };
+ //
+ private ElementHandler graphHandler = new XMLParser.ElementHandler(GRAPH_ELEMENT) {
+
+ private InputGraph graph;
+
+ @Override
+ protected InputGraph start() throws SAXException {
+
+ String name = readAttribute(GRAPH_NAME_PROPERTY);
+ InputGraph previous = getParentObject().getLastAdded();
+ if (!difference) {
+ previous = null;
+ }
+ InputGraph curGraph = new InputGraph(getParentObject(), previous, name);
+ getParentObject().addGraph(curGraph);
+ this.graph = curGraph;
+ return curGraph;
+ }
+
+ @Override
+ protected void end(String text) throws SAXException {
+ graph.resolveBlockLinks();
+ }
+ };
+ //
+ private HandoverElementHandler nodesHandler = new HandoverElementHandler(NODES_ELEMENT);
+ //
+ private HandoverElementHandler controlFlowHandler = new HandoverElementHandler(CONTROL_FLOW_ELEMENT);
+ //
+ private ElementHandler blockHandler = new ElementHandler(BLOCK_ELEMENT) {
+
+ @Override
+ protected InputBlock start() throws SAXException {
+ InputGraph graph = getParentObject();
+ String name = readRequiredAttribute(BLOCK_NAME_PROPERTY);
+ InputBlock b = new InputBlock(getParentObject(), name);
+ graph.addBlock(b);
+ return b;
+ }
+ };
+ //
+ private HandoverElementHandler blockNodesHandler = new HandoverElementHandler(NODES_ELEMENT);
+ //
+ private ElementHandler blockNodeHandler = new ElementHandler(NODE_ELEMENT) {
+
+ @Override
+ protected InputBlock start() throws SAXException {
+ String s = readRequiredAttribute(NODE_ID_PROPERTY);
+
+ int id = 0;
+ try {
+ id = Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ throw new SAXException(e);
+ }
+ getParentObject().addNode(id);
+ return getParentObject();
+ }
+ };
+ //
+ private HandoverElementHandler successorsHandler = new HandoverElementHandler(SUCCESSORS_ELEMENT);
+ //
+ private ElementHandler successorHandler = new ElementHandler(SUCCESSOR_ELEMENT) {
+
+ @Override
+ protected InputBlock start() throws SAXException {
+ String name = readRequiredAttribute(BLOCK_NAME_PROPERTY);
+ getParentObject().addSuccessor(name);
+ return getParentObject();
+ }
+ };
+ //
+ private ElementHandler nodeHandler = new ElementHandler(NODE_ELEMENT) {
+
+ @Override
+ protected InputNode start() throws SAXException {
+ String s = readRequiredAttribute(NODE_ID_PROPERTY);
+ int id = 0;
+ try {
+ id = Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ throw new SAXException(e);
+ }
+ InputNode node = new InputNode(id);
+ getParentObject().addNode(node);
+ return node;
+ }
+ };
+ //
+ private ElementHandler removeNodeHandler = new ElementHandler(REMOVE_NODE_ELEMENT) {
+
+ @Override
+ protected InputNode start() throws SAXException {
+ String s = readRequiredAttribute(NODE_ID_PROPERTY);
+ int id = 0;
+ try {
+ id = Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ throw new SAXException(e);
+ }
+ return getParentObject().removeNode(id);
+ }
+ };
+ //
+ private HandoverElementHandler edgesHandler = new HandoverElementHandler(EDGES_ELEMENT);
+
+ // Local class for edge elements
+ private static class EdgeElementHandler extends ElementHandler {
+
+ public EdgeElementHandler(String name) {
+ super(name);
+ }
+
+ @Override
+ protected InputEdge start() throws SAXException {
+ int toIndex = 0;
+ int from = -1;
+ int to = -1;
+
+ try {
+ String toIndexString = readAttribute(TO_INDEX_PROPERTY);
+ if (toIndexString != null) {
+ toIndex = Integer.parseInt(toIndexString);
+ }
+
+ from = Integer.parseInt(readRequiredAttribute(FROM_PROPERTY));
+ to = Integer.parseInt(readRequiredAttribute(TO_PROPERTY));
+ } catch (NumberFormatException e) {
+ throw new SAXException(e);
+ }
+
+
+ InputEdge conn = new InputEdge((char) toIndex, from, to);
+ return start(conn);
+ }
+
+ protected InputEdge start(InputEdge conn) throws SAXException {
+ return conn;
+ }
+ }
+ //
+ private EdgeElementHandler edgeHandler = new EdgeElementHandler(EDGE_ELEMENT) {
+
+ @Override
+ protected InputEdge start(InputEdge conn) throws SAXException {
+ getParentObject().addEdge(conn);
+ return conn;
+ }
+ };
+ //
+ private EdgeElementHandler removeEdgeHandler = new EdgeElementHandler(REMOVE_EDGE_ELEMENT) {
+
+ @Override
+ protected InputEdge start(InputEdge conn) throws SAXException {
+ getParentObject().removeEdge(conn);
+ return conn;
+ }
+ };
+ //
+ private HandoverElementHandler propertiesHandler = new HandoverElementHandler(PROPERTIES_ELEMENT);
+ //
+ private HandoverElementHandler groupPropertiesHandler = new HandoverElementHandler(PROPERTIES_ELEMENT) {
+
+ @Override
+ public void end(String text) throws SAXException {
+ if (groupCallback != null) {
+ groupCallback.started(getParentObject());
+ }
+ }
+ };
+ //
+ private ElementHandler propertyHandler = new XMLParser.ElementHandler(PROPERTY_ELEMENT, true) {
+
+ @Override
+ public Property start() throws SAXException {
+ String value = "";
+ String name = readRequiredAttribute(PROPERTY_NAME_PROPERTY).intern();
+ return getParentObject().getProperties().setProperty(name, value);
+ }
+
+ @Override
+ public void end(String text) {
+ getObject().setValue(text.trim().intern());
+ }
+ };
+
+ public Parser() {
+ this(null);
+ }
+
+ public Parser(GroupCallback groupCallback) {
+
+ this.groupCallback = groupCallback;
+
+ // Initialize dependencies
+ xmlDocument.addChild(topHandler);
+ topHandler.addChild(groupHandler);
+
+ groupHandler.addChild(methodHandler);
+ groupHandler.addChild(assemblyHandler);
+ groupHandler.addChild(graphHandler);
+
+ methodHandler.addChild(inlinedHandler);
+ methodHandler.addChild(bytecodesHandler);
+
+ inlinedHandler.addChild(inlinedMethodHandler);
+ inlinedMethodHandler.addChild(bytecodesHandler);
+ inlinedMethodHandler.addChild(inlinedHandler);
+
+ graphHandler.addChild(nodesHandler);
+ graphHandler.addChild(edgesHandler);
+ graphHandler.addChild(controlFlowHandler);
+
+ controlFlowHandler.addChild(blockHandler);
+
+ blockHandler.addChild(successorsHandler);
+ successorsHandler.addChild(successorHandler);
+ blockHandler.addChild(blockNodesHandler);
+ blockNodesHandler.addChild(blockNodeHandler);
+
+ nodesHandler.addChild(nodeHandler);
+ nodesHandler.addChild(removeNodeHandler);
+ edgesHandler.addChild(edgeHandler);
+ edgesHandler.addChild(removeEdgeHandler);
+
+ methodHandler.addChild(propertiesHandler);
+ inlinedMethodHandler.addChild(propertiesHandler);
+ topHandler.addChild(propertiesHandler);
+ groupHandler.addChild(groupPropertiesHandler);
+ graphHandler.addChild(propertiesHandler);
+ nodeHandler.addChild(propertiesHandler);
+ propertiesHandler.addChild(propertyHandler);
+ groupPropertiesHandler.addChild(propertyHandler);
+ }
+
+ // Returns a new GraphDocument object deserialized from an XML input source.
+ public GraphDocument parse(XMLReader reader, InputSource source, XMLParser.ParseMonitor monitor) throws SAXException {
+ reader.setContentHandler(new XMLParser(xmlDocument, monitor));
+ try {
+ reader.parse(source);
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+ }
+
+ return topHandler.getObject();
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java
new file mode 100644
index 0000000000000000000000000000000000000000..c5b794fce2f7ce54ae0a6fbf0406a4df3fbe7784
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java
@@ -0,0 +1,217 @@
+/*
+ * 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.data.serialization;
+
+import com.sun.hotspot.igv.data.GraphDocument;
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.InputBlock;
+import com.sun.hotspot.igv.data.InputBytecode;
+import com.sun.hotspot.igv.data.InputEdge;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.InputMethod;
+import com.sun.hotspot.igv.data.InputNode;
+import com.sun.hotspot.igv.data.Properties;
+import com.sun.hotspot.igv.data.Property;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class Printer {
+
+ public void export(Writer writer, GraphDocument document) {
+
+ XMLWriter xmlWriter = new XMLWriter(writer);
+
+ try {
+ export(xmlWriter, document);
+ } catch (IOException ex) {
+ }
+ }
+
+ private void export(XMLWriter xmlWriter, GraphDocument document) throws IOException {
+ xmlWriter.startTag(Parser.ROOT_ELEMENT);
+ xmlWriter.writeProperties(document.getProperties());
+ for (Group g : document.getGroups()) {
+ export(xmlWriter, g);
+ }
+
+ xmlWriter.endTag();
+ xmlWriter.flush();
+ }
+
+ private void export(XMLWriter writer, Group g) throws IOException {
+ Properties attributes = new Properties();
+ attributes.add(new Property("difference", Boolean.toString(true)));
+ writer.startTag(Parser.GROUP_ELEMENT, attributes);
+ writer.writeProperties(g.getProperties());
+
+ if (g.getMethod() != null) {
+ export(writer, g.getMethod());
+ }
+
+ InputGraph previous = null;
+ for (InputGraph graph : g.getGraphs()) {
+ export(writer, graph, previous, true);
+ previous = graph;
+ }
+
+ writer.endTag();
+ }
+
+ public void export(XMLWriter writer, InputGraph graph, InputGraph previous, boolean difference) throws IOException {
+
+ writer.startTag(Parser.GRAPH_ELEMENT);
+ writer.writeProperties(graph.getProperties());
+ writer.startTag(Parser.NODES_ELEMENT);
+
+ Set removed = new HashSet();
+ Set equal = new HashSet();
+
+ if (previous != null) {
+ for (InputNode n : previous.getNodes()) {
+ int id = n.getId();
+ InputNode n2 = graph.getNode(id);
+ if (n2 == null) {
+ removed.add(n);
+ } else if (n.equals(n2)) {
+ equal.add(n);
+ }
+ }
+ }
+
+ if (difference) {
+ for (InputNode n : removed) {
+ writer.simpleTag(Parser.REMOVE_NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, Integer.toString(n.getId())));
+ }
+ }
+
+ for (InputNode n : graph.getNodes()) {
+ if (!difference || !equal.contains(n)) {
+ writer.startTag(Parser.NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, Integer.toString(n.getId())));
+ writer.writeProperties(n.getProperties());
+ writer.endTag();
+ }
+ }
+
+ writer.endTag();
+
+ writer.startTag(Parser.EDGES_ELEMENT);
+ Set removedEdges = new HashSet();
+ Set equalEdges = new HashSet();
+
+ if (previous != null) {
+ for (InputEdge e : previous.getEdges()) {
+ if (graph.getEdges().contains(e)) {
+ equalEdges.add(e);
+ } else {
+ removedEdges.add(e);
+ }
+ }
+ }
+
+ if (difference) {
+ for (InputEdge e : removedEdges) {
+ writer.simpleTag(Parser.REMOVE_EDGE_ELEMENT, createProperties(e));
+ }
+ }
+
+ for (InputEdge e : graph.getEdges()) {
+ if (!difference || !equalEdges.contains(e)) {
+ if (!equalEdges.contains(e)) {
+ writer.simpleTag(Parser.EDGE_ELEMENT, createProperties(e));
+ }
+ }
+ }
+
+ writer.endTag();
+
+ writer.startTag(Parser.CONTROL_FLOW_ELEMENT);
+ for (InputBlock b : graph.getBlocks()) {
+
+ writer.startTag(Parser.BLOCK_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, b.getName()));
+
+ writer.startTag(Parser.SUCCESSORS_ELEMENT);
+ for (InputBlock s : b.getSuccessors()) {
+ writer.simpleTag(Parser.SUCCESSOR_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, s.getName()));
+ }
+ writer.endTag();
+
+ writer.startTag(Parser.NODES_ELEMENT);
+ for (InputNode n : b.getNodes()) {
+ writer.simpleTag(Parser.NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, n.getId() + ""));
+ }
+ writer.endTag();
+
+ writer.endTag();
+
+ }
+
+ writer.endTag();
+ writer.endTag();
+ }
+
+ private void export(XMLWriter w, InputMethod method) throws IOException {
+
+ w.startTag(Parser.METHOD_ELEMENT, new Properties(Parser.METHOD_BCI_PROPERTY, method.getBci() + "", Parser.METHOD_NAME_PROPERTY, method.getName(), Parser.METHOD_SHORT_NAME_PROPERTY, method.getShortName()));
+
+ w.writeProperties(method.getProperties());
+
+ if (method.getInlined().size() > 0) {
+ w.startTag(Parser.INLINE_ELEMENT);
+ for (InputMethod m : method.getInlined()) {
+ export(w, m);
+ }
+ w.endTag();
+ }
+
+ w.startTag(Parser.BYTECODES_ELEMENT);
+
+ StringBuilder b = new StringBuilder();
+ b.append("");
+ w.write(b.toString());
+ w.endTag();
+ w.endTag();
+ }
+
+ private Properties createProperties(InputEdge edge) {
+ Properties p = new Properties();
+ p.setProperty(Parser.TO_INDEX_PROPERTY, Integer.toString(edge.getToIndex()));
+ p.setProperty(Parser.TO_PROPERTY, Integer.toString(edge.getTo()));
+ p.setProperty(Parser.FROM_PROPERTY, Integer.toString(edge.getFrom()));
+ return p;
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java
new file mode 100644
index 0000000000000000000000000000000000000000..1efcd06dec9de23d022ef124d0ad10104bd0984e
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java
@@ -0,0 +1,254 @@
+/*
+ * 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.data.serialization;
+
+import com.sun.hotspot.igv.data.Property;
+import com.sun.hotspot.igv.data.Properties;
+import java.util.Hashtable;
+import java.util.Stack;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class XMLParser implements ContentHandler {
+
+ public static interface ParseMonitor {
+
+ public void setProgress(double d);
+
+ public void setState(String state);
+ }
+
+ public static class MissingAttributeException extends SAXException {
+
+ private String name;
+
+ public MissingAttributeException(String name) {
+ super("Missing attribute \"" + name + "\"");
+ this.name = name;
+ }
+
+ public String getAttributeName() {
+ return this.getMessage();
+ }
+ }
+
+ public static class HandoverElementHandler
extends ElementHandler
{
+
+ @Override
+ protected P start() throws SAXException {
+ return getParentObject();
+ }
+
+ public HandoverElementHandler(String name) {
+ super(name);
+ }
+
+ public HandoverElementHandler(String name, boolean needsText) {
+ super(name, needsText);
+ }
+ }
+
+ public static class TopElementHandler
parentElement;
+
+ public ElementHandler(String name) {
+ this(name, false);
+ }
+
+ public ElementHandler
getParentElement() {
+ return parentElement;
+ }
+
+ public P getParentObject() {
+ return getParentElement().getObject();
+ }
+
+ protected boolean needsText() {
+ return needsText;
+ }
+
+ public ElementHandler(String name, boolean needsText) {
+ this.hashtable = new Hashtable>();
+ this.name = name;
+ this.needsText = needsText;
+ }
+
+ public ParseMonitor getMonitor() {
+ return monitor;
+ }
+
+ public ElementHandler, ? super T> getChild(String name) {
+ return hashtable.get(name);
+ }
+
+ public void addChild(ElementHandler, ? super T> handler) {
+ assert handler != null;
+ hashtable.put(handler.getName(), handler);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public T getObject() {
+ return object;
+ }
+
+ public String readAttribute(String name) {
+ return attr.getValue(name);
+ }
+
+ public String readRequiredAttribute(String name) throws SAXException {
+ String s = readAttribute(name);
+ if (s == null) {
+ throw new MissingAttributeException(name);
+ }
+ return s;
+ }
+
+ public void processAttributesAsProperties(Properties p) {
+ int length = attr.getLength();
+ for (int i = 0; i < length; i++) {
+ String val = attr.getValue(i).intern();
+ String localName = attr.getLocalName(i).intern();
+ p.add(new Property(val, localName));
+ }
+ }
+
+ public void startElement(ElementHandler
parentElement, Attributes attr, ParseMonitor monitor) throws SAXException {
+ this.currentText = new StringBuilder();
+ this.attr = attr;
+ this.monitor = monitor;
+ this.parentElement = parentElement;
+ object = start();
+ }
+
+ protected T start() throws SAXException {
+ return null;
+ }
+
+ protected void end(String text) throws SAXException {
+
+ }
+
+ public void endElement() throws SAXException {
+ end(currentText.toString());
+ }
+
+ protected void text(char[] c, int start, int length) {
+ assert currentText != null;
+ currentText.append(c, start, length);
+ }
+ }
+ private Stack stack;
+ private ParseMonitor monitor;
+
+ public XMLParser(TopElementHandler rootHandler, ParseMonitor monitor) {
+ this.stack = new Stack();
+ this.monitor = monitor;
+ this.stack.push(rootHandler);
+ }
+
+ public void setDocumentLocator(Locator locator) {
+ if (monitor != null) {
+ monitor.setState("Starting parsing");
+ }
+ }
+
+ public void startDocument() throws SAXException {
+ }
+
+ public void endDocument() throws SAXException {
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+
+ assert !stack.isEmpty();
+ ElementHandler parent = stack.peek();
+ if (parent != null) {
+ ElementHandler child = parent.getChild(qName);
+ if (child != null) {
+ child.startElement(parent, atts, monitor);
+ stack.push(child);
+ return;
+ }
+ }
+
+ stack.push(null);
+ }
+
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ ElementHandler handler = stack.pop();
+ if (handler != null) {
+ handler.endElement();
+ }
+ }
+
+ public void characters(char[] ch, int start, int length) throws SAXException {
+
+ assert !stack.isEmpty();
+
+
+ ElementHandler top = stack.peek();
+ if (top != null && top.needsText()) {
+ top.text(ch, start, length);
+ }
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException {
+ }
+
+ public void skippedEntity(String name) throws SAXException {
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java
new file mode 100644
index 0000000000000000000000000000000000000000..e112dbf4f076591f422963658a314adde0c4260b
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java
@@ -0,0 +1,128 @@
+/*
+ * 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.data.serialization;
+
+import com.sun.hotspot.igv.data.Properties;
+import com.sun.hotspot.igv.data.Property;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Stack;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class XMLWriter extends Writer {
+
+ private Writer inner;
+ private Stack elementStack;
+
+ public XMLWriter(Writer inner) {
+ this.inner = inner;
+ elementStack = new Stack();
+ }
+
+ @Override
+ public void write(char[] arr) throws IOException {
+ write(arr, 0, arr.length);
+ }
+
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ for (int i = off; i < off + len; i++) {
+ char c = cbuf[i];
+ if (c == '>') {
+ inner.write(">");
+ } else if (c == '<') {
+ inner.write("<");
+ } else if (c == '&') {
+ inner.write("&");
+ } else {
+ inner.write(c);
+ }
+ }
+ }
+
+ public void flush() throws IOException {
+ inner.flush();
+ }
+
+ public void close() throws IOException {
+ inner.close();
+ }
+
+ public void endTag() throws IOException {
+ inner.write("" + elementStack.pop() + ">\n");
+ }
+
+ public void startTag(String name) throws IOException {
+ inner.write("<" + name + ">\n");
+ elementStack.push(name);
+ }
+
+ public void simpleTag(String name) throws IOException {
+ inner.write("<" + name + "/>\n");
+ }
+
+ public void startTag(String name, Properties attributes) throws IOException {
+ inner.write("<" + name);
+ elementStack.push(name);
+
+ for (Property p : attributes.getProperties()) {
+ inner.write(" " + p.getName() + "=\"");
+ write(p.getValue().toCharArray());
+ inner.write("\"");
+ }
+
+ inner.write(">\n");
+ }
+
+ public void simpleTag(String name, Properties attributes) throws IOException {
+ inner.write("<" + name);
+
+ for (Property p : attributes.getProperties()) {
+ inner.write(" " + p.getName() + "=\"");
+ write(p.getValue().toCharArray());
+ inner.write("\"");
+ }
+
+ inner.write("/>\n");
+ }
+
+ public void writeProperties(Properties props) throws IOException {
+ if (props.getProperties().size() == 0) {
+ return;
+ }
+
+ startTag(Parser.PROPERTIES_ELEMENT);
+
+ for (Property p : props.getProperties()) {
+ startTag(Parser.PROPERTY_ELEMENT, new Properties(Parser.PROPERTY_NAME_PROPERTY, p.getName()));
+ this.write(p.getValue().toCharArray());
+ endTag();
+ }
+
+ endTag();
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GraphViewer.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GraphViewer.java
new file mode 100644
index 0000000000000000000000000000000000000000..153221d55e5d44648a2a178deae1fb0a81488841
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GraphViewer.java
@@ -0,0 +1,35 @@
+/*
+ * 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.data.services;
+
+import com.sun.hotspot.igv.data.InputGraph;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface GraphViewer {
+
+ public void view(InputGraph graph);
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupCallback.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupCallback.java
new file mode 100644
index 0000000000000000000000000000000000000000..8b0115e84b155f5e75621bd7729ecdd17e4196c8
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupCallback.java
@@ -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.data.services;
+
+import com.sun.hotspot.igv.data.Group;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface GroupCallback {
+
+ public void started(Group g);
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java
new file mode 100644
index 0000000000000000000000000000000000000000..90d61ebc10dc207180bcda65c05c97a55decb80c
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java
@@ -0,0 +1,39 @@
+/*
+ * 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.data.services;
+
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.Pair;
+import java.util.List;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface GroupOrganizer {
+
+ public String getName();
+
+ public List>> organize(List subFolders, List groups);
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java
new file mode 100644
index 0000000000000000000000000000000000000000..8b730c3e29166e61a09fe9f5e2c4df9c8b5d1028
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java
@@ -0,0 +1,35 @@
+/*
+ * 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.data.services;
+
+import java.awt.Component;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface GroupReceiver {
+
+ public Component init(GroupCallback callback);
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..0006ec55a13bb46347fa1d03b98842cf0cc0d241
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java
@@ -0,0 +1,40 @@
+/*
+ * 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.data.services;
+
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.InputNode;
+import java.util.Set;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface InputGraphProvider {
+
+ InputGraph getGraph();
+
+ void setSelectedNodes(Set nodes);
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/Scheduler.java b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/Scheduler.java
new file mode 100644
index 0000000000000000000000000000000000000000..18207df4c1f6f18e18a2842c902afe90f53185b7
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/Scheduler.java
@@ -0,0 +1,38 @@
+/*
+ * 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.data.services;
+
+import com.sun.hotspot.igv.data.InputBlock;
+import com.sun.hotspot.igv.data.InputGraph;
+import java.util.Collection;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public interface Scheduler {
+
+ public Collection schedule(InputGraph graph);
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/build.xml b/src/share/tools/IdealGraphVisualizer/Difference/build.xml
new file mode 100644
index 0000000000000000000000000000000000000000..bc11fd91f85ea92c550811b95213d3f4c986c395
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/build.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+ Builds, tests, and runs the project com.sun.hotspot.igv.difference.
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/manifest.mf b/src/share/tools/IdealGraphVisualizer/Difference/manifest.mf
new file mode 100644
index 0000000000000000000000000000000000000000..febe22452a0704dd162839504976d74a5c339fbc
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/manifest.mf
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.sun.hotspot.igv.difference
+OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/difference/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/nbproject/build-impl.xml b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/build-impl.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1c1b96a9deaa376b109c3a8a9169aeba1577f5c0
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/build-impl.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+ You must set 'suite.dir' to point to your containing module suite
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/nbproject/genfiles.properties b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/genfiles.properties
new file mode 100644
index 0000000000000000000000000000000000000000..1c01a0733d172fdb82f82241d3a0e492b01de72c
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=1657ecfe
+build.xml.script.CRC32=03909051
+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=1657ecfe
+nbproject/build-impl.xml.script.CRC32=2208e770
+nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/nbproject/platform.properties b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/platform.properties
new file mode 100644
index 0000000000000000000000000000000000000000..68ad75e5766f33be5a65a19d28cc7605c5b50a1c
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/platform.properties
@@ -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
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties
new file mode 100644
index 0000000000000000000000000000000000000000..152f44eca60ab831869539ffae9192aa03915f3b
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1225db629713bd96c86d14ad446c9840f06d0c9c
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml
@@ -0,0 +1,23 @@
+
+
+ org.netbeans.modules.apisupport.project
+
+
+ com.sun.hotspot.igv.difference
+
+
+
+ com.sun.hotspot.igv.data
+
+
+
+ 1.0
+
+
+
+
+ com.sun.hotspot.igv.difference
+
+
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/nbproject/suite.properties b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/suite.properties
new file mode 100644
index 0000000000000000000000000000000000000000..29d7cc9bd6fdd81453543cdf1bcf1dab301e3a92
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/suite.properties
@@ -0,0 +1 @@
+suite.dir=${basedir}/..
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Bundle.properties b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Bundle.properties
new file mode 100644
index 0000000000000000000000000000000000000000..5c4d7e177fb4b317fbc3d57e1998fad0d9e2051d
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Bundle.properties
@@ -0,0 +1 @@
+OpenIDE-Module-Name=Difference
diff --git a/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java
new file mode 100644
index 0000000000000000000000000000000000000000..335344eb77bb43fd65bca60c442516da176fc6bf
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java
@@ -0,0 +1,320 @@
+/*
+ * 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.difference;
+
+import com.sun.hotspot.igv.data.Group;
+import com.sun.hotspot.igv.data.InputEdge;
+import com.sun.hotspot.igv.data.InputGraph;
+import com.sun.hotspot.igv.data.InputNode;
+import com.sun.hotspot.igv.data.Property;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class Difference {
+
+ public static final String PROPERTY_STATE = "state";
+ public static final String VALUE_NEW = "new";
+ public static final String VALUE_CHANGED = "changed";
+ public static final String VALUE_SAME = "same";
+ public static final String VALUE_DELETED = "deleted";
+ public static final String OLD_PREFIX = "OLD_";
+ public static final String MAIN_PROPERTY = "name";
+ public static final double LIMIT = 100.0;
+ public static final String[] IGNORE_PROPERTIES = new String[]{"idx", "debug_idx"};
+
+ public static InputGraph createDiffGraph(InputGraph a, InputGraph b) {
+ if (a.getGroup() == b.getGroup()) {
+ return createDiffSameGroup(a, b);
+ } else {
+ return createDiff(a, b);
+ }
+ }
+
+ private static InputGraph createDiffSameGroup(InputGraph a, InputGraph b) {
+ Map keyMapB = new HashMap();
+ for (InputNode n : b.getNodes()) {
+ Integer key = n.getId();
+ assert !keyMapB.containsKey(key);
+ keyMapB.put(key, n);
+ }
+
+ Set pairs = new HashSet();
+
+ for (InputNode n : a.getNodes()) {
+ Integer key = n.getId();
+
+
+ if (keyMapB.containsKey(key)) {
+ InputNode nB = keyMapB.get(key);
+ pairs.add(new Pair(n, nB));
+ }
+ }
+
+ return createDiff(a, b, pairs);
+ }
+
+ private static InputGraph createDiff(InputGraph a, InputGraph b, Set pairs) {
+ Group g = new Group();
+ g.setMethod(a.getGroup().getMethod());
+ g.setAssembly(a.getGroup().getAssembly());
+ g.getProperties().setProperty("name", "Difference");
+ InputGraph graph = new InputGraph(g, null);
+ graph.setName(a.getName() + ", " + b.getName());
+ graph.setIsDifferenceGraph(true);
+
+ Set nodesA = new HashSet(a.getNodes());
+ Set nodesB = new HashSet(b.getNodes());
+
+ Map inputNodeMap = new HashMap();
+ for (Pair p : pairs) {
+ InputNode n = p.getN1();
+ assert nodesA.contains(n);
+ InputNode nB = p.getN2();
+ assert nodesB.contains(nB);
+
+ nodesA.remove(n);
+ nodesB.remove(nB);
+ InputNode n2 = new InputNode(n);
+ inputNodeMap.put(n, n2);
+ inputNodeMap.put(nB, n2);
+ graph.addNode(n2);
+ markAsChanged(n2, n, nB);
+ }
+
+ for (InputNode n : nodesA) {
+ InputNode n2 = new InputNode(n);
+ graph.addNode(n2);
+ markAsNew(n2);
+ inputNodeMap.put(n, n2);
+ }
+
+ for (InputNode n : nodesB) {
+ InputNode n2 = new InputNode(n);
+ n2.setId(-n2.getId());
+ graph.addNode(n2);
+ markAsDeleted(n2);
+ inputNodeMap.put(n, n2);
+ }
+
+ Set edgesA = a.getEdges();
+ Set edgesB = b.getEdges();
+
+ Set newEdges = new HashSet();
+
+ for (InputEdge e : edgesA) {
+ int from = e.getFrom();
+ int to = e.getTo();
+ InputNode nodeFrom = inputNodeMap.get(a.getNode(from));
+ InputNode nodeTo = inputNodeMap.get(a.getNode(to));
+ char index = e.getToIndex();
+
+ InputEdge newEdge = new InputEdge(index, nodeFrom.getId(), nodeTo.getId());
+ if (!newEdges.contains(newEdge)) {
+ markAsNew(newEdge);
+ newEdges.add(newEdge);
+ graph.addEdge(newEdge);
+ }
+ }
+
+ for (InputEdge e : edgesB) {
+ int from = e.getFrom();
+ int to = e.getTo();
+ InputNode nodeFrom = inputNodeMap.get(b.getNode(from));
+ InputNode nodeTo = inputNodeMap.get(b.getNode(to));
+ char index = e.getToIndex();
+
+ InputEdge newEdge = new InputEdge(index, nodeFrom.getId(), nodeTo.getId());
+ if (!newEdges.contains(newEdge)) {
+ markAsDeleted(newEdge);
+ newEdges.add(newEdge);
+ graph.addEdge(newEdge);
+ } else {
+ newEdges.remove(newEdge);
+ graph.removeEdge(newEdge);
+ markAsSame(newEdge);
+ newEdges.add(newEdge);
+ graph.addEdge(newEdge);
+ }
+ }
+
+ g.addGraph(graph);
+ return graph;
+ }
+
+ private static class Pair {
+
+ private InputNode n1;
+ private InputNode n2;
+
+ public Pair(InputNode n1, InputNode n2) {
+ this.n1 = n1;
+ this.n2 = n2;
+ }
+
+ public double getValue() {
+
+ double result = 0.0;
+ for (Property p : n1.getProperties().getProperties()) {
+ double faktor = 1.0;
+ for (String forbidden : IGNORE_PROPERTIES) {
+ if (p.getName().equals(forbidden)) {
+ faktor = 0.1;
+ break;
+ }
+ }
+ String p2 = n2.getProperties().get(p.getName());
+ result += evaluate(p.getValue(), p2) * faktor;
+ }
+
+ return result;
+ }
+
+ private double evaluate(String p, String p2) {
+ if (p2 == null) {
+ return 1.0;
+ }
+ if (p.equals(p2)) {
+ return 0.0;
+ } else {
+ return (double) (Math.abs(p.length() - p2.length())) / p.length() + 0.5;
+ }
+ }
+
+ public InputNode getN1() {
+ return n1;
+ }
+
+ public InputNode getN2() {
+ return n2;
+ }
+ }
+
+ private static InputGraph createDiff(InputGraph a, InputGraph b) {
+
+ Set matched = new HashSet();
+
+ Set pairs = new HashSet();
+ for (InputNode n : a.getNodes()) {
+ String s = n.getProperties().get(MAIN_PROPERTY);
+ if (s == null) {
+ s = "";
+ }
+ for (InputNode n2 : b.getNodes()) {
+ String s2 = n2.getProperties().get(MAIN_PROPERTY);
+ if (s2 == null) {
+ s2 = "";
+ }
+
+ if (s.equals(s2)) {
+ Pair p = new Pair(n, n2);
+ pairs.add(p);
+ }
+ }
+ }
+
+ Set selectedPairs = new HashSet();
+ while (pairs.size() > 0) {
+
+ double min = Double.MAX_VALUE;
+ Pair minPair = null;
+ for (Pair p : pairs) {
+ double cur = p.getValue();
+ if (cur < min) {
+ minPair = p;
+ min = cur;
+ }
+ }
+
+ if (min > LIMIT) {
+ break;
+ } else {
+ selectedPairs.add(minPair);
+
+ Set toRemove = new HashSet();
+ for (Pair p : pairs) {
+ if (p.getN1() == minPair.getN1() || p.getN2() == minPair.getN2()) {
+ toRemove.add(p);
+ }
+ }
+ pairs.removeAll(toRemove);
+ }
+ }
+
+ return createDiff(a, b, selectedPairs);
+ }
+
+ private static void markAsNew(InputEdge e) {
+ e.setState(InputEdge.State.NEW);
+ }
+
+ private static void markAsDeleted(InputEdge e) {
+ e.setState(InputEdge.State.DELETED);
+
+ }
+
+ private static void markAsSame(InputEdge e) {
+ e.setState(InputEdge.State.SAME);
+ }
+
+ private static void markAsChanged(InputNode n, InputNode firstNode, InputNode otherNode) {
+
+ boolean difference = false;
+ for (Property p : otherNode.getProperties().getProperties()) {
+ String s = firstNode.getProperties().getProperty(p.getName());
+ if (!p.getValue().equals(s)) {
+ difference = true;
+ n.getProperties().add(new Property(OLD_PREFIX + p.getName(), p.getValue()));
+ }
+ }
+
+ for (Property p : firstNode.getProperties().getProperties()) {
+ String s = otherNode.getProperties().getProperty(p.getName());
+ if (s == null && p.getValue().length() > 0) {
+ difference = true;
+ n.getProperties().add(new Property(OLD_PREFIX + p.getName(), ""));
+ }
+ }
+
+ if (difference) {
+ n.getProperties().add(new Property(PROPERTY_STATE, VALUE_CHANGED));
+ } else {
+ n.getProperties().add(new Property(PROPERTY_STATE, VALUE_SAME));
+ }
+ }
+
+ private static void markAsDeleted(InputNode n) {
+ n.getProperties().add(new Property(PROPERTY_STATE, VALUE_DELETED));
+ }
+
+ private static void markAsNew(InputNode n) {
+ n.getProperties().add(new Property(PROPERTY_STATE, VALUE_NEW));
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/build.xml b/src/share/tools/IdealGraphVisualizer/Filter/build.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2182f70466c3381ea7aaf6cbabcd4e4117d38107
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/build.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+ Builds, tests, and runs the project com.sun.hotspot.igv.filter.
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/manifest.mf b/src/share/tools/IdealGraphVisualizer/Filter/manifest.mf
new file mode 100644
index 0000000000000000000000000000000000000000..185ff360536c3b812b17178de87dec59eaad3e5d
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/manifest.mf
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.sun.hotspot.igv.filter
+OpenIDE-Module-Layer: com/sun/hotspot/igv/filter/layer.xml
+OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/filter/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/nbproject/build-impl.xml b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/build-impl.xml
new file mode 100644
index 0000000000000000000000000000000000000000..363a56cc9d97743af403986924b414feb057c834
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/build-impl.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+ You must set 'suite.dir' to point to your containing module suite
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/nbproject/genfiles.properties b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/genfiles.properties
new file mode 100644
index 0000000000000000000000000000000000000000..0b45838e0769bba9982ebfec15ccf11bdb88b30c
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=7c032ebf
+build.xml.script.CRC32=3b022a25
+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=7c032ebf
+nbproject/build-impl.xml.script.CRC32=26513f91
+nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/nbproject/platform.properties b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/platform.properties
new file mode 100644
index 0000000000000000000000000000000000000000..68ad75e5766f33be5a65a19d28cc7605c5b50a1c
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/platform.properties
@@ -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
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties
new file mode 100644
index 0000000000000000000000000000000000000000..152f44eca60ab831869539ffae9192aa03915f3b
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties
@@ -0,0 +1,2 @@
+javac.source=1.5
+javac.compilerargs=-Xlint -Xlint:-serial
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.xml b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..31414d5503e0414b28b0cda0ee4d1bc3c62a5276
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.xml
@@ -0,0 +1,80 @@
+
+
+ org.netbeans.modules.apisupport.project
+
+
+ com.sun.hotspot.igv.filter
+
+
+
+ com.sun.hotspot.igv.data
+
+
+
+ 1.0
+
+
+
+ com.sun.hotspot.igv.graph
+
+
+
+ 1.0
+
+
+
+ org.jdesktop.layout
+
+
+
+ 1
+ 1.4.1
+
+
+
+ org.openide.dialogs
+
+
+
+ 7.5.1
+
+
+
+ org.openide.filesystems
+
+
+
+ 7.3
+
+
+
+ org.openide.nodes
+
+
+
+ 7.2.0.1
+
+
+
+ org.openide.util
+
+
+
+ 7.9.0.1
+
+
+
+ org.openide.windows
+
+
+
+ 6.16
+
+
+
+
+ com.sun.hotspot.igv.filter
+
+
+
+
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/nbproject/suite.properties b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/suite.properties
new file mode 100644
index 0000000000000000000000000000000000000000..29d7cc9bd6fdd81453543cdf1bcf1dab301e3a92
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/nbproject/suite.properties
@@ -0,0 +1 @@
+suite.dir=${basedir}/..
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction b/src/share/tools/IdealGraphVisualizer/Filter/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction
new file mode 100644
index 0000000000000000000000000000000000000000..4ebfb455217336de99e15dc13e03d95e9bccf89f
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction
@@ -0,0 +1 @@
+com.sun.hotspot.igv.filter.JavaSE6ScriptEngine
\ No newline at end of file
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..d015e64189522ba3a4bab47bbd23f08d560ca471
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java
@@ -0,0 +1,60 @@
+/*
+ * 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.filter;
+
+import com.sun.hotspot.igv.data.ChangedEvent;
+import com.sun.hotspot.igv.data.Properties;
+import org.openide.cookies.OpenCookie;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public abstract class AbstractFilter implements Filter {
+
+ private ChangedEvent changedEvent;
+ private Properties properties;
+
+ public AbstractFilter() {
+ changedEvent = new ChangedEvent(this);
+ properties = new Properties();
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public OpenCookie getEditor() {
+ return null;
+ }
+
+ public ChangedEvent getChangedEvent() {
+ return changedEvent;
+ }
+
+ protected void fireChangedEvent() {
+ changedEvent.fire();
+ }
+}
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Bundle.properties b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Bundle.properties
new file mode 100644
index 0000000000000000000000000000000000000000..cd43cb80c2a8fe64dcd1160c34de204547cc51e3
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Bundle.properties
@@ -0,0 +1,11 @@
+OpenIDE-Module-Name=Filter
+
+jLabel1.text=Name\:
+jLabel2.text=Source\:
+
+nameTextField.text=
+
+jButton1.text=OK
+jButton2.text=Cancel
+
+title=Edit Filter Dialog
diff --git a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..f0dd2ca95cb091d2f6d3549c417802320ed9c88d
--- /dev/null
+++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java
@@ -0,0 +1,138 @@
+/*
+ * 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.filter;
+
+import com.sun.hotspot.igv.graph.Connection;
+import com.sun.hotspot.igv.graph.Connection.ConnectionStyle;
+import com.sun.hotspot.igv.graph.Diagram;
+import com.sun.hotspot.igv.graph.Figure;
+import com.sun.hotspot.igv.graph.OutputSlot;
+import com.sun.hotspot.igv.graph.Selector;
+import com.sun.hotspot.igv.data.Properties;
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author Thomas Wuerthinger
+ */
+public class ColorFilter extends AbstractFilter {
+
+ private List colorRules;
+ private String name;
+
+ public ColorFilter(String name) {
+ this.name = name;
+ colorRules = new ArrayList();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void apply(Diagram diagram) {
+
+ Properties.PropertySelector