diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java @ 21686:5fa7935c5de3

Truffle/Instrumentation: fix the small tool demonstration in SL
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 02 Jun 2015 17:41:19 -0700
parents 1c76a5662753
children ed234a3178af
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Tue Jun 02 17:11:48 2015 -0700
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Tue Jun 02 17:41:19 2015 -0700
@@ -139,11 +139,6 @@
     private static List<NodeFactory<? extends SLBuiltinNode>> builtins = Collections.emptyList();
     private final SLContext context;
 
-    /* Small tools that can be demonstrated */
-    NodeExecCounter nodeExecCounter = null;
-    NodeExecCounter statementExecCounter = null;
-    CoverageTracker coverageTracker = null;
-
     public SLMain(Env env) {
         super(env);
         context = SLContextFactory.create(new BufferedReader(env().stdIn()), new PrintWriter(env().stdOut(), true));
@@ -153,23 +148,27 @@
         }
     }
 
-    /* Demonstrate per-type tabulation of node execution counts */
+    /* Enables demonstration of per-type tabulation of node execution counts */
     private static boolean nodeExecCounts = false;
-    /* Demonstrate per-line tabulation of STATEMENT node execution counts */
+    /* Enables demonstration of per-line tabulation of STATEMENT node execution counts */
     private static boolean statementCounts = false;
-    /* Demonstrate per-line tabulation of STATEMENT coverage */
+    /* Enables demonstration of er-line tabulation of STATEMENT coverage */
     private static boolean coverage = false;
 
+    /* Small tools that can be installed for demonstration */
+    private static NodeExecCounter nodeExecCounter = null;
+    private static NodeExecCounter statementExecCounter = null;
+    private static CoverageTracker coverageTracker = null;
+
     /**
      * The main entry point. Use the mx command "mx sl" to run it with the correct class path setup.
-     * <p>
-     * Obsolete: being replaced with new TruffleLanguage API
      */
-    @Deprecated
     public static void main(String[] args) throws IOException {
         TruffleVM vm = TruffleVM.newVM().build();
         assert vm.getLanguages().containsKey("application/x-sl");
 
+        setupToolDemos();
+
         int repeats = 1;
         if (args.length >= 2) {
             repeats = Integer.parseInt(args[1]);
@@ -187,6 +186,7 @@
         while (repeats-- > 0) {
             main.invoke(null);
         }
+        reportToolDemos();
     }
 
     /**
@@ -359,10 +359,7 @@
 
     @Override
     protected Object eval(Source code) throws IOException {
-
-        setupToolDemos();
         context.executeMain(code);
-        reportToolDemos();
         return null;
     }
 
@@ -386,7 +383,7 @@
         return object instanceof SLFunction;
     }
 
-    private void setupToolDemos() {
+    private static void setupToolDemos() {
         if (statementCounts || coverage) {
             Probe.registerASTProber(new SLStandardASTProber());
         }
@@ -406,7 +403,7 @@
         }
     }
 
-    private void reportToolDemos() {
+    private static void reportToolDemos() {
         if (nodeExecCounter != null) {
             nodeExecCounter.print(System.out);
             nodeExecCounter.dispose();