changeset 21407:36285949c1d5

Truffle/Instrumentation: some commentary and a new AST printing method needed for tools.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Sun, 17 May 2015 20:35:31 -0700
parents b4aca5ec3f10
children 32ca2353accf
files graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTPrinter.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java
diffstat 3 files changed, 35 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);
 }
--- 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 <em>Advanced Instrument</em>: this Instrument executes efficiently, subject to
      * full Truffle optimization, a client-provided AST fragment every time the Probed node is
      * entered.
+     * <p>
+     * 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
--- 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");