# HG changeset patch # User Michael Van De Vanter # Date 1431920131 25200 # Node ID 36285949c1d5c41dd725623e83f8285006d048e1 # Parent b4aca5ec3f10a3e160d6fa48588241675153bbb0 Truffle/Instrumentation: some commentary and a new AST printing method needed for tools. diff -r b4aca5ec3f10 -r 36285949c1d5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTPrinter.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTPrinter.java Sun May 17 18:30:43 2015 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTPrinter.java Sun May 17 20:35:31 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. 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 @@ -63,4 +63,9 @@ */ String printTreeToString(Node node, int maxDepth); + /** + * Creates a textual display describing a single (non-wrapper) node, including instrumentation + * status: if Probed, and any tags. + */ + String printNodeWithInstrumentation(Node node); } diff -r b4aca5ec3f10 -r 36285949c1d5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java Sun May 17 18:30:43 2015 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java Sun May 17 20:35:31 2015 -0700 @@ -130,6 +130,9 @@ * Creates an Advanced Instrument: this Instrument executes efficiently, subject to * full Truffle optimization, a client-provided AST fragment every time the Probed node is * entered. + *

+ * Any {@link RuntimeException} thrown by execution of the fragment is caught by the framework + * and reported to the listener; there is no other notification. * * @param resultListener optional client callback for results/failure notification * @param rootFactory provider of AST fragments on behalf of the client diff -r b4aca5ec3f10 -r 36285949c1d5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java Sun May 17 18:30:43 2015 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java Sun May 17 20:35:31 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. 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 @@ -28,6 +28,7 @@ import java.util.*; import com.oracle.truffle.api.instrument.*; +import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind; import com.oracle.truffle.api.source.*; @@ -56,6 +57,30 @@ return printTreeToString(node, maxDepth, null); } + public String printNodeWithInstrumentation(Node node) { + final StringBuilder sb = new StringBuilder(); + if (node == null) { + sb.append("null"); + } else { + sb.append(nodeName(node)); + sb.append("("); + if (node instanceof InstrumentationNode) { + sb.append(instrumentInfo((InstrumentationNode) node)); + } + sb.append(sourceInfo(node)); + + sb.append(NodeUtil.printSyntaxTags(node)); + sb.append(")"); + } + final Node parent = node.getParent(); + if (parent instanceof WrapperNode) { + final WrapperNode wrapper = (WrapperNode) parent; + sb.append(" Probed"); + sb.append(NodeUtil.printSyntaxTags(wrapper)); + } + return sb.toString(); + } + protected void printTree(PrintWriter p, Node node, int maxDepth, Node markNode, int level) { if (node == null) { p.print("null");