Mercurial > hg > graal-compiler
comparison graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java @ 4353:043bec543161
More work on debug framework. Removed concept of GraalContext.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 17 Jan 2012 23:35:21 +0100 |
parents | 5a84f5548fc4 |
children | 249752adcb8d |
comparison
equal
deleted
inserted
replaced
4352:5a84f5548fc4 | 4353:043bec543161 |
---|---|
24 | 24 |
25 import com.oracle.max.graal.debug.internal.DebugScope; | 25 import com.oracle.max.graal.debug.internal.DebugScope; |
26 import com.oracle.max.graal.debug.internal.MetricImpl; | 26 import com.oracle.max.graal.debug.internal.MetricImpl; |
27 import com.oracle.max.graal.debug.internal.TimerImpl; | 27 import com.oracle.max.graal.debug.internal.TimerImpl; |
28 import java.util.Collections; | 28 import java.util.Collections; |
29 import java.util.concurrent.*; | |
29 | 30 |
30 | 31 |
31 public class Debug { | 32 public class Debug { |
32 public static boolean SCOPE = false; | 33 public static boolean SCOPE = false; |
33 public static boolean LOG = false; | 34 public static boolean LOG = false; |
34 public static boolean METER = false; | 35 public static boolean METER = false; |
35 public static boolean TIME = false; | 36 public static boolean TIME = false; |
36 | 37 |
37 public static void scope(String name, Runnable runnable, Object... context) { | 38 public static void sandbox(String name, Runnable runnable) { |
38 if (SCOPE) { | 39 if (SCOPE) { |
39 DebugScope.getInstance().scope(name, runnable, false, context); | 40 DebugScope.getInstance().scope(name, runnable, null, true, new Object[0]); |
40 } else { | 41 } else { |
41 runnable.run(); | 42 runnable.run(); |
42 } | 43 } |
43 } | 44 } |
44 | 45 |
45 public static void sandbox(String name, Runnable runnable, Object... context) { | 46 public static void scope(String name, Runnable runnable) { |
47 scope(name, null, runnable); | |
48 } | |
49 | |
50 public static <T> T scope(String name, Callable<T> callable) { | |
51 return scope(name, null, callable); | |
52 } | |
53 | |
54 public static void scope(String name, Object context, Runnable runnable) { | |
46 if (SCOPE) { | 55 if (SCOPE) { |
47 DebugScope.getInstance().scope(name, runnable, true, context); | 56 DebugScope.getInstance().scope(name, runnable, null, false, new Object[]{context}); |
48 } else { | 57 } else { |
49 runnable.run(); | 58 runnable.run(); |
59 } | |
60 } | |
61 | |
62 public static <T> T scope(String name, Object context, Callable<T> callable) { | |
63 if (SCOPE) { | |
64 return DebugScope.getInstance().scope(name, null, callable, false, new Object[]{context}); | |
65 } else { | |
66 return DebugScope.call(callable); | |
50 } | 67 } |
51 } | 68 } |
52 | 69 |
53 public static void log(String msg, Object... args) { | 70 public static void log(String msg, Object... args) { |
54 if (LOG) { | 71 if (LOG) { |