# HG changeset patch # User Christian Humer # Date 1391457671 -3600 # Node ID f9b934e1e172c1e6be9c2013fc8bed4b3afa3460 # Parent 28479abd1a69c4e6def042f68b802b7bbe0a22bb SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV. diff -r 28479abd1a69 -r f9b934e1e172 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java --- 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); } diff -r 28479abd1a69 -r f9b934e1e172 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLCallNode.java --- 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()); } } } diff -r 28479abd1a69 -r f9b934e1e172 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java --- 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()); } } } diff -r 28479abd1a69 -r f9b934e1e172 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java --- 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()); } } }