Skip to content

Commit

Permalink
[GR-38837] [GR-52025] [GR-50265] Various minor IGV fixes
Browse files Browse the repository at this point in the history
PullRequest: graal/16855
  • Loading branch information
tkrodriguez committed Mar 14, 2024
2 parents 1bfaa67 + c142db0 commit 8f54b76
Show file tree
Hide file tree
Showing 46 changed files with 149 additions and 108 deletions.
20 changes: 15 additions & 5 deletions compiler/mx.compiler/mx_graal_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from argparse import ArgumentParser, REMAINDER

import mx
import mx_compiler

if sys.version_info[0] < 3:
_long = long # pylint: disable=undefined-variable
Expand Down Expand Up @@ -74,17 +73,28 @@ def run_netbeans_app(app_name, jdkhome, args=None, dist=None):
mx.run(launch+args)

def igv(args):
"""run the Ideal Graph Visualizer"""
dist = 'IDEALGRAPHVISUALIZER-0_31-0A82D7A0D60_DIST'
run_netbeans_app('IdealGraphVisualizer', mx_compiler.jdk.home, args=args, dist=dist)
"""run the Ideal Graph Visualizer
The current version must be run with JDK 11 as it's based on NetBeans 14 and JDK 11
is the only supported LTS release with that version.
Extra NetBeans specific options can be passed as well. mx igv --help will show the
help for NetBeans itself.
"""
v11 = mx.VersionSpec("11")
v12 = mx.VersionSpec("12")
def _igvJdkVersionCheck(version):
return v11 <= version < v12
jdkhome = mx.get_jdk(_igvJdkVersionCheck, versionDescription='(Netbeans requires JDK 11 which can be specified via EXTRA_JAVA_HOMES or --extra-java-homes)', purpose="running IGV").home
run_netbeans_app('IdealGraphVisualizer', jdkhome, args=args, dist='IDEALGRAPHVISUALIZER_DIST')

def c1visualizer(args):
"""run the C1 Compiler Visualizer"""
v8u40 = mx.VersionSpec("1.8.0_40")
v12 = mx.VersionSpec("12")
def _c1vJdkVersionCheck(version):
return v8u40 <= version < v12
jdkhome = mx.get_jdk(_c1vJdkVersionCheck, versionDescription='(JDK that is >= 1.8.0u40 and <= 11)', purpose="running C1 Visualizer").home
jdkhome = mx.get_jdk(_c1vJdkVersionCheck, versionDescription='(JDK that is >= 1.8.0u40 and <= 11 which can be specified via EXTRA_JAVA_HOMES or --extra-java-homes)', purpose="running C1 Visualizer").home
run_netbeans_app('C1Visualizer', jdkhome, args() if callable(args) else args)

def hsdis(args, copyToDir=None):
Expand Down
6 changes: 3 additions & 3 deletions compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
"digest" : "sha512:40c505dd03ca0bb102f1091b89b90672126922f290bd8370eef9a7afc5d9c1e7b5db08c448a0948ef46bf57d850e166813e2d68bf7b1c88a46256d839b6b0201",
"packedResource": True,
},
"IDEALGRAPHVISUALIZER-0_31-0A82D7A0D60_DIST" : {
"urls" : ["https://lafo.ssw.uni-linz.ac.at/pub/idealgraphvisualizer/idealgraphvisualizer-0.31-0a82d7a0d60-all.zip"],
"digest" : "sha512:20a3d87927fbecfe9b61dcd6c59f12f4c25e7da1ca926ea6d2571594424782751261e581e1c6e5113aeaeb8f31b8141b1941f7bbef1c6c07c55b9a753812b6db",
"IDEALGRAPHVISUALIZER_DIST" : {
"urls" : ["https://lafo.ssw.uni-linz.ac.at/pub/idealgraphvisualizer/idealgraphvisualizer-0.31-cb98bbf5fef-all.zip"],
"digest" : "sha512:ca30052094ce03a8ab88b4666261cfe66ee369c4e876528efd42facd98e53dea3ee1ae622dda6234cf79fe16698f2418e40f025ee859ca3534308be70a47794a",
"packedResource": True,
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,11 @@ protected void verify(StructuredGraph graph, CoreProviders context) {
throw new VerificationError("Checked callee graph %s has null method", checkedMethod);
}

if (checkedMethod.getDeclaringClass().getName().startsWith("Ljdk/graal/compiler/graphio")) {
// This package is mirrored from the visualizer so explicitly ignore it
return;
}

MethodInfo checkedMethodInfo = getMethodInfo(checkedMethod);
checkedMethodInfo.allPathsAssertionDominated = verifyAllReturnPathsReturnTrue(graph, checkedMethodInfo);
checkedMethodInfo.root = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import java.util.Objects;
import java.util.WeakHashMap;

import jdk.graal.compiler.debug.Assertions;

abstract class GraphProtocol<Graph, Node, NodeClass, Edges, Block, ResolvedJavaMethod, ResolvedJavaField, Signature, NodeSourcePosition, Location> implements Closeable {
private static final Charset UTF8 = Charset.forName("UTF-8");

Expand Down Expand Up @@ -577,7 +575,9 @@ private void writeEdges(Graph graph, Node node, boolean dumpInputs) throws IOExc
writeShort((char) 0);
} else {
int listSize = list.size();
assert listSize == ((char) listSize) : Assertions.errorMessage(listSize);
if (listSize != ((char) listSize)) {
throw new IOException("Too many nodes in list: " + list.size());
}
writeShort((char) listSize);
for (Node edge : list) {
writeNodeRef(edge);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void approveSelection() {
FileImporter.asyncImportDocument(file.toPath(), true, true, null);
} catch (IOException ex) {
Exceptions.printStackTrace(
Exceptions.attachLocalizedMessage(ex, Bundle.ERR_OpeningFile(file.toPath(), ex.getLocalizedMessage()))
Exceptions.attachLocalizedMessage(ex, Bundle.ERR_OpeningFile(file.toPath(), ex.toString()))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public void save() {
// no op }
} catch (IOException ex) {
DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(
Bundle.ERR_Save(ex.getLocalizedMessage()),
Bundle.ERR_Save(ex.toString()),
NotifyDescriptor.ERROR_MESSAGE));
}
}
Expand Down Expand Up @@ -626,7 +626,7 @@ public void run() {
f.delete();
} else {
DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(
Bundle.ERR_Save(e.getLocalizedMessage()),
Bundle.ERR_Save(e.toString()),
NotifyDescriptor.ERROR_MESSAGE));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void importPrimaryFile() {
FileImporter.asyncImportDocument(f.toPath(), true, true, null);
} catch (IOException ex) {
Exceptions.printStackTrace(
Exceptions.attachLocalizedMessage(ex, Bundle.ERR_OpeningFile(f.toPath(), ex.getLocalizedMessage()))
Exceptions.attachLocalizedMessage(ex, Bundle.ERR_OpeningFile(f.toPath(), ex.toString()))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private static void reportException(Path path, Throwable ex) {
NotifyDescriptor.INFORMATION_MESSAGE));
} else {
Exceptions.printStackTrace(
Exceptions.attachLocalizedMessage(ex, Bundle.ERR_ReadingFile(path, ex.getLocalizedMessage()))
Exceptions.attachLocalizedMessage(ex, Bundle.ERR_ReadingFile(path, ex.toString()))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

import java.util.Collection;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

final class DefaultGraphTypes implements GraphTypes {
static final GraphTypes DEFAULT = new DefaultGraphTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

/**
* Representation of methods, fields, their signatures and code locations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* questions.
*/

package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

import java.io.File;
import java.io.FileOutputStream;
Expand All @@ -38,7 +38,7 @@
final class GraphJavadocSnippets {
static GraphStructure<AcmeGraph, AcmeNode, AcmeNodeType, AcmePorts> acmeGraphStructure() {
// @formatter:off
// BEGIN: org.graalvm.graphio.GraphJavadocSnippets#acmeGraphStructure
// BEGIN: jdk.graal.compiler.graphio.GraphJavadocSnippets#acmeGraphStructure
class AcmeGraphStructure implements
GraphStructure<AcmeGraph, AcmeNode, AcmeNodeType, AcmePorts> {

Expand Down Expand Up @@ -142,22 +142,22 @@ public Collection<? extends AcmeNode> edgeNodes(
}
}

// END: org.graalvm.graphio.GraphJavadocSnippets#acmeGraphStructure
// END: jdk.graal.compiler.graphio.GraphJavadocSnippets#acmeGraphStructure

return new AcmeGraphStructure();
}

// BEGIN: org.graalvm.graphio.GraphJavadocSnippets#buildOutput
// BEGIN: jdk.graal.compiler.graphio.GraphJavadocSnippets#buildOutput
static GraphOutput<AcmeGraph, ?> buildOutput(WritableByteChannel channel)
throws IOException {
return GraphOutput.newBuilder(acmeGraphStructure()).
// use the latest version; currently 6.0
protocolVersion(6, 0).
build(channel);
}
// END: org.graalvm.graphio.GraphJavadocSnippets#buildOutput
// END: jdk.graal.compiler.graphio.GraphJavadocSnippets#buildOutput

// BEGIN: org.graalvm.graphio.GraphJavadocSnippets#buildAll
// BEGIN: jdk.graal.compiler.graphio.GraphJavadocSnippets#buildAll
static GraphOutput<AcmeGraph, ?> buildAll(WritableByteChannel channel)
throws IOException {
GraphBlocks<AcmeGraph, AcmeBlocks, AcmeNode> graphBlocks = acmeBlocks();
Expand All @@ -172,7 +172,7 @@ public Collection<? extends AcmeNode> edgeNodes(
types(graphTypes).
build(channel);
}
// END: org.graalvm.graphio.GraphJavadocSnippets#buildAll
// END: jdk.graal.compiler.graphio.GraphJavadocSnippets#buildAll

private static GraphTypes acmeTypes() {
GraphTypes graphTypes = null;
Expand Down Expand Up @@ -259,7 +259,7 @@ private static class AcmeSignature {
private static class AcmeCodePosition {
}

// BEGIN: org.graalvm.graphio.GraphJavadocSnippets#dump
// BEGIN: jdk.graal.compiler.graphio.GraphJavadocSnippets#dump
static void dump(File toFile) throws IOException {
try (
FileChannel ch = new FileOutputStream(toFile).getChannel();
Expand All @@ -282,6 +282,6 @@ static void dump(File toFile) throws IOException {
output.endGroup();
}
}
// END: org.graalvm.graphio.GraphJavadocSnippets#dump
// END: jdk.graal.compiler.graphio.GraphJavadocSnippets#dump

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

import java.net.URI;
import java.net.URISyntaxException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

import java.io.Closeable;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -575,7 +575,9 @@ private void writeEdges(Graph graph, Node node, boolean dumpInputs) throws IOExc
writeShort((char) 0);
} else {
int listSize = list.size();
assert listSize == ((char) listSize);
if (listSize != ((char) listSize)) {
throw new IOException("Too many nodes in list: " + list.size());
}
writeShort((char) listSize);
for (Node edge : list) {
writeNodeRef(edge);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

import java.util.Collection;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

/**
* Special support for dealing with enums. Normally one can represent various {@link GraphOutput
* graph} enum values with real {@link Enum} instances. In case this is not possible, the
* {@link GraphOutput.Builder} allows one to
* {@link GraphOutput.Builder#types(org.graalvm.graphio.GraphTypes) register} an implementation of
* this interface to treat them specially.
* {@link GraphOutput.Builder} allows one to {@link GraphOutput.Builder#types(GraphTypes) register}
* an implementation of this interface to treat them specially.
*/
public interface GraphTypes {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,33 @@
* Send your graphs to <b>IGV</b> via a socket or a file. This package allows one to easily encode
* any graph-like data structure and send it for visualization to <em>OracleLab's Ideal Graph
* Visualizer</em> tool. Assuming you already have your own data structure that contains
* <b>nodes</b> and <b>edges</b> among them, creating a {@link org.graalvm.graphio.GraphOutput}
* specialized for your data is a matter of implementing a single interface:
* <b>nodes</b> and <b>edges</b> among them, creating a
* {@link jdk.graal.compiler.graphio.GraphOutput} specialized for your data is a matter of
* implementing a single interface:
*
* {@link org.graalvm.graphio.GraphJavadocSnippets#acmeGraphStructure}
* {@link jdk.graal.compiler.graphio.GraphJavadocSnippets#acmeGraphStructure}
*
* The {@link org.graalvm.graphio.GraphStructure} interface defines the set of operations that are
* needed by the <em>graph protocol</em> to encode a graph into the <b>IGV</b> expected format. The
* graph structure is implemented as a so called
* The {@link jdk.graal.compiler.graphio.GraphStructure} interface defines the set of operations
* that are needed by the <em>graph protocol</em> to encode a graph into the <b>IGV</b> expected
* format. The graph structure is implemented as a so called
* <a href="http://wiki.apidesign.org/wiki/Singletonizer">singletonizer</a> API pattern: there is no
* need to change your data structures or implement some special interfaces - everything needed is
* provided by implementing the {@link org.graalvm.graphio.GraphStructure} operations.
* provided by implementing the {@link jdk.graal.compiler.graphio.GraphStructure} operations.
* <p>
* The next step is to turn this graph structure into an instance of
* {@link org.graalvm.graphio.GraphOutput}. To do so use the associated
* {@link org.graalvm.graphio.GraphOutput.Builder builder} just like shown in the following method:
* {@link jdk.graal.compiler.graphio.GraphOutput}. To do so use the associated
* {@link jdk.graal.compiler.graphio.GraphOutput.Builder builder} just like shown in the following
* method:
*
* {@link org.graalvm.graphio.GraphJavadocSnippets#buildOutput}
* {@link jdk.graal.compiler.graphio.GraphJavadocSnippets#buildOutput}
*
* Now you are ready to dump your graph into <b>IGV</b>. Where to obtain the right channel? One
* option is to create a {@link java.nio.channels.FileChannel} and dump the data into a file
* (preferrably with <code>.bgv</code> extension). The other is to open a socket to port
* <code>4445</code> (the default port <b>IGV</b> listens to) and dump the data there. Here is an
* example:
*
* {@link org.graalvm.graphio.GraphJavadocSnippets#dump}
* {@link jdk.graal.compiler.graphio.GraphJavadocSnippets#dump}
*
* Call the {@code dump} method with pointer to file {@code diamond.bgv} and then you can open the
* file in <b>IGV</b>. The result will look like this:
Expand All @@ -65,22 +67,23 @@
* The primary <b>IGV</b> focus is on graphs used by the compiler. As such they aren't plain graphs,
* but contain various compiler oriented attributes:
* <ul>
* <li>{@linkplain org.graalvm.graphio.GraphBlocks code blocks} information</li>
* <li>{@linkplain org.graalvm.graphio.GraphElements method and fields} information</li>
* <li>Advanced support for {@linkplain org.graalvm.graphio.GraphTypes recognizing types}</li>
* <li>{@linkplain jdk.graal.compiler.graphio.GraphBlocks code blocks} information</li>
* <li>{@linkplain jdk.graal.compiler.graphio.GraphElements method and fields} information</li>
* <li>Advanced support for {@linkplain jdk.graal.compiler.graphio.GraphTypes recognizing
* types}</li>
* </ul>
* all these additional interfaces ({@link org.graalvm.graphio.GraphBlocks},
* {@link org.graalvm.graphio.GraphElements} and {@link org.graalvm.graphio.GraphTypes}) are
* optional - they don't have to be provided. As such they can be specified via
* {@link org.graalvm.graphio.GraphOutput.Builder} instance methods, which may, but need not be
* called at all. Here is an example:
* all these additional interfaces ({@link jdk.graal.compiler.graphio.GraphBlocks},
* {@link jdk.graal.compiler.graphio.GraphElements} and
* {@link jdk.graal.compiler.graphio.GraphTypes}) are optional - they don't have to be provided. As
* such they can be specified via {@link jdk.graal.compiler.graphio.GraphOutput.Builder} instance
* methods, which may, but need not be called at all. Here is an example:
*
* {@link org.graalvm.graphio.GraphJavadocSnippets#buildAll}
* {@link jdk.graal.compiler.graphio.GraphJavadocSnippets#buildAll}
*
* All these interfaces follow the
* <a href="http://wiki.apidesign.org/wiki/Singletonizer">singletonizer</a> API pattern again - e.g.
* no need to change your existing data structures, just implement the operations provided by the
* interfaces you pass into the builder. By combining these interfaces together you can get as rich,
* colorful, source linked graphs as the compiler produces to describe its optimizations.
*/
package org.graalvm.graphio;
package jdk.graal.compiler.graphio;
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ private void reportLoadingError(String message) {
throw new IllegalStateException(ex);
}
if (lastName != null) {
message = Bundle.MSG_ErrorsWithPreceding(message, lastName);
message = Bundle.MSG_ErrorsWithPreceding(message, lastName.get());
}
builder.reportLoadingError(message, parents);
}
Expand Down
Loading

0 comments on commit 8f54b76

Please sign in to comment.