Skip to content

Commit edb42d7

Browse files
robcaslozchhagedorn
andcommitted
8282547: IGV: add control-flow graph view
Co-authored-by: Christian Hagedorn <chagedorn@openjdk.org> Reviewed-by: chagedorn, xliu, thartmann
1 parent 7418373 commit edb42d7

File tree

70 files changed

+2091
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2091
-507
lines changed

src/utils/IdealGraphVisualizer/ControlFlow/src/main/java/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
2626
import com.sun.hotspot.igv.data.InputBlockEdge;
2727
import com.sun.hotspot.igv.layout.Link;
2828
import com.sun.hotspot.igv.layout.Port;
29+
import com.sun.hotspot.igv.layout.Cluster;
2930
import java.awt.BasicStroke;
3031
import java.awt.Point;
3132
import java.awt.Stroke;
@@ -76,6 +77,14 @@ public Port getFrom() {
7677
return outputSlot;
7778
}
7879

80+
public Cluster getFromCluster() {
81+
return null;
82+
}
83+
84+
public Cluster getToCluster() {
85+
return null;
86+
}
87+
7988
public void setBold(boolean bold) {
8089
this.isBold = bold;
8190
updateStroke();

src/utils/IdealGraphVisualizer/ControlFlow/src/main/java/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -69,6 +69,14 @@ public Port getTo() {
6969
return to.getSlot();
7070
}
7171

72+
public Cluster getFromCluster() {
73+
return null;
74+
}
75+
76+
public Cluster getToCluster() {
77+
return null;
78+
}
79+
7280
public List<Point> getControlPoints() {
7381
return new ArrayList<Point>();
7482
}

src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/InputBlock.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@ public class InputBlock {
3535
private String name;
3636
private InputGraph graph;
3737
private Set<InputBlock> successors;
38+
private boolean artificial;
3839

3940
@Override
4041
public int hashCode() {
@@ -77,6 +78,7 @@ public boolean equals(Object o) {
7778
this.name = name;
7879
nodes = new ArrayList<>();
7980
successors = new LinkedHashSet<>(2);
81+
artificial = false;
8082
}
8183

8284
public String getName() {
@@ -101,6 +103,10 @@ public Set<InputBlock> getSuccessors() {
101103
return Collections.unmodifiableSet(successors);
102104
}
103105

106+
public void setNodes(List<InputNode> nodes) {
107+
this.nodes = nodes;
108+
}
109+
104110
@Override
105111
public String toString() {
106112
return "Block " + this.getName();
@@ -111,4 +117,12 @@ void addSuccessor(InputBlock b) {
111117
successors.add(b);
112118
}
113119
}
120+
121+
void setArtificial(boolean artificial) {
122+
this.artificial = artificial;
123+
}
124+
125+
public boolean isArtificial() {
126+
return artificial;
127+
}
114128
}

src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/InputBlockEdge.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -38,12 +38,14 @@ public enum State {
3838
private InputBlock from;
3939
private InputBlock to;
4040
private State state = State.SAME;
41+
private String label;
4142

42-
public InputBlockEdge(InputBlock from, InputBlock to) {
43+
public InputBlockEdge(InputBlock from, InputBlock to, String label) {
4344
assert from != null;
4445
assert to != null;
4546
this.from = from;
4647
this.to = to;
48+
this.label = label;
4749
}
4850

4951
public InputBlock getFrom() {
@@ -62,6 +64,10 @@ public void setState(State state) {
6264
this.state = state;
6365
}
6466

67+
public String getLabel() {
68+
return label;
69+
}
70+
6571
@Override
6672
public boolean equals(Object obj) {
6773
if (obj != null && obj instanceof InputBlockEdge) {

src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/InputGraph.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,11 @@ public void setParent(Folder parent) {
5858
}
5959

6060
public InputBlockEdge addBlockEdge(InputBlock left, InputBlock right) {
61-
InputBlockEdge edge = new InputBlockEdge(left, right);
61+
return addBlockEdge(left, right, null);
62+
}
63+
64+
public InputBlockEdge addBlockEdge(InputBlock left, InputBlock right, String label) {
65+
InputBlockEdge edge = new InputBlockEdge(left, right, label);
6266
blockEdges.add(edge);
6367
left.addSuccessor(right);
6468
return edge;
@@ -140,6 +144,7 @@ public List<InputEdge> findOutgoingEdges(InputNode n) {
140144

141145
public void clearBlocks() {
142146
blocks.clear();
147+
blockEdges.clear();
143148
nodeToBlock.clear();
144149
}
145150

@@ -168,7 +173,7 @@ public void ensureNodesInBlocks() {
168173
assert nodes.get(n.getId()) == n;
169174
if (!scheduledNodes.contains(n)) {
170175
if (noBlock == null) {
171-
noBlock = this.addBlock("(no block)");
176+
noBlock = addArtificialBlock();
172177
}
173178
noBlock.addNode(n.getId());
174179
}
@@ -270,6 +275,12 @@ public String toString() {
270275
return sb.toString();
271276
}
272277

278+
public InputBlock addArtificialBlock() {
279+
InputBlock b = addBlock("(no block)");
280+
b.setArtificial(true);
281+
return b;
282+
}
283+
273284
public InputBlock addBlock(String name) {
274285
final InputBlock b = new InputBlock(this, name);
275286
blocks.put(b.getName(), b);

src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/serialization/Parser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -261,7 +261,7 @@ protected void end(String text) throws SAXException {
261261
for (InputNode n : graph.getNodes()) {
262262
if (graph.getBlock(n) == null) {
263263
if (noBlock == null) {
264-
noBlock = graph.addBlock("(no block)");
264+
noBlock = graph.addArtificialBlock();
265265
}
266266

267267
noBlock.addNode(n.getId());

src/utils/IdealGraphVisualizer/Filter/src/main/java/com/sun/hotspot/igv/filter/ColorFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -78,7 +78,7 @@ private void applyRule(ColorRule rule, Figure f) {
7878
ConnectionStyle style = rule.getLineStyle();
7979

8080
for (OutputSlot s : f.getOutputSlots()) {
81-
for (Connection c : s.getConnections()) {
81+
for (FigureConnection c : s.getConnections()) {
8282
if (color != null) {
8383
c.setColor(color);
8484
}

src/utils/IdealGraphVisualizer/Filter/src/main/java/com/sun/hotspot/igv/filter/CombineFilter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@ public void apply(Diagram diagram) {
6767
InputSlot slot = null;
6868

6969
for (InputSlot s : succ.getInputSlots()) {
70-
for (Connection c : s.getConnections()) {
70+
for (FigureConnection c : s.getConnections()) {
7171
if (c.getOutputSlot().getFigure() == f) {
7272
slot = s;
7373
}
@@ -97,8 +97,8 @@ public void apply(Diagram diagram) {
9797
}
9898

9999
for (InputSlot s : f.getInputSlots()) {
100-
for (Connection c : s.getConnections()) {
101-
Connection newConn = diagram.createConnection(slot, c.getOutputSlot(), c.getLabel(), c.getType());
100+
for (FigureConnection c : s.getConnections()) {
101+
FigureConnection newConn = diagram.createConnection(slot, c.getOutputSlot(), c.getLabel());
102102
newConn.setColor(c.getColor());
103103
newConn.setStyle(c.getStyle());
104104
}
@@ -115,7 +115,7 @@ public void apply(Diagram diagram) {
115115

116116
OutputSlot oldSlot = null;
117117
for (OutputSlot s : f.getOutputSlots()) {
118-
for (Connection c : s.getConnections()) {
118+
for (FigureConnection c : s.getConnections()) {
119119
if (c.getInputSlot().getFigure() == succ) {
120120
oldSlot = s;
121121
}
@@ -155,8 +155,8 @@ public void apply(Diagram diagram) {
155155
}
156156
}
157157
}
158-
for (Connection c : nextSlot.getConnections()) {
159-
Connection newConn = diagram.createConnection(c.getInputSlot(), slot, c.getLabel(), c.getType());
158+
for (FigureConnection c : nextSlot.getConnections()) {
159+
FigureConnection newConn = diagram.createConnection(c.getInputSlot(), slot, c.getLabel());
160160
newConn.setColor(c.getColor());
161161
newConn.setStyle(c.getStyle());
162162
}

src/utils/IdealGraphVisualizer/Filter/src/main/java/com/sun/hotspot/igv/filter/ConnectionFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@ public void apply(Diagram diagram) {
6262

6363
for (Figure f : figures) {
6464
for (OutputSlot os : f.getOutputSlots()) {
65-
for (Connection c : os.getConnections()) {
65+
for (FigureConnection c : os.getConnections()) {
6666
c.setStyle(rule.getLineStyle());
6767
c.setColor(rule.getLineColor());
6868
}

src/utils/IdealGraphVisualizer/Filter/src/main/java/com/sun/hotspot/igv/filter/EdgeColorIndexFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,7 @@ public void apply(Diagram d) {
6464
for (Slot slot : slots) {
6565
if (index < colors.length && colors[index] != null) {
6666
slot.setColor(colors[index]);
67-
for (Connection c : slot.getConnections()) {
67+
for (FigureConnection c : slot.getConnections()) {
6868

6969
c.setColor(colors[index]);
7070
}

0 commit comments

Comments
 (0)