changeset 21688:889b45a0dedd

Merge with c74d3c9b9de7f007fe4339b987973830131ad0fe
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 02 Jun 2015 21:15:59 -0700
parents afea1d08c393 (diff) c74d3c9b9de7 (current diff)
children ed234a3178af
files
diffstat 4 files changed, 44 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java	Tue Jun 02 18:25:16 2015 -0700
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java	Tue Jun 02 21:15:59 2015 -0700
@@ -24,6 +24,7 @@
  */
 package com.oracle.truffle.api.instrument;
 
+import java.io.*;
 import java.lang.ref.*;
 import java.util.*;
 
@@ -100,6 +101,16 @@
  */
 public final class Probe {
 
+    private static final boolean TRACE = false;
+    private static final String TRACE_PREFIX = "PROBE: ";
+    private static final PrintStream OUT = System.out;
+
+    private static void trace(String format, Object... args) {
+        if (TRACE) {
+            OUT.println(TRACE_PREFIX + String.format(format, args));
+        }
+    }
+
     private static final List<ASTProber> astProbers = new ArrayList<>();
 
     private static final List<ProbeListener> probeListeners = new ArrayList<>();
@@ -162,8 +173,17 @@
      */
     public static void applyASTProbers(Node node) {
 
+        String name = "<?>";
         final Source source = findSource(node);
-
+        if (source != null) {
+            name = source.getShortName();
+        } else {
+            final SourceSection sourceSection = node.getEncapsulatingSourceSection();
+            if (sourceSection != null) {
+                name = sourceSection.getShortDescription();
+            }
+        }
+        trace("START %s", name);
         for (ProbeListener listener : probeListeners) {
             listener.startASTProbing(source);
         }
@@ -173,6 +193,7 @@
         for (ProbeListener listener : probeListeners) {
             listener.endASTProbing(source);
         }
+        trace("FINISHED %s", name);
     }
 
     /**
@@ -286,6 +307,10 @@
         this.sourceSection = sourceSection;
         probes.add(new WeakReference<>(this));
         registerProbeNodeClone(probeNode);
+        if (TRACE) {
+            final String location = this.sourceSection == null ? "<unknown>" : sourceSection.getShortDescription();
+            trace("ADDED %s %s %s", "Probe@", location, getTagsDescription());
+        }
         for (ProbeListener listener : probeListeners) {
             listener.newProbeInserted(this);
         }
@@ -332,6 +357,9 @@
             if (tagTrapsChanged) {
                 invalidateProbeUnchanged();
             }
+            if (TRACE) {
+                trace("TAGGED as %s: %s", tag, getShortDescription());
+            }
         }
     }
 
--- a/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/SymbolInvokerImpl.java	Tue Jun 02 18:25:16 2015 -0700
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/SymbolInvokerImpl.java	Tue Jun 02 21:15:59 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 18:25:16 2015 -0700
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Tue Jun 02 21:15:59 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();
--- a/graal/com.oracle.truffle.tools.debug.engine/src/com/oracle/truffle/tools/debug/engine/DebugEngine.java	Tue Jun 02 18:25:16 2015 -0700
+++ b/graal/com.oracle.truffle.tools.debug.engine/src/com/oracle/truffle/tools/debug/engine/DebugEngine.java	Tue Jun 02 21:15:59 2015 -0700
@@ -41,7 +41,6 @@
 public final class DebugEngine {
 
     private static final boolean TRACE = false;
-    private static final boolean TRACE_PROBES = false;
     private static final String TRACE_PREFIX = "DEBUG ENGINE: ";
 
     private static final PrintStream OUT = System.out;
@@ -49,9 +48,8 @@
     private static final SyntaxTag STEPPING_TAG = StandardSyntaxTag.STATEMENT;
     private static final SyntaxTag CALL_TAG = StandardSyntaxTag.CALL;
 
-    @SuppressWarnings("unused")
     private static void trace(String format, Object... args) {
-        if (TRACE || TRACE_PROBES) {
+        if (TRACE) {
             OUT.println(TRACE_PREFIX + String.format(format, args));
         }
     }
@@ -151,38 +149,6 @@
         this.lineBreaks = new LineBreakpointFactory(sourceExecutionProvider, breakpointCallback, warningLog);
 
         this.tagBreaks = new TagBreakpointFactory(sourceExecutionProvider, breakpointCallback, warningLog);
-
-        if (TRACE_PROBES) {
-            Probe.addProbeListener(new ProbeListener() {
-
-                private Source beingProbed = null;
-
-                @Override
-                public void startASTProbing(Source source) {
-                    final String sourceName = source == null ? "<?>" : source.getShortName();
-                    trace("START PROBING %s", sourceName);
-                    beingProbed = source;
-                }
-
-                @Override
-                public void newProbeInserted(Probe probe) {
-                    trace("PROBE ADDED %s", probe.getShortDescription());
-                }
-
-                @Override
-                public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
-                    trace("PROBE TAGGED as %s: %s", tag, probe.getShortDescription());
-                }
-
-                @Override
-                public void endASTProbing(Source source) {
-                    final String sourceName = source == null ? "<?>" : source.getShortName();
-                    trace("FINISHED PROBING %s", sourceName);
-                    assert source == beingProbed;
-                    beingProbed = null;
-                }
-            });
-        }
     }
 
     public static DebugEngine create(DebugClient debugClient, SourceExecutionProvider sourceExecutionProvider) {