Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java @ 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 | 64c77f0577bb |
children | afd6fa5e8229 |
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); }