Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/Debug.java @ 4346:ee5fbfca6612
more work on debug project; removed CiStatistics
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 11 Jan 2012 15:02:48 +0100 |
parents | 176d60b77d31 |
children | d49c90e641cb |
rev | line source |
---|---|
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.max.graal.debug; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 public class Debug { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 public static boolean ENABLED = false; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 public static void log(String msg, Object... args) { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 if (ENABLED) { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 DebugContext.getInstance().log(msg, args); |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
4346
ee5fbfca6612
more work on debug project; removed CiStatistics
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4345
diff
changeset
|
35 public static void scope(String name, Runnable runnable, Object... context) { |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 if (ENABLED) { |
4346
ee5fbfca6612
more work on debug project; removed CiStatistics
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4345
diff
changeset
|
37 DebugContext.getInstance().scope(name, runnable, context); |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 } else { |
4346
ee5fbfca6612
more work on debug project; removed CiStatistics
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4345
diff
changeset
|
39 runnable.run(); |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 private static final Scope VOID_SCOPE = new Scope(null); |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 |
4346
ee5fbfca6612
more work on debug project; removed CiStatistics
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4345
diff
changeset
|
45 |
4345
176d60b77d31
Moved PrintCompilation logic from graal.compiler to graal.hotspot. Made bootclasspath generated from the GRAAL environment option more generic (such that adding/removing a project requires no changes in the C++ part).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4343
diff
changeset
|
46 public static final class Scope implements AutoCloseable { |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 private String name; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 private Object[] context; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 private Scope(String name, Object... context) { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 this.name = name; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 this.context = context; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 @Override |
4345
176d60b77d31
Moved PrintCompilation logic from graal.compiler to graal.hotspot. Made bootclasspath generated from the GRAAL environment option more generic (such that adding/removing a project requires no changes in the C++ part).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4343
diff
changeset
|
56 public void close() { |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 private static class ScopeChild { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 private String name; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 protected ScopeChild(String name) { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 this.name = name; |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 public static final class Metric extends ScopeChild { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 private Metric(String name) { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 super(name); |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 public static final class Timer extends ScopeChild { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 private Timer(String name) { |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 super(name); |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 } |