diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/BinaryReader.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/BinaryReader.java index 1cb784d353e5..7b8881c43a1d 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/BinaryReader.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/BinaryReader.java @@ -1047,7 +1047,7 @@ private void parseBlocks() throws IOException { } } - private void createEdges(int id, int preds, List portList, EdgeBuilder factory) throws IOException { + private void createEdges(int id, int startNum, List portList, EdgeBuilder factory) throws IOException { int portNum = 0; for (Port p : portList) { if (p.isList) { @@ -1055,18 +1055,14 @@ private void createEdges(int id, int preds, List portList, EdgeB for (int j = 0; j < size; j++) { int in = dataSource.readInt(); p.ids.add(in); - if (in >= 0) { - factory.edge(p, in, id, (char) (preds + portNum), j); - portNum++; - } + factory.edge(p, in, id, (char) (startNum + portNum), j); + portNum++; } } else { int in = dataSource.readInt(); p.ids.add(in); - if (in >= 0) { - factory.edge(p, in, id, (char) (preds + portNum), -1); - portNum++; - } + factory.edge(p, in, id, (char) (startNum + portNum), -1); + portNum++; } p.ids = new ArrayList<>(); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/ModelBuilder.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/ModelBuilder.java index 16aa960c98a0..c8df87e9c062 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/ModelBuilder.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/ModelBuilder.java @@ -87,20 +87,22 @@ public static final class EdgeInfo { final int from; final int to; final char num; + final int listIndex; final String label; final String type; final boolean input; EdgeInfo(int from, int to) { - this(from, to, (char) 0, null, null, false); + this(from, to, (char) 0, -1, null, null, false); } - EdgeInfo(int from, int to, char num, String label, String type, boolean input) { + EdgeInfo(int from, int to, char num, int listIndex, String label, String type, boolean input) { this.from = from; this.to = to; this.label = label; this.type = type; this.num = num; + this.listIndex = listIndex; this.input = input; } @@ -112,6 +114,10 @@ public int getTo() { return to; } + public int getListIndex() { + return listIndex; + } + @Override public boolean equals(Object other) { if (other == null) { @@ -121,12 +127,13 @@ public boolean equals(Object other) { return false; } EdgeInfo otherEdge = (EdgeInfo) other; - return from == otherEdge.from && to == otherEdge.to && num == otherEdge.num && input == otherEdge.input && Objects.equals(label, otherEdge.label) && Objects.equals(type, otherEdge.type); + return from == otherEdge.from && to == otherEdge.to && num == otherEdge.num && listIndex == otherEdge.listIndex && input == otherEdge.input && Objects.equals(label, otherEdge.label) && + Objects.equals(type, otherEdge.type); } @Override public int hashCode() { - return Objects.hash(from, to, label); + return Objects.hash(from, to, listIndex, label); } } @@ -335,10 +342,9 @@ protected final InputGraph pushGraph(InputGraph g) { } protected void connectModifiedProperties(FolderElement g) { - if (!(g instanceof Properties.MutableOwner)) { + if (!(g instanceof Properties.MutableOwner mu)) { return; } - Properties.MutableOwner mu = (Properties.MutableOwner) g; GraphDocument doc = g.getOwner(); if (doc != null) { Properties props = doc.getModifiedProperties(g); @@ -357,8 +363,8 @@ public static String makeGraphName(int dumpId, String format, Object[] args) { for (int i = 0; i < args.length; ++i) { if (args[i] instanceof BinaryReader.Klass) { String className = args[i].toString(); - String s = className.substring(className.lastIndexOf(".") + 1); // strip the package - // name + // strip the package name + String s = className.substring(className.lastIndexOf(".") + 1); int innerClassPos = s.indexOf('$'); if (innerClassPos > 0) { /* Remove inner class name. */ @@ -721,8 +727,7 @@ private String createName(NodeClass nodeClass, List edges, String temp String length = m.group(4); if (prop == null) { result = "?"; - } else if (length != null && prop instanceof LengthToString) { - LengthToString lengthProp = (LengthToString) prop; + } else if (length != null && prop instanceof LengthToString lengthProp) { switch (length) { case "s": result = lengthProp.toString(Length.S); @@ -777,12 +782,19 @@ public void setNodeProperty(String key, Object value) { } } + protected static String inputEdgeType(Port p) { + EnumValue type = ((TypedPort) p).type; + return type == null ? null : type.toString(Length.S); + } + @Override public void inputEdge(Port p, int from, int to, char num, int index) { assert currentNode != null; - String label = (p.isList && index >= 0) ? p.name + "[" + index + "]" : p.name; - EnumValue type = ((TypedPort) p).type; - EdgeInfo ei = new EdgeInfo(from, to, num, label, type == null ? null : type.toString(Length.S), true); + // Ignore null edges + if (from < 0) { + return; + } + EdgeInfo ei = new EdgeInfo(from, to, num, index, p.name, inputEdgeType(p), true); inputEdges.add(ei); nodeEdges.add(ei); } @@ -790,14 +802,17 @@ public void inputEdge(Port p, int from, int to, char num, int index) { @Override public void successorEdge(Port p, int from, int to, char num, int index) { assert currentNode != null; - String label = (p.isList && index >= 0) ? p.name + "[" + index + "]" : p.name; - EdgeInfo ei = new EdgeInfo(to, from, num, label, InputEdge.SUCCESSOR_EDGE_TYPE, false); + // Ignore null edges + if (from < 0) { + return; + } + EdgeInfo ei = new EdgeInfo(to, from, num, index, p.name, InputEdge.SUCCESSOR_EDGE_TYPE, false); successorEdges.add(ei); nodeEdges.add(ei); } - protected InputEdge immutableEdge(char fromIndex, char toIndex, int from, int to, String label, String type) { - return InputEdge.createImmutable(fromIndex, toIndex, from, to, label, type); + protected InputEdge immutableEdge(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type) { + return InputEdge.createImmutable(fromIndex, toIndex, from, to, listIndex, label, type); } @Override @@ -818,13 +833,13 @@ public void makeGraphEdges() { if (currentGraph.getNode(e.to) == null) { reportLoadingError(ErrorMessages.edgeEndNodeNotExists(e.label, e.to)); } - graph.addEdge(immutableEdge(fromIndex, toIndex, e.from, e.to, e.label, e.type)); + graph.addEdge(immutableEdge(fromIndex, toIndex, e.from, e.to, e.listIndex, e.label, e.type)); } for (EdgeInfo e : inputEdges) { assert e.input; char fromIndex = (char) (nodesWithSuccessor.contains(graph.getNode(e.from)) ? 1 : 0); char toIndex = e.num; - graph.addEdge(immutableEdge(fromIndex, toIndex, e.from, e.to, e.label, e.type)); + graph.addEdge(immutableEdge(fromIndex, toIndex, e.from, e.to, e.listIndex, e.label, e.type)); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/model/InputEdge.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/model/InputEdge.java index 53a53b05c7cb..13ce12ffd294 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/model/InputEdge.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/model/InputEdge.java @@ -26,6 +26,7 @@ import java.lang.ref.WeakReference; import java.util.Comparator; +import java.util.Objects; import java.util.WeakHashMap; public class InputEdge { @@ -44,10 +45,13 @@ public enum State { private final char toIndex; private final char fromIndex; + private final int from; private final int to; + private final int listIndex; private final String label; private final String type; + private State state; private int hashCode = -1; @@ -60,13 +64,17 @@ public InputEdge(char fromIndex, char toIndex, int from, int to) { } public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type) { - this(fromIndex, toIndex, from, to, label, type, State.SAME); + this(fromIndex, toIndex, from, to, -1, label, type, State.SAME); + } + + public InputEdge(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type) { + this(fromIndex, toIndex, from, to, listIndex, label, type, State.SAME); } static WeakHashMap> immutableCache = new WeakHashMap<>(); - public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, String label, String type) { - InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, label, type, State.IMMUTABLE); + public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type) { + InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, listIndex, label, type, State.IMMUTABLE); WeakReference result = immutableCache.get(edge); if (result != null) { InputEdge edge2 = result.get(); @@ -78,18 +86,19 @@ public static synchronized InputEdge createImmutable(char fromIndex, char toInde return edge; } - public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type, State state) { + public InputEdge(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type, State state) { this.toIndex = toIndex; this.fromIndex = fromIndex; this.from = from; this.to = to; + this.listIndex = listIndex; this.state = state; this.label = label; this.type = type; - int hash = (from << 20 | to << 8 | toIndex << 4 | fromIndex); + int hash = Objects.hash(from, to, fromIndex, toIndex, listIndex); if (state == State.IMMUTABLE) { - hash = hash << 5 ^ label.hashCode(); + hash = Objects.hash(hash, label); } this.hashCode = hash; } @@ -108,7 +117,7 @@ public void setState(State x) { this.state = x; // terminal state if (state == State.IMMUTABLE) { - hashCode = hashCode << 5 ^ label.hashCode(); + hashCode = Objects.hash(hashCode, label); } } @@ -120,10 +129,6 @@ public char getFromIndex() { return fromIndex; } - public String getName() { - return "in" + toIndex; - } - public int getFrom() { return from; } @@ -132,21 +137,32 @@ public int getTo() { return to; } + public int getListIndex() { + return listIndex; + } + public String getLabel() { return label; } + public String getDisplayLabel() { + String ret = getLabel(); + if (listIndex >= 0) { + ret = ret + "[" + listIndex + "]"; + } + return ret; + } + public String getType() { return type; } @Override public boolean equals(Object o) { - if (!(o instanceof InputEdge)) { + if (!(o instanceof InputEdge conn2)) { return false; } - InputEdge conn2 = (InputEdge) o; - boolean result = conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to; + boolean result = conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to && conn2.listIndex == listIndex; if (result && (state == State.IMMUTABLE || conn2.state == State.IMMUTABLE)) { // Immutable instances must be exactly the same return conn2.state == state && conn2.label.equals(label); diff --git a/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/BinaryReader.java b/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/BinaryReader.java index 1cb784d353e5..7b8881c43a1d 100644 --- a/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/BinaryReader.java +++ b/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/BinaryReader.java @@ -1047,7 +1047,7 @@ private void parseBlocks() throws IOException { } } - private void createEdges(int id, int preds, List portList, EdgeBuilder factory) throws IOException { + private void createEdges(int id, int startNum, List portList, EdgeBuilder factory) throws IOException { int portNum = 0; for (Port p : portList) { if (p.isList) { @@ -1055,18 +1055,14 @@ private void createEdges(int id, int preds, List portList, EdgeB for (int j = 0; j < size; j++) { int in = dataSource.readInt(); p.ids.add(in); - if (in >= 0) { - factory.edge(p, in, id, (char) (preds + portNum), j); - portNum++; - } + factory.edge(p, in, id, (char) (startNum + portNum), j); + portNum++; } } else { int in = dataSource.readInt(); p.ids.add(in); - if (in >= 0) { - factory.edge(p, in, id, (char) (preds + portNum), -1); - portNum++; - } + factory.edge(p, in, id, (char) (startNum + portNum), -1); + portNum++; } p.ids = new ArrayList<>(); } diff --git a/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/ModelBuilder.java b/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/ModelBuilder.java index 16aa960c98a0..c8df87e9c062 100644 --- a/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/ModelBuilder.java +++ b/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/ModelBuilder.java @@ -87,20 +87,22 @@ public static final class EdgeInfo { final int from; final int to; final char num; + final int listIndex; final String label; final String type; final boolean input; EdgeInfo(int from, int to) { - this(from, to, (char) 0, null, null, false); + this(from, to, (char) 0, -1, null, null, false); } - EdgeInfo(int from, int to, char num, String label, String type, boolean input) { + EdgeInfo(int from, int to, char num, int listIndex, String label, String type, boolean input) { this.from = from; this.to = to; this.label = label; this.type = type; this.num = num; + this.listIndex = listIndex; this.input = input; } @@ -112,6 +114,10 @@ public int getTo() { return to; } + public int getListIndex() { + return listIndex; + } + @Override public boolean equals(Object other) { if (other == null) { @@ -121,12 +127,13 @@ public boolean equals(Object other) { return false; } EdgeInfo otherEdge = (EdgeInfo) other; - return from == otherEdge.from && to == otherEdge.to && num == otherEdge.num && input == otherEdge.input && Objects.equals(label, otherEdge.label) && Objects.equals(type, otherEdge.type); + return from == otherEdge.from && to == otherEdge.to && num == otherEdge.num && listIndex == otherEdge.listIndex && input == otherEdge.input && Objects.equals(label, otherEdge.label) && + Objects.equals(type, otherEdge.type); } @Override public int hashCode() { - return Objects.hash(from, to, label); + return Objects.hash(from, to, listIndex, label); } } @@ -335,10 +342,9 @@ protected final InputGraph pushGraph(InputGraph g) { } protected void connectModifiedProperties(FolderElement g) { - if (!(g instanceof Properties.MutableOwner)) { + if (!(g instanceof Properties.MutableOwner mu)) { return; } - Properties.MutableOwner mu = (Properties.MutableOwner) g; GraphDocument doc = g.getOwner(); if (doc != null) { Properties props = doc.getModifiedProperties(g); @@ -357,8 +363,8 @@ public static String makeGraphName(int dumpId, String format, Object[] args) { for (int i = 0; i < args.length; ++i) { if (args[i] instanceof BinaryReader.Klass) { String className = args[i].toString(); - String s = className.substring(className.lastIndexOf(".") + 1); // strip the package - // name + // strip the package name + String s = className.substring(className.lastIndexOf(".") + 1); int innerClassPos = s.indexOf('$'); if (innerClassPos > 0) { /* Remove inner class name. */ @@ -721,8 +727,7 @@ private String createName(NodeClass nodeClass, List edges, String temp String length = m.group(4); if (prop == null) { result = "?"; - } else if (length != null && prop instanceof LengthToString) { - LengthToString lengthProp = (LengthToString) prop; + } else if (length != null && prop instanceof LengthToString lengthProp) { switch (length) { case "s": result = lengthProp.toString(Length.S); @@ -777,12 +782,19 @@ public void setNodeProperty(String key, Object value) { } } + protected static String inputEdgeType(Port p) { + EnumValue type = ((TypedPort) p).type; + return type == null ? null : type.toString(Length.S); + } + @Override public void inputEdge(Port p, int from, int to, char num, int index) { assert currentNode != null; - String label = (p.isList && index >= 0) ? p.name + "[" + index + "]" : p.name; - EnumValue type = ((TypedPort) p).type; - EdgeInfo ei = new EdgeInfo(from, to, num, label, type == null ? null : type.toString(Length.S), true); + // Ignore null edges + if (from < 0) { + return; + } + EdgeInfo ei = new EdgeInfo(from, to, num, index, p.name, inputEdgeType(p), true); inputEdges.add(ei); nodeEdges.add(ei); } @@ -790,14 +802,17 @@ public void inputEdge(Port p, int from, int to, char num, int index) { @Override public void successorEdge(Port p, int from, int to, char num, int index) { assert currentNode != null; - String label = (p.isList && index >= 0) ? p.name + "[" + index + "]" : p.name; - EdgeInfo ei = new EdgeInfo(to, from, num, label, InputEdge.SUCCESSOR_EDGE_TYPE, false); + // Ignore null edges + if (from < 0) { + return; + } + EdgeInfo ei = new EdgeInfo(to, from, num, index, p.name, InputEdge.SUCCESSOR_EDGE_TYPE, false); successorEdges.add(ei); nodeEdges.add(ei); } - protected InputEdge immutableEdge(char fromIndex, char toIndex, int from, int to, String label, String type) { - return InputEdge.createImmutable(fromIndex, toIndex, from, to, label, type); + protected InputEdge immutableEdge(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type) { + return InputEdge.createImmutable(fromIndex, toIndex, from, to, listIndex, label, type); } @Override @@ -818,13 +833,13 @@ public void makeGraphEdges() { if (currentGraph.getNode(e.to) == null) { reportLoadingError(ErrorMessages.edgeEndNodeNotExists(e.label, e.to)); } - graph.addEdge(immutableEdge(fromIndex, toIndex, e.from, e.to, e.label, e.type)); + graph.addEdge(immutableEdge(fromIndex, toIndex, e.from, e.to, e.listIndex, e.label, e.type)); } for (EdgeInfo e : inputEdges) { assert e.input; char fromIndex = (char) (nodesWithSuccessor.contains(graph.getNode(e.from)) ? 1 : 0); char toIndex = e.num; - graph.addEdge(immutableEdge(fromIndex, toIndex, e.from, e.to, e.label, e.type)); + graph.addEdge(immutableEdge(fromIndex, toIndex, e.from, e.to, e.listIndex, e.label, e.type)); } } diff --git a/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/model/InputEdge.java b/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/model/InputEdge.java index 53a53b05c7cb..13ce12ffd294 100644 --- a/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/model/InputEdge.java +++ b/visualizer/IdealGraphVisualizer/Data/src/main/java/jdk/graal/compiler/graphio/parsing/model/InputEdge.java @@ -26,6 +26,7 @@ import java.lang.ref.WeakReference; import java.util.Comparator; +import java.util.Objects; import java.util.WeakHashMap; public class InputEdge { @@ -44,10 +45,13 @@ public enum State { private final char toIndex; private final char fromIndex; + private final int from; private final int to; + private final int listIndex; private final String label; private final String type; + private State state; private int hashCode = -1; @@ -60,13 +64,17 @@ public InputEdge(char fromIndex, char toIndex, int from, int to) { } public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type) { - this(fromIndex, toIndex, from, to, label, type, State.SAME); + this(fromIndex, toIndex, from, to, -1, label, type, State.SAME); + } + + public InputEdge(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type) { + this(fromIndex, toIndex, from, to, listIndex, label, type, State.SAME); } static WeakHashMap> immutableCache = new WeakHashMap<>(); - public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, String label, String type) { - InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, label, type, State.IMMUTABLE); + public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type) { + InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, listIndex, label, type, State.IMMUTABLE); WeakReference result = immutableCache.get(edge); if (result != null) { InputEdge edge2 = result.get(); @@ -78,18 +86,19 @@ public static synchronized InputEdge createImmutable(char fromIndex, char toInde return edge; } - public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type, State state) { + public InputEdge(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type, State state) { this.toIndex = toIndex; this.fromIndex = fromIndex; this.from = from; this.to = to; + this.listIndex = listIndex; this.state = state; this.label = label; this.type = type; - int hash = (from << 20 | to << 8 | toIndex << 4 | fromIndex); + int hash = Objects.hash(from, to, fromIndex, toIndex, listIndex); if (state == State.IMMUTABLE) { - hash = hash << 5 ^ label.hashCode(); + hash = Objects.hash(hash, label); } this.hashCode = hash; } @@ -108,7 +117,7 @@ public void setState(State x) { this.state = x; // terminal state if (state == State.IMMUTABLE) { - hashCode = hashCode << 5 ^ label.hashCode(); + hashCode = Objects.hash(hashCode, label); } } @@ -120,10 +129,6 @@ public char getFromIndex() { return fromIndex; } - public String getName() { - return "in" + toIndex; - } - public int getFrom() { return from; } @@ -132,21 +137,32 @@ public int getTo() { return to; } + public int getListIndex() { + return listIndex; + } + public String getLabel() { return label; } + public String getDisplayLabel() { + String ret = getLabel(); + if (listIndex >= 0) { + ret = ret + "[" + listIndex + "]"; + } + return ret; + } + public String getType() { return type; } @Override public boolean equals(Object o) { - if (!(o instanceof InputEdge)) { + if (!(o instanceof InputEdge conn2)) { return false; } - InputEdge conn2 = (InputEdge) o; - boolean result = conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to; + boolean result = conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to && conn2.listIndex == listIndex; if (result && (state == State.IMMUTABLE || conn2.state == State.IMMUTABLE)) { // Immutable instances must be exactly the same return conn2.state == state && conn2.label.equals(label); diff --git a/visualizer/IdealGraphVisualizer/Data/src/main/java/org/graalvm/visualizer/data/serialization/lazy/ScanningModelBuilder.java b/visualizer/IdealGraphVisualizer/Data/src/main/java/org/graalvm/visualizer/data/serialization/lazy/ScanningModelBuilder.java index 3a002b189500..91554e7f0716 100644 --- a/visualizer/IdealGraphVisualizer/Data/src/main/java/org/graalvm/visualizer/data/serialization/lazy/ScanningModelBuilder.java +++ b/visualizer/IdealGraphVisualizer/Data/src/main/java/org/graalvm/visualizer/data/serialization/lazy/ScanningModelBuilder.java @@ -280,20 +280,20 @@ public void makeGraphEdges() { } @Override - public InputEdge immutableEdge(char fromIndex, char toIndex, int from, int to, String label, String type) { + public InputEdge immutableEdge(char fromIndex, char toIndex, int from, int to, int listIndex, String label, String type) { return null; } @Override public void successorEdge(Port p, int from, int to, char num, int index) { - if (scanGraph) { + if (scanGraph && from >= 0) { entry.getGraphMeta().addEdge(from, to); } } @Override public void inputEdge(Port p, int from, int to, char num, int index) { - if (scanGraph) { + if (scanGraph && from >= 0) { entry.getGraphMeta().addEdge(from, to); } } diff --git a/visualizer/IdealGraphVisualizer/Difference/src/main/java/org/graalvm/visualizer/difference/Difference.java b/visualizer/IdealGraphVisualizer/Difference/src/main/java/org/graalvm/visualizer/difference/Difference.java index 118e1ddccf3f..b1698a98f47d 100644 --- a/visualizer/IdealGraphVisualizer/Difference/src/main/java/org/graalvm/visualizer/difference/Difference.java +++ b/visualizer/IdealGraphVisualizer/Difference/src/main/java/org/graalvm/visualizer/difference/Difference.java @@ -236,7 +236,7 @@ private static DiffGraph createDiff(InputGraph a, InputGraph b, DiffGraph graph, if (nodeFrom == null || nodeTo == null) { System.out.println("Unexpected edge : " + from + " -> " + to); } else { - InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId(), e.getLabel(), e.getType()); + InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId(), e.getListIndex(), e.getLabel(), e.getType()); if (!newEdges.contains(newEdge)) { markAsDeleted(newEdge); newEdges.add(newEdge); @@ -256,7 +256,7 @@ private static DiffGraph createDiff(InputGraph a, InputGraph b, DiffGraph graph, if (nodeFrom == null || nodeTo == null) { System.out.println("Unexpected edge : " + from + " -> " + to); } else { - InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId(), e.getLabel(), e.getType()); + InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId(), e.getListIndex(), e.getLabel(), e.getType()); if (!newEdges.contains(newEdge)) { markAsNew(newEdge); newEdges.add(newEdge); diff --git a/visualizer/IdealGraphVisualizer/Graph/src/main/java/org/graalvm/visualizer/graph/Diagram.java b/visualizer/IdealGraphVisualizer/Graph/src/main/java/org/graalvm/visualizer/graph/Diagram.java index 761bdcca05ba..238f619c268a 100644 --- a/visualizer/IdealGraphVisualizer/Graph/src/main/java/org/graalvm/visualizer/graph/Diagram.java +++ b/visualizer/IdealGraphVisualizer/Graph/src/main/java/org/graalvm/visualizer/graph/Diagram.java @@ -308,7 +308,7 @@ public static Diagram createDiagram(InputGraph graph, String nodeText) { assert toFigure.getInputSlots().size() >= toIndex + 1; InputSlot inputSlot = toFigure.getInputSlots().get(toIndex); - Connection c = d.createConnection(inputSlot, outputSlot, e.getLabel(), e.getType()); + Connection c = d.createConnection(inputSlot, outputSlot, e.getDisplayLabel(), e.getType()); if (e.getState() == InputEdge.State.NEW) { c.setStyle(Connection.ConnectionStyle.BOLD); diff --git a/visualizer/mx.visualizer/mx_visualizer.py b/visualizer/mx.visualizer/mx_visualizer.py index 969e95b896d1..28d87114e638 100644 --- a/visualizer/mx.visualizer/mx_visualizer.py +++ b/visualizer/mx.visualizer/mx_visualizer.py @@ -59,7 +59,7 @@ def source_dirs(self): def classpath_repr(self, resolve=True): src = os.path.join(self.dir, 'IdealGraphVisualizer', self.name, 'src') if not os.path.exists(src): - mx.abort("Cannot find {0}".format(src)) + mx.abort(f"Cannot find {src}") return src def output_dir(self, relative=False): @@ -107,7 +107,7 @@ def __init__(self, subject, args, vmbuild, vm): self.vmbuild = vmbuild def __str__(self): - return 'Building NetBeans for {}'.format(self.subject) + return f'Building NetBeans for {self.subject}' def needsBuild(self, newestInput): return (True, 'Let us re-build everytime') @@ -123,24 +123,22 @@ def build(self): lib_path = lib.classpath_repr(resolve=False) link_name = os.path.join(libs_dir, os.path.basename(lib_path)) from_path = os.path.relpath(lib_path, os.path.dirname(link_name)) - mx.log("Symlink {0}, {1}".format(from_path, link_name)) + mx.log(f"Symlink {from_path}, {link_name}") os.symlink(from_path, link_name) mx.log('Symlinks must be copied!') env = os.environ.copy() env["MAVEN_OPTS"] = "-Djava.awt.headless=true -Dpolyglot.engine.WarnInterpreterOnly=false" - mx.logv('Setting PATH to {}'.format(os.environ["PATH"])) - mx.logv('Calling java -version') - mx.run(['java', '-version']) + mx.logv(f"Setting PATH to {os.environ['PATH']}") - mx.log('Invoking maven for {} for {} in {}'.format(' '.join(self.subject.build_commands), self.subject.name, self.subject.baseDir)) + mx.log(f"Invoking maven for {' '.join(self.subject.build_commands)} for {self.subject.name} in {self.subject.baseDir}") run_maven(self.subject.build_commands, nonZeroIsFatal=True, cwd=self.subject.baseDir, env=env) for output_dir in self.subject.output_dirs: os.chmod(os.path.join(self.subject.output_dir(), output_dir, 'bin', 'idealgraphvisualizer'), 0o755) - mx.log('...finished build of {}'.format(self.subject)) + mx.log(f'...finished build of {self.subject}') def clean(self, forBuild=False): if self.subject.mxLibs: