# HG changeset patch # User Thomas Wuerthinger # Date 1319124350 -7200 # Node ID 707bc4847b00256dc27ac1ebad8a435c6f7cba70 # Parent 9c0748af29c99594b79d6c79342f84c3aaa4ffbe# Parent 9fe4191f46af8d7dd27f99bec39f889c892495fb Merge. diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/Bundle.properties Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/Bundle.properties Thu Oct 20 17:25:50 2011 +0200 @@ -1,4 +1,4 @@ -CTL_BytecodeViewAction=Open BytecodeView Window +CTL_BytecodeViewAction=Bytecode CTL_BytecodeViewTopComponent=Bytecode CTL_SelectBytecodesAction=Select nodes HINT_BytecodeViewTopComponent=Shows the bytecode associated with the displayed graph. diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties Thu Oct 20 17:25:50 2011 +0200 @@ -1,4 +1,4 @@ -CTL_ControlFlowAction=Open ControlFlow Window +CTL_ControlFlowAction=Control Flow CTL_ControlFlowTopComponent=Control Flow HINT_ControlFlowTopComponent=Shows the blocks of the current graph. OpenIDE-Module-Name=ControlFlow diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Thu Oct 20 17:25:50 2011 +0200 @@ -79,7 +79,7 @@ List curNodes = new ArrayList(); for (Group g : p.getRight()) { - for (InputGraph graph : g.getGraphs()) { + for (InputGraph graph : g.getGraphListCopy()) { curNodes.add(new GraphNode(graph)); } g.getChangedEvent().addListener(this); diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java Thu Oct 20 17:25:50 2011 +0200 @@ -51,7 +51,7 @@ if (subFolders.size() == 0) { Map> map = new HashMap>(groups.size()); for (Group g : groups) { - Integer cur = g.getGraphs().size(); + Integer cur = g.getGraphsCount(); if (!map.containsKey(cur)) { map.put(cur, new ArrayList()); } diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties Thu Oct 20 17:25:50 2011 +0200 @@ -2,7 +2,7 @@ CTL_OpenGraphAction=View graph CTL_DiffGraphAction=Difference to current graph CTL_RemoveAction=Remove methods -CTL_OutlineAction=Open Outline Window +CTL_OutlineAction=Outline CTL_SaveAsAction=Save selected methods... CTL_SaveAllAction=Save all... CTL_PropertiesAction=Open Properties Window diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java Thu Oct 20 17:25:50 2011 +0200 @@ -47,10 +47,8 @@ import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; import org.openide.util.actions.CallableSystemAction; -import org.openide.xml.XMLUtil; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; /** * @@ -88,7 +86,6 @@ Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); try { - final XMLReader reader = XMLUtil.createXMLReader(); final FileInputStream inputStream = new FileInputStream(file); final InputSource is = new InputSource(inputStream); @@ -123,7 +120,7 @@ public void run() { GraphDocument document = null; try { - document = parser.parse(reader, is, parseMonitor); + document = parser.parse(is, parseMonitor); parseMonitor.setState("Finishing"); component.getDocument().addGraphDocument(document); } catch (SAXException ex) { @@ -140,8 +137,6 @@ } }); - } catch (SAXException ex) { - ex.printStackTrace(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java Thu Oct 20 17:25:50 2011 +0200 @@ -35,14 +35,15 @@ */ public class Group extends Properties.Entity implements ChangedEventProvider { - private List graphs; + private final List graphs; + private InputMethod method; private String assembly; private transient ChangedEvent changedEvent; private transient boolean complete = true; public Group() { - graphs = new ArrayList(); + graphs = Collections.synchronizedList(new ArrayList()); changedEvent = new ChangedEvent(this); // Ensure that name and type are never null @@ -86,30 +87,50 @@ return Collections.unmodifiableList(graphs); } + public int getGraphsCount() { + return graphs.size(); + } + + public List getGraphListCopy() { + synchronized (graphs) { + return new ArrayList(graphs); + } + } + + public void addGraph(InputGraph graph) { + synchronized (graphs) { + graph.setParent(this, graphs.size()); + graphs.add(graph); + } + changedEvent.fire(); + } + public InputGraph addGraph(String name) { return addGraph(name, null); } public InputGraph addGraph(String name, Pair pair) { - InputGraph g = new InputGraph(graphs.size(), this, name, pair); - graphs.add(g); + InputGraph g; + synchronized (graphs) { + g = new InputGraph(graphs.size(), this, name, pair); + graphs.add(g); + } changedEvent.fire(); return g; } public void removeGraph(InputGraph g) { - int index = graphs.indexOf(g); - if (index != -1) { - graphs.remove(g); + if (graphs.remove(g)) { changedEvent.fire(); } } public Set getAllNodes() { Set result = new HashSet(); - for (InputGraph g : graphs) { - Set ids = g.getNodesAsSet(); - result.addAll(g.getNodesAsSet()); + synchronized (graphs) { + for (InputGraph g : graphs) { + result.addAll(g.getNodesAsSet()); + } } return result; } @@ -118,9 +139,11 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Group " + getProperties().toString() + "\n"); - for (InputGraph g : graphs) { - sb.append(g.toString()); - sb.append("\n"); + synchronized (graphs) { + for (InputGraph g : graphs) { + sb.append(g.toString()); + sb.append('\n'); + } } return sb.toString(); } diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Thu Oct 20 17:25:50 2011 +0200 @@ -49,6 +49,10 @@ private Pair sourceGraphs; private int parentIndex; + public static InputGraph createWithoutGroup(String name, Pair sourceGraphs) { + return new InputGraph(-1, null, name, sourceGraphs); + } + InputGraph(int parentIndex, Group parent, String name, Pair sourceGraphs) { this.parentIndex = parentIndex; this.parent = parent; @@ -60,6 +64,14 @@ blockEdges = new LinkedHashSet(); nodeToBlock = new LinkedHashMap(); } + + public void setParent(Group parent, int parentIndex) { + assert (this.parent == null); + assert (this.parentIndex == -1); + + this.parent = parent; + this.parentIndex = parentIndex; + } public InputBlockEdge addBlockEdge(InputBlock left, InputBlock right) { InputBlockEdge edge = new InputBlockEdge(left, right); diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Thu Oct 20 17:25:50 2011 +0200 @@ -38,9 +38,15 @@ import com.sun.hotspot.igv.data.serialization.XMLParser.ParseMonitor; import com.sun.hotspot.igv.data.serialization.XMLParser.TopElementHandler; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.SchemaFactory; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -205,14 +211,12 @@ @Override protected InputGraph start() throws SAXException { - String name = readAttribute(GRAPH_NAME_PROPERTY); - InputGraph curGraph = getParentObject().addGraph(name); + InputGraph curGraph = InputGraph.createWithoutGroup(name, null); if (difference) { - List list = getParentObject().getGraphs(); - if (list.size() > 1) { - InputGraph previous = list.get(list.size() - 2); + if (list.size() > 0) { + InputGraph previous = list.get(list.size() - 1); for (InputNode n : previous.getNodes()) { curGraph.addNode(n); } @@ -273,6 +277,9 @@ graph.addBlockEdge(left, right); } blockConnections.clear(); + + // Add to group + getParentObject().addGraph(graph); } }; // @@ -378,7 +385,7 @@ if (fromIndexString != null) { fromIndex = Integer.parseInt(fromIndexString); } - + String toIndexString = readAttribute(TO_INDEX_PROPERTY); if (toIndexString == null) { toIndexString = readAttribute(TO_INDEX_ALT_PROPERTY); @@ -495,7 +502,9 @@ } // Returns a new GraphDocument object deserialized from an XML input source. - public synchronized GraphDocument parse(XMLReader reader, InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { + public synchronized GraphDocument parse(InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { + XMLReader reader = createReader(); + reader.setContentHandler(new XMLParser(xmlDocument, monitor)); try { reader.parse(source); @@ -505,4 +514,21 @@ return topHandler.getObject(); } + + private XMLReader createReader() throws SAXException { + try { + SAXParserFactory pfactory = SAXParserFactory.newInstance(); + pfactory.setValidating(false); + pfactory.setNamespaceAware(true); + + // Enable schema validation + SchemaFactory sfactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + InputStream stream = Parser.class.getResourceAsStream("graphdocument.xsd"); + pfactory.setSchema(sfactory.newSchema(new Source[]{new StreamSource(stream)})); + + return pfactory.newSAXParser().getXMLReader(); + } catch (ParserConfigurationException ex) { + throw new SAXException(ex); + } + } } diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/graphdocument.xsd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/graphdocument.xsd Thu Oct 20 17:25:50 2011 +0200 @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java --- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java Thu Oct 20 17:25:50 2011 +0200 @@ -70,7 +70,7 @@ public static void assertGroupEquals(Group a, Group b) { - if (a.getGraphs().size() != b.getGraphs().size()) { + if (a.getGraphsCount() != b.getGraphsCount()) { fail(); } diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java --- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java Thu Oct 20 17:25:50 2011 +0200 @@ -40,11 +40,9 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.openide.xml.XMLUtil; import static org.junit.Assert.*; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; /** * @@ -84,9 +82,8 @@ InputSource is = new InputSource(sr); try { - XMLReader reader = XMLUtil.createXMLReader(); Parser parser = new Parser(); - final GraphDocument parsedDocument = parser.parse(reader, is, null); + final GraphDocument parsedDocument = parser.parse(is, null); Util.assertGraphDocumentEquals(document, parsedDocument); } catch (SAXException ex) { fail(ex.toString()); diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties Thu Oct 20 17:25:50 2011 +0200 @@ -1,4 +1,4 @@ -CTL_FilterAction=Open Filter Window +CTL_FilterAction=Filters CTL_MoveFilterUpAction=Move upwards CTL_MoveFilterDownAction=Move downwards CTL_RemoveFilterAction=Remove diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties Thu Oct 20 17:25:50 2011 +0200 @@ -1,4 +1,4 @@ -CTL_TextAction=Open Text Window +CTL_TextAction=Text CTL_TextTopComponent=Text HINT_TextTopComponent=Shows a textual representation of the graph. OpenIDE-Module-Name=GraphTextEditor diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java --- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java Thu Oct 20 17:25:50 2011 +0200 @@ -33,10 +33,8 @@ import java.net.Socket; import javax.swing.JTextField; import org.openide.util.Exceptions; -import org.openide.xml.XMLUtil; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; /** * @@ -65,9 +63,8 @@ InputSource is = new InputSource(inputStream); try { - XMLReader reader = XMLUtil.createXMLReader(); Parser parser = new Parser(this); - parser.parse(reader, is, null); + parser.parse(is, null); } catch (SAXException ex) { ex.printStackTrace(); } diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Thu Oct 20 17:25:50 2011 +0200 @@ -111,7 +111,12 @@ p = parent; break; } + p = p.preds.get(0); + if (p == proj) { + // Cycle, stop + break; + } if (p.block == null) { p.block = block; diff -r 9c0748af29c9 -r 707bc4847b00 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java Thu Oct 20 17:25:37 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java Thu Oct 20 17:25:50 2011 +0200 @@ -294,7 +294,7 @@ } }); - if (diagram.getGraph().getGroup().getGraphs().size() == 1) { + if (diagram.getGraph().getGroup().getGraphsCount() == 1) { rangeSlider.setVisible(false); }