changeset 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 fd8a92655fbd
children afea1d08c393
files graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/SymbolInvokerImpl.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java
diffstat 2 files changed, 14 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/SymbolInvokerImpl.java	Tue Jun 02 17:11:48 2015 -0700
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/SymbolInvokerImpl.java	Tue Jun 02 17:41:19 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
@@ -29,7 +29,6 @@
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.impl.*;
-import com.oracle.truffle.api.instrument.*;
 import com.oracle.truffle.api.interop.*;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.interop.messages.*;
@@ -58,11 +57,6 @@
         }
 
         @Override
-        public void applyInstrumentation() {
-            Probe.applyASTProbers(foreignAccess);
-        }
-
-        @Override
         public Object execute(VirtualFrame frame) {
             return foreignAccess.executeForeign(frame, function, args);
         }
--- 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();