changeset 13862:f9b934e1e172

SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
author Christian Humer <christian.humer@gmail.com>
date Mon, 03 Feb 2014 21:01:11 +0100
parents 28479abd1a69
children 88026f1d51e4
files graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLCallNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java
diffstat 4 files changed, 30 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Mon Feb 03 20:59:57 2014 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Mon Feb 03 21:01:11 2014 +0100
@@ -154,8 +154,10 @@
 
         /* Change to true if you want to see the AST on the console. */
         boolean printASTToLog = false;
+        /* Change to dump the AST to IGV over the network. */
+        boolean dumpASTToIGV = false;
 
-        printScript("before execution", context, logOutput, printASTToLog);
+        printScript("before execution", context, logOutput, printASTToLog, dumpASTToIGV);
         try {
             for (int i = 0; i < repeats; i++) {
                 long start = System.nanoTime();
@@ -176,7 +178,7 @@
             }
 
         } finally {
-            printScript("after execution", context, logOutput, printASTToLog);
+            printScript("after execution", context, logOutput, printASTToLog, dumpASTToIGV);
         }
     }
 
@@ -184,21 +186,27 @@
      * Dumps the AST of all functions to the IGV visualizer, via a socket connection. IGV can be
      * started with the mx command "mx igv". Optionally, also prints the ASTs to the console.
      */
-    private static void printScript(String groupName, SLContext context, PrintStream logOutput, boolean printASTToLog) {
-        GraphPrintVisitor graphPrinter = new GraphPrintVisitor();
-        graphPrinter.beginGroup(groupName);
-        for (SLFunction function : context.getFunctionRegistry().getFunctions()) {
-            RootCallTarget callTarget = function.getCallTarget();
-            if (callTarget != null) {
-                graphPrinter.beginGraph(function.toString()).visit(callTarget.getRootNode());
-
-                if (logOutput != null && printASTToLog) {
+    private static void printScript(String groupName, SLContext context, PrintStream logOutput, boolean printASTToLog, boolean dumpASTToIGV) {
+        if (dumpASTToIGV) {
+            GraphPrintVisitor graphPrinter = new GraphPrintVisitor();
+            graphPrinter.beginGroup(groupName);
+            for (SLFunction function : context.getFunctionRegistry().getFunctions()) {
+                RootCallTarget callTarget = function.getCallTarget();
+                if (callTarget != null) {
+                    graphPrinter.beginGraph(function.toString()).visit(callTarget.getRootNode());
+                }
+            }
+            graphPrinter.printToNetwork(true);
+        }
+        if (printASTToLog && logOutput != null) {
+            for (SLFunction function : context.getFunctionRegistry().getFunctions()) {
+                RootCallTarget callTarget = function.getCallTarget();
+                if (callTarget != null) {
                     logOutput.println("=== " + function);
                     NodeUtil.printTree(logOutput, callTarget.getRootNode());
                 }
             }
         }
-        graphPrinter.printToNetwork(true);
     }
 
     /**
@@ -223,8 +231,10 @@
         result.append(" not defined for");
 
         String sep = " ";
-        for (Object value : ex.getSuppliedValues()) {
-            if (value != null) {
+        for (int i = 0; i < ex.getSuppliedValues().length; i++) {
+            Object value = ex.getSuppliedValues()[i];
+            Node node = ex.getSuppliedNodes()[i];
+            if (node != null) {
                 result.append(sep);
                 sep = ", ";
 
@@ -238,6 +248,9 @@
                     result.append("Function ").append(value);
                 } else if (value == SLNull.SINGLETON) {
                     result.append("NULL");
+                } else if (value == null) {
+                    // value is not evaluated because of short circuit evaluation
+                    result.append("ANY");
                 } else {
                     result.append(value);
                 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLCallNode.java	Mon Feb 03 20:59:57 2014 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLCallNode.java	Mon Feb 03 21:01:11 2014 +0100
@@ -79,7 +79,7 @@
              * program. We report it with the same exception that Truffle DSL generated nodes use to
              * report type errors.
              */
-            throw new UnsupportedSpecializationException(this, ex.getResult());
+            throw new UnsupportedSpecializationException(this, new Node[]{functionNode}, ex.getResult());
         }
     }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java	Mon Feb 03 20:59:57 2014 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java	Mon Feb 03 21:01:11 2014 +0100
@@ -92,7 +92,7 @@
              * program. We report it with the same exception that Truffle DSL generated nodes use to
              * report type errors.
              */
-            throw new UnsupportedSpecializationException(this, ex.getResult());
+            throw new UnsupportedSpecializationException(this, new Node[]{conditionNode}, ex.getResult());
         }
     }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java	Mon Feb 03 20:59:57 2014 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java	Mon Feb 03 21:01:11 2014 +0100
@@ -107,7 +107,7 @@
              * program. We report it with the same exception that Truffle DSL generated nodes use to
              * report type errors.
              */
-            throw new UnsupportedSpecializationException(this, ex.getResult());
+            throw new UnsupportedSpecializationException(this, new Node[]{conditionNode}, ex.getResult());
         }
     }
 }