changeset 14873:00eb80d735ed

removed Debug.printf and added multi-arg versions of Debug.dump
author Doug Simon <doug.simon@oracle.com>
date Fri, 28 Mar 2014 12:39:46 +0100
parents e6ce6d9f477f
children 7dfc0e9fd45a
files graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfig.java graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java
diffstat 5 files changed, 79 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Fri Mar 28 11:45:47 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Fri Mar 28 12:39:46 2014 +0100
@@ -355,6 +355,15 @@
     }
 
     /**
+     * @see #log(String, Object)
+     */
+    public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
+        if (ENABLED) {
+            DebugScope.getInstance().log(format, arg1, arg2, arg3, arg4, arg5, arg6);
+        }
+    }
+
+    /**
      * Prints a message to the current debug scope's logging stream. This method must only be called
      * if debugging is {@linkplain Debug#isEnabled() enabled} as it incurs allocation at the call
      * site. If possible, call one of the other {@code log()} methods in this class that take a
@@ -371,9 +380,10 @@
     }
 
     /**
-     * This override exists to catch cases when log is called with one argument bound to a varargs
-     * method parameter. It will bind to this method instead of the single arg variant and produce a
-     * deprecation warning instead of silently wrapping the Object[] inside of another Object[].
+     * This override exists to catch cases when {@link #log(String, Object)} is called with one
+     * argument bound to a varargs method parameter. It will bind to this method instead of the
+     * single arg variant and produce a deprecation warning instead of silently wrapping the
+     * Object[] inside of another Object[].
      */
     @Deprecated
     public static void log(String format, Object[] args) {
@@ -381,18 +391,41 @@
         logv(format, args);
     }
 
-    /**
-     * The same as {@link #log}, but without line termination and without indentation.
-     */
-    public static void printf(String msg, Object... args) {
-        if (ENABLED && DebugScope.getInstance().isLogEnabled()) {
-            DebugScope.getInstance().printf(msg, args);
+    public static void dump(Object object, String msg) {
+        if (ENABLED && DebugScope.getInstance().isDumpEnabled()) {
+            DebugScope.getInstance().dump(object, msg);
+        }
+    }
+
+    public static void dump(Object object, String format, Object arg) {
+        if (ENABLED && DebugScope.getInstance().isDumpEnabled()) {
+            DebugScope.getInstance().dump(object, format, arg);
+        }
+    }
+
+    public static void dump(Object object, String format, Object arg1, Object arg2) {
+        if (ENABLED && DebugScope.getInstance().isDumpEnabled()) {
+            DebugScope.getInstance().dump(object, format, arg1, arg2);
         }
     }
 
-    public static void dump(Object object, String msg, Object... args) {
+    public static void dump(Object object, String format, Object arg1, Object arg2, Object arg3) {
         if (ENABLED && DebugScope.getInstance().isDumpEnabled()) {
-            DebugScope.getInstance().dump(object, msg, args);
+            DebugScope.getInstance().dump(object, format, arg1, arg2, arg3);
+        }
+    }
+
+    /**
+     * This override exists to catch cases when {@link #dump(Object, String, Object)} is called with
+     * one argument bound to a varargs method parameter. It will bind to this method instead of the
+     * single arg variant and produce a deprecation warning instead of silently wrapping the
+     * Object[] inside of another Object[].
+     */
+    @Deprecated
+    public static void dump(Object object, String format, Object[] args) {
+        assert false : "shouldn't use this";
+        if (ENABLED && DebugScope.getInstance().isDumpEnabled()) {
+            DebugScope.getInstance().dump(object, format, args);
         }
     }
 
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfig.java	Fri Mar 28 11:45:47 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfig.java	Fri Mar 28 12:39:46 2014 +0100
@@ -41,7 +41,7 @@
     /**
      * Determines if metering is enabled in the {@linkplain Debug#currentScope() current debug
      * scope}.
-     * 
+     *
      * @see Debug#metric(CharSequence)
      */
     boolean isMeterEnabled();
@@ -49,8 +49,8 @@
     /**
      * Determines if dumping is enabled in the {@linkplain Debug#currentScope() current debug scope}
      * .
-     * 
-     * @see Debug#dump(Object, String, Object...)
+     *
+     * @see Debug#dump(Object, String)
      */
     boolean isDumpEnabled();
 
@@ -67,7 +67,7 @@
 
     /**
      * Removes an object the context used by this configuration to do filtering.
-     * 
+     *
      * This should only removes extra context added by {@link #addToContext(Object)}.
      */
     void removeFromContext(Object o);
@@ -79,7 +79,7 @@
 
     /**
      * Handles notification of an exception occurring within a debug scope.
-     * 
+     *
      * @return the exception object that is to be propagated to parent scope. A value of
      *         {@code null} indicates that {@code e} is to be propagated.
      */
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Fri Mar 28 11:45:47 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Fri Mar 28 12:39:46 2014 +0100
@@ -180,7 +180,7 @@
         }
     }
 
-    public void dump(Object object, String formatString, Object[] args) {
+    public void dump(Object object, String formatString, Object... args) {
         if (isDumpEnabled()) {
             DebugConfig config = getConfig();
             if (config != null) {
@@ -195,7 +195,7 @@
     /**
      * This method exists mainly to allow a debugger (e.g., Eclipse) to force dump a graph.
      */
-    public static void dump(Object object, String message) {
+    public static void forceDump(Object object, String message) {
         DebugConfig config = getConfig();
         if (config != null) {
             for (DebugDumpHandler dumpHandler : config.dumpHandlers()) {
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Fri Mar 28 11:45:47 2014 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Fri Mar 28 12:39:46 2014 +0100
@@ -293,19 +293,20 @@
 
     private void printSchedule(String desc) {
         if (Debug.isLogEnabled()) {
-            Debug.printf("=== %s / %s / %s (%s) ===\n", getCFG().getStartBlock().getBeginNode().graph(), selectedStrategy, memsched, desc);
+            Formatter buf = new Formatter();
+            buf.format("=== %s / %s / %s (%s) ===%n", getCFG().getStartBlock().getBeginNode().graph(), selectedStrategy, memsched, desc);
             for (Block b : getCFG().getBlocks()) {
-                Debug.printf("==== b: %s (loopDepth: %s). ", b, b.getLoopDepth());
-                Debug.printf("dom: %s. ", b.getDominator());
-                Debug.printf("post-dom: %s. ", b.getPostdominator());
-                Debug.printf("preds: %s. ", b.getPredecessors());
-                Debug.printf("succs: %s ====\n", b.getSuccessors());
+                buf.format("==== b: %s (loopDepth: %s). ", b, b.getLoopDepth());
+                buf.format("dom: %s. ", b.getDominator());
+                buf.format("post-dom: %s. ", b.getPostdominator());
+                buf.format("preds: %s. ", b.getPredecessors());
+                buf.format("succs: %s ====%n", b.getSuccessors());
                 BlockMap<KillSet> killSets = blockToKillSet;
                 if (killSets != null) {
-                    Debug.printf("X block kills: \n");
+                    buf.format("X block kills: %n");
                     if (killSets.get(b) != null) {
                         for (LocationIdentity locId : killSets.get(b)) {
-                            Debug.printf("X %s killed by %s\n", locId, "dunno anymore");
+                            buf.format("X %s killed by %s%n", locId, "dunno anymore");
                         }
                     }
                 }
@@ -320,28 +321,30 @@
                     }
                 }
             }
-            Debug.printf("\n\n");
+            buf.format("%n");
+            Debug.log("%s", buf);
         }
     }
 
     private static void printNode(Node n) {
-        Debug.printf("%s", n);
+        Formatter buf = new Formatter();
+        buf.format("%s", n);
         if (n instanceof MemoryCheckpoint.Single) {
-            Debug.printf(" // kills %s", ((MemoryCheckpoint.Single) n).getLocationIdentity());
+            buf.format(" // kills %s", ((MemoryCheckpoint.Single) n).getLocationIdentity());
         } else if (n instanceof MemoryCheckpoint.Multi) {
-            Debug.printf(" // kills ");
+            buf.format(" // kills ");
             for (LocationIdentity locid : ((MemoryCheckpoint.Multi) n).getLocationIdentities()) {
-                Debug.printf("%s, ", locid);
+                buf.format("%s, ", locid);
             }
         } else if (n instanceof FloatingReadNode) {
             FloatingReadNode frn = (FloatingReadNode) n;
-            Debug.printf(" // from %s", frn.location().getLocationIdentity());
-            Debug.printf(", lastAccess: %s", frn.getLastLocationAccess());
-            Debug.printf(", object: %s", frn.object());
+            buf.format(" // from %s", frn.location().getLocationIdentity());
+            buf.format(", lastAccess: %s", frn.getLastLocationAccess());
+            buf.format(", object: %s", frn.object());
         } else if (n instanceof GuardNode) {
-            Debug.printf(", guard: %s", ((GuardNode) n).getGuard());
+            buf.format(", guard: %s", ((GuardNode) n).getGuard());
         }
-        Debug.printf("\n");
+        Debug.log("%s", buf);
     }
 
     public ControlFlowGraph getCFG() {
@@ -410,7 +413,7 @@
                 if (scheduleRead) {
                     FloatingReadNode read = (FloatingReadNode) node;
                     block = optimalBlock(read, strategy);
-                    Debug.printf("schedule for %s: %s\n", read, block);
+                    Debug.log("schedule for %s: %s", read, block);
                     assert earliestBlock.dominates(block) : String.format("%s (%s) cannot be scheduled before earliest schedule (%s). location: %s", read, block, earliestBlock,
                                     read.getLocationIdentity());
                 } else {
@@ -486,14 +489,14 @@
         Block latestBlock = latestBlock(n, strategy);
         assert latestBlock != null && earliestBlock.dominates(latestBlock) : "earliest (" + earliestBlock + ") should dominate latest block (" + latestBlock + ")";
 
-        Debug.printf("processing %s (accessing %s): latest %s, earliest %s, upper bound %s (%s)\n", n, locid, latestBlock, earliestBlock, upperBoundBlock, n.getLastLocationAccess());
+        Debug.log("processing %s (accessing %s): latest %s, earliest %s, upper bound %s (%s)", n, locid, latestBlock, earliestBlock, upperBoundBlock, n.getLastLocationAccess());
         if (earliestBlock == latestBlock) {
             // read is fixed to this block, nothing to schedule
             return latestBlock;
         }
 
         Deque<Block> path = computePathInDominatorTree(earliestBlock, latestBlock);
-        Debug.printf("|path| is %d: %s\n", path.size(), path);
+        Debug.log("|path| is %d: %s", path.size(), path);
 
         // follow path, start at earliest schedule
         while (path.size() > 0) {
@@ -504,7 +507,7 @@
                 assert dominatedBlock.getBeginNode() instanceof MergeNode;
 
                 HashSet<Block> region = computeRegion(currentBlock, dominatedBlock);
-                Debug.printf("> merge.  %s: region for %s -> %s: %s\n", n, currentBlock, dominatedBlock, region);
+                Debug.log("> merge.  %s: region for %s -> %s: %s", n, currentBlock, dominatedBlock, region);
 
                 NewMemoryScheduleClosure closure = null;
                 if (currentBlock == upperBoundBlock) {
@@ -643,7 +646,7 @@
          * implies that the inputs' blocks have a total ordering via their dominance relation. So in
          * order to find the earliest block placement for this node we need to find the input block
          * that is dominated by all other input blocks.
-         * 
+         *
          * While iterating over the inputs a set of dominator blocks of the current earliest
          * placement is maintained. When the block of an input is not within this set, it becomes
          * the current earliest placement and the list of dominator blocks is updated.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Fri Mar 28 11:45:47 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Fri Mar 28 12:39:46 2014 +0100
@@ -138,7 +138,7 @@
     /**
      * Converts the arguments of an invoke node to object values suitable for use as the arguments
      * to a reflective invocation of a Java constructor or method.
-     * 
+     *
      * @param folding specifies if the invocation is for handling a {@link Fold} annotation
      * @return the arguments for the reflective invocation or null if an argument of {@code invoke}
      *         that is expected to be constant isn't
@@ -395,7 +395,7 @@
             }
             graph.removeFixed(pi);
         } else {
-            DebugScope.dump(graph, "exception");
+            DebugScope.forceDump(graph, "exception");
             assert false : sourceLocation(usage) + " has unexpected usage " + usage + " of checkcast " + input + " at " + sourceLocation(input);
         }
     }