changeset 9199:2ff3499d408e

enhanced support for sandboxed debug scope such that their debug config can be specified
author Doug Simon <doug.simon@oracle.com>
date Sun, 21 Apr 2013 21:37:40 +0200
parents cf470d096a8f
children 9be78aeab2e1
files graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java
diffstat 3 files changed, 38 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Sun Apr 21 21:15:26 2013 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Sun Apr 21 21:37:40 2013 +0200
@@ -76,9 +76,26 @@
         return callable;
     }
 
-    public static void sandbox(String name, Runnable runnable) {
+    public static void sandbox(String name, DebugConfig config, Runnable runnable) {
         if (ENABLED) {
-            DebugScope.getInstance().scope(name, runnable, null, true, new Object[0]);
+            DebugScope.getInstance().scope(name, runnable, null, true, config, new Object[0]);
+        } else {
+            runnable.run();
+        }
+    }
+
+    /**
+     * Creates a new debug scope that is unrelated to the current scope and runs a given task in the
+     * new scope.
+     * 
+     * @param name new scope name
+     * @param context the context objects of the new scope
+     * @param config the debug configuration to use for the new scope
+     * @param runnable the task to run in the new scope
+     */
+    public static void sandbox(String name, Object[] context, DebugConfig config, Runnable runnable) {
+        if (ENABLED) {
+            DebugScope.getInstance().scope(name, runnable, null, true, config, context);
         } else {
             runnable.run();
         }
@@ -98,7 +115,7 @@
 
     public static void scope(String name, Object[] context, Runnable runnable) {
         if (ENABLED) {
-            DebugScope.getInstance().scope(name, runnable, null, false, context);
+            DebugScope.getInstance().scope(name, runnable, null, false, null, context);
         } else {
             runnable.run();
         }
@@ -118,7 +135,7 @@
 
     public static <T> T scope(String name, Object[] context, Callable<T> callable) {
         if (ENABLED) {
-            return DebugScope.getInstance().scope(name, null, callable, false, context);
+            return DebugScope.getInstance().scope(name, null, callable, false, null, context);
         } else {
             return DebugScope.call(callable);
         }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Sun Apr 21 21:15:26 2013 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Sun Apr 21 21:37:40 2013 +0200
@@ -138,13 +138,26 @@
         }
     }
 
-    public <T> T scope(String newName, Runnable runnable, Callable<T> callable, boolean sandbox, Object[] newContext) {
+    /**
+     * Runs a task in a new debug scope which is either a child of the current scope or a disjoint
+     * top level scope.
+     * 
+     * @param newName the name of the new scope
+     * @param runnable the task to run (must be null iff {@code callable} is not null)
+     * @param callable the task to run (must be null iff {@code runnable} is not null)
+     * @param sandbox specifies if the scope is a child of the current scope or a top level scope
+     * @param sandboxConfig the config to use of a new top level scope (ignored if
+     *            {@code sandbox == false})
+     * @param newContext context objects of the new scope
+     * @return the value returned by the task
+     */
+    public <T> T scope(String newName, Runnable runnable, Callable<T> callable, boolean sandbox, DebugConfig sandboxConfig, Object[] newContext) {
         DebugScope oldContext = getInstance();
         DebugConfig oldConfig = getConfig();
         DebugScope newChild = null;
         if (sandbox) {
             newChild = new DebugScope(newName, newName, null, newContext);
-            setConfig(null);
+            setConfig(sandboxConfig);
         } else {
             newChild = oldContext.createChild(newName, newContext);
         }
@@ -215,7 +228,7 @@
                         return new RuntimeException("Exception while intercepting exception", t);
                     }
                 }
-            }, false, new Object[]{e});
+            }, false, null, new Object[]{e});
         }
         return null;
     }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Sun Apr 21 21:15:26 2013 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Sun Apr 21 21:37:40 2013 +0200
@@ -161,7 +161,7 @@
                 previousInlineContext = inlineContext;
 
                 final SchedulePhase predefinedSchedule = getPredefinedSchedule();
-                Debug.sandbox("PrintingGraph", new Runnable() {
+                Debug.sandbox("PrintingGraph", null, new Runnable() {
 
                     @Override
                     public void run() {