annotate graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java @ 14109:85969b1aba78

Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
author Gilles Duboscq <duboscq@ssw.jku.at>
date Thu, 06 Mar 2014 18:13:49 +0100
parents ba72961e0d41
children 5fc6b8b54d82
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.debug;
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
25 import static com.oracle.graal.debug.Debug.Initialization.*;
5302
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
26
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
27 import java.io.*;
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
28 import java.util.*;
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
29 import java.util.concurrent.*;
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
30
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
31 import com.oracle.graal.debug.internal.*;
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
32
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
33 /**
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
34 * Scope based debugging facility. This facility is {@link #isEnabled()} if assertions are enabled
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
35 * for the {@link Debug} class or the {@value Initialization#INITIALIZER_PROPERTY_NAME} system
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
36 * property is {@code "true"} when {@link Debug} is initialized.
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
37 */
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
38 public class Debug {
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
40 /**
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
41 * Class to assist with initialization of {@link Debug}.
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
42 */
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
43 public static class Initialization {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
44
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
45 public static final String INITIALIZER_PROPERTY_NAME = "graal.debug.enable";
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
46
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
47 private static boolean initialized;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
48
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
49 /**
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
50 * Determines if {@link Debug} has been initialized.
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
51 */
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
52 public static boolean isDebugInitialized() {
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
53 return initialized;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
54 }
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
55
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
56 }
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
58 @SuppressWarnings("all")
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
59 private static boolean initialize() {
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
60 boolean assertionsEnabled = false;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
61 assert assertionsEnabled = true;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
62 Initialization.initialized = true;
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
63 return assertionsEnabled || Boolean.getBoolean(INITIALIZER_PROPERTY_NAME);
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
64 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
65
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
66 private static final boolean ENABLED = initialize();
11611
a27678c47948 made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents: 11562
diff changeset
67
4369
efc430d943c0 Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4363
diff changeset
68 public static boolean isEnabled() {
efc430d943c0 Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4363
diff changeset
69 return ENABLED;
efc430d943c0 Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4363
diff changeset
70 }
efc430d943c0 Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4363
diff changeset
71
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
72 public static boolean isDumpEnabledForMethod() {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
73 if (!ENABLED) {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
74 return false;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
75 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
76 DebugConfig config = DebugScope.getConfig();
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
77 if (config == null) {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
78 return false;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
79 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
80 return config.isDumpEnabledForMethod();
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
81 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
82
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
83 public static boolean isDumpEnabled() {
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
84 return ENABLED && DebugScope.getInstance().isDumpEnabled();
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
85 }
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
86
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
87 public static boolean isMeterEnabled() {
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
88 return ENABLED && DebugScope.getInstance().isMeterEnabled();
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
89 }
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
90
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
91 public static boolean isTimeEnabled() {
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
92 return ENABLED && DebugScope.getInstance().isTimeEnabled();
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
93 }
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
94
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
95 public static boolean isLogEnabledForMethod() {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
96 if (!ENABLED) {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
97 return false;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
98 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
99 DebugConfig config = DebugScope.getConfig();
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
100 if (config == null) {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
101 return false;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
102 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
103 return config.isLogEnabledForMethod();
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
104 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
105
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
106 public static boolean isLogEnabled() {
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
107 return ENABLED && DebugScope.getInstance().isLogEnabled();
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
108 }
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
109
5159
24c77ad284dc fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents: 5137
diff changeset
110 @SuppressWarnings("unused")
5137
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
111 public static Runnable decorateDebugRoot(Runnable runnable, String name, DebugConfig config) {
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
112 return runnable;
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
113 }
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
114
5159
24c77ad284dc fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents: 5137
diff changeset
115 @SuppressWarnings("unused")
5137
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
116 public static <T> Callable<T> decorateDebugRoot(Callable<T> callable, String name, DebugConfig config) {
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
117 return callable;
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
118 }
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
119
5159
24c77ad284dc fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents: 5137
diff changeset
120 @SuppressWarnings("unused")
5137
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
121 public static Runnable decorateScope(Runnable runnable, String name, Object... context) {
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
122 return runnable;
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
123 }
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
124
5159
24c77ad284dc fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents: 5137
diff changeset
125 @SuppressWarnings("unused")
5137
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
126 public static <T> Callable<T> decorateScope(Callable<T> callable, String name, Object... context) {
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
127 return callable;
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
128 }
09f66048738e Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5061
diff changeset
129
9199
2ff3499d408e enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents: 9103
diff changeset
130 /**
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
131 * Gets a string composed of the names in the current nesting of debug
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
132 * {@linkplain #scope(String, Object...) scopes} separated by {@code '.'}.
9199
2ff3499d408e enhanced support for sandboxed debug scope such that their debug config can be specified
Doug Simon <doug.simon@oracle.com>
parents: 9103
diff changeset
133 */
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
134 public static String currentScope() {
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
135 if (ENABLED) {
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
136 return DebugScope.getInstance().getQualifiedName();
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
137 } else {
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
138 return "";
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
139 }
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
140 }
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
141
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
142 /**
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
143 * Represents a debug scope entered by {@link Debug#scope(String, Object...)} or
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
144 * {@link Debug#sandbox(String, DebugConfig, Object...)}. Leaving the scope is achieved via
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
145 * {@link #close()}.
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
146 */
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
147 public interface Scope extends AutoCloseable {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
148 void close();
5009
e3cc0d407bc6 Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4579
diff changeset
149 }
e3cc0d407bc6 Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4579
diff changeset
150
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
151 /**
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
152 * Creates and enters a new debug scope which will be a child of the current debug scope.
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
153 * <p>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
154 * It is recommended to use the try-with-resource statement for managing entering and leaving
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
155 * debug scopes. For example:
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
156 *
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
157 * <pre>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
158 * try (Scope s = Debug.scope(&quot;InliningGraph&quot;, inlineeGraph)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
159 * ...
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
160 * } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
161 * throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
162 * }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
163 * </pre>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
164 *
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
165 * @param name the name of the new scope
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
166 * @param context objects to be appended to the {@linkplain #context() current} debug context
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
167 * @return the scope entered by this method which will be exited when its {@link Scope#close()}
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
168 * method is called
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
169 */
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
170 public static Scope scope(String name, Object... context) {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
171 if (ENABLED) {
13547
8ea968b6dba9 fix handling of sandboxed debug scopes (don't destroy parent flags)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13326
diff changeset
172 return DebugScope.getInstance().scope(name, null, context);
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
173 } else {
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
174 return null;
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
175 }
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
176 }
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
177
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
178 /**
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
179 * Creates and enters a new debug scope which will be disjoint from the current debug scope.
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
180 * <p>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
181 * It is recommended to use the try-with-resource statement for managing entering and leaving
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
182 * debug scopes. For example:
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
183 *
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
184 * <pre>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
185 * try (Scope s = Debug.sandbox(&quot;CompilingStub&quot;, null, stubGraph)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
186 * ...
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
187 * } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
188 * throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
189 * }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
190 * </pre>
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
191 *
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
192 * @param name the name of the new scope
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
193 * @param config the debug configuration to use for the new scope
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
194 * @param context objects to be appended to the {@linkplain #context() current} debug context
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
195 * @return the scope entered by this method which will be exited when its {@link Scope#close()}
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
196 * method is called
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
197 */
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
198 public static Scope sandbox(String name, DebugConfig config, Object... context) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
199 if (ENABLED) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
200 DebugConfig sandboxConfig = config == null ? silentConfig() : config;
13547
8ea968b6dba9 fix handling of sandboxed debug scopes (don't destroy parent flags)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13326
diff changeset
201 return DebugScope.getInstance().scope(name, sandboxConfig, context);
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
202 } else {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
203 return null;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
204 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
205 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
206
14109
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
207 public static Scope forceLog() {
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
208 return Debug.sandbox("forceLog", new DelegatingDebugConfig(DebugScope.getConfig()) {
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
209 @Override
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
210 public boolean isLogEnabled() {
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
211 return true;
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
212 }
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
213
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
214 @Override
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
215 public boolean isLogEnabledForMethod() {
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
216 return true;
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
217 }
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
218 });
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
219 }
85969b1aba78 Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13551
diff changeset
220
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
221 /**
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
222 * Handles an exception in the context of the debug scope just exited. The just exited scope
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
223 * must have the current scope as its parent which will be the case if the try-with-resource
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
224 * pattern recommended by {@link #scope(String, Object...)} and
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
225 * {@link #sandbox(String, DebugConfig, Object...)} is used
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
226 *
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
227 * @see #scope(String, Object...)
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
228 * @see #sandbox(String, DebugConfig, Object...)
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
229 */
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
230 public static RuntimeException handle(Throwable exception) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
231 if (ENABLED) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
232 return DebugScope.getInstance().handle(exception);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
233 } else {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
234 if (exception instanceof Error) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
235 throw (Error) exception;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
236 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
237 if (exception instanceof RuntimeException) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
238 throw (RuntimeException) exception;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
239 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
240 throw new RuntimeException(exception);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
241 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
242 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
243
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
244 /**
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
245 * Prints an indented message to the current debug scopes's logging stream if logging is enabled
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13189
diff changeset
246 * in the scope.
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
247 *
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
248 * @param msg The format string of the log message
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
249 * @param args The arguments referenced by the log message string
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
250 * @see Indent#log
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
251 */
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
252 public static void log(String msg, Object... args) {
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
253 if (ENABLED) {
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
254 DebugScope.getInstance().log(msg, args);
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
255 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
256 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
257
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
258 /**
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
259 * The same as {@link #log}, but without line termination and without indentation.
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
260 */
10923
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
261 public static void printf(String msg, Object... args) {
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
262 if (ENABLED && DebugScope.getInstance().isLogEnabled()) {
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
263 DebugScope.getInstance().printf(msg, args);
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
264 }
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
265 }
01a0f525ac17 Debug: add printf
Bernhard Urban <bernhard.urban@jku.at>
parents: 10611
diff changeset
266
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
267 public static void dump(Object object, String msg, Object... args) {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
268 if (ENABLED && DebugScope.getInstance().isDumpEnabled()) {
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
269 DebugScope.getInstance().dump(object, msg, args);
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
270 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
271 }
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
272
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
273 private static final class NoLogger implements Indent {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
274
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
275 @Override
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
276 public void log(String msg, Object... args) {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
277 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
278
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
279 @Override
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
280 public Indent indent() {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
281 return this;
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
282 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
283
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
284 @Override
13142
401830ff96f4 some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents: 12778
diff changeset
285 public Indent logAndIndent(String msg, Object... args) {
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
286 return this;
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
287 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
288
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
289 @Override
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
290 public Indent outdent() {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
291 return this;
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
292 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
293
13142
401830ff96f4 some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents: 12778
diff changeset
294 @Override
401830ff96f4 some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents: 12778
diff changeset
295 public void close() {
401830ff96f4 some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents: 12778
diff changeset
296 }
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
297 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
298
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
299 private static final NoLogger noLoggerInstance = new NoLogger();
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
300
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
301 /**
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
302 * Creates a new indentation level (by adding some spaces) based on the last used Indent of the
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
303 * current DebugScope.
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
304 *
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
305 * @return The new indentation level
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
306 * @see Indent#indent
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
307 */
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
308 public static Indent indent() {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
309 if (ENABLED) {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
310 DebugScope scope = DebugScope.getInstance();
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
311 return scope.pushIndentLogger();
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
312 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
313 return noLoggerInstance;
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
314 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
315
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
316 /**
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
317 * A convenience function which combines {@link #log} and {@link #indent()}.
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
318 *
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
319 * @param msg The format string of the log message
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
320 * @param args The arguments referenced by the log message string
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
321 * @return The new indentation level
13142
401830ff96f4 some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents: 12778
diff changeset
322 * @see Indent#logAndIndent
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
323 */
13142
401830ff96f4 some improvements in Debug logging
Erik Eckstein <erik.eckstein@oracle.com>
parents: 12778
diff changeset
324 public static Indent logAndIndent(String msg, Object... args) {
11382
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
325 if (ENABLED) {
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
326 DebugScope scope = DebugScope.getInstance();
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
327 scope.log(msg, args);
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
328 return scope.pushIndentLogger();
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
329 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
330 return noLoggerInstance;
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
331 }
d7d12ef788ba add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10923
diff changeset
332
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
333 public static Iterable<Object> context() {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
334 if (ENABLED) {
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
335 return DebugScope.getInstance().getCurrentContext();
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
336 } else {
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4349
diff changeset
337 return Collections.emptyList();
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
338 }
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
339 }
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
341 @SuppressWarnings("unchecked")
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
342 public static <T> List<T> contextSnapshot(Class<T> clazz) {
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
343 if (ENABLED) {
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
344 List<T> result = new ArrayList<>();
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
345 for (Object o : context()) {
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
346 if (clazz.isInstance(o)) {
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
347 result.add((T) o);
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
348 }
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
349 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
350 return result;
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
351 } else {
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
352 return Collections.emptyList();
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
353 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
354 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
355
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5159
diff changeset
356 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6584
diff changeset
357 * Searches the current debug scope, bottom up, for a context object that is an instance of a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6584
diff changeset
358 * given type. The first such object found is returned.
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5159
diff changeset
359 */
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
360 @SuppressWarnings("unchecked")
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
361 public static <T> T contextLookup(Class<T> clazz) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
362 if (ENABLED) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
363 for (Object o : context()) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
364 if (clazz.isInstance(o)) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
365 return ((T) o);
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
366 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
367 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
368 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
369 return null;
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
370 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
371
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
372 /**
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
373 * Creates a {@linkplain DebugMetric metric} that is enabled iff debugging is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
374 * {@linkplain #isEnabled() enabled} or the system property whose name is formed by adding to
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
375 * {@value #ENABLE_METRIC_PROPERTY_NAME_PREFIX} to {@code name} is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
376 * {@linkplain Boolean#getBoolean(String) true}. If the latter condition is true, then the
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
377 * returned metric is {@linkplain DebugMetric#isConditional() unconditional} otherwise it is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
378 * conditional.
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
379 * <p>
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
380 * A disabled metric has virtually no overhead.
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
381 */
4356
249752adcb8d Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4353
diff changeset
382 public static DebugMetric metric(String name) {
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
383 if (Boolean.getBoolean(ENABLE_METRIC_PROPERTY_NAME_PREFIX + name)) {
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
384 return new MetricImpl(name, false);
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
385 } else if (ENABLED) {
11562
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
386 return new MetricImpl(name, true);
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
387 } else {
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
388 return VOID_METRIC;
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 }
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 }
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
392 /**
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
393 * Changes the debug configuration for the current thread.
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
394 *
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
395 * @param config new configuration to use for the current thread
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
396 * @return an object that when {@linkplain DebugConfigScope#close() closed} will restore the
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
397 * debug configuration for the current thread to what it was before this method was
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
398 * called
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
399 */
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
400 public static DebugConfigScope setConfig(DebugConfig config) {
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
401 if (ENABLED) {
13158
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
402 return new DebugConfigScope(config);
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
403 } else {
53b1edcf628f added support for scoping a change to the current DebugConfig using try-with-resource
Doug Simon <doug.simon@oracle.com>
parents: 13142
diff changeset
404 return null;
4357
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
405 }
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
406 }
719ac1d92a52 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4356
diff changeset
407
11551
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 11382
diff changeset
408 /**
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 11382
diff changeset
409 * Creates an object for counting value frequencies.
63b4694d3627 split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents: 11382
diff changeset
410 */
9103
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7557
diff changeset
411 public static DebugHistogram createHistogram(String name) {
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7557
diff changeset
412 return new DebugHistogramImpl(name);
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7557
diff changeset
413 }
e7541d478e38 Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7557
diff changeset
414
13189
f444a67ecbae Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents: 13163
diff changeset
415 public static DebugConfig silentConfig() {
f444a67ecbae Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents: 13163
diff changeset
416 return fixedConfig(false, false, false, false, Collections.<DebugDumpHandler> emptyList(), System.out);
f444a67ecbae Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents: 13163
diff changeset
417 }
f444a67ecbae Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents: 13163
diff changeset
418
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6584
diff changeset
419 public static DebugConfig fixedConfig(final boolean isLogEnabled, final boolean isDumpEnabled, final boolean isMeterEnabled, final boolean isTimerEnabled,
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6584
diff changeset
420 final Collection<DebugDumpHandler> dumpHandlers, final PrintStream output) {
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
421 return new DebugConfig() {
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
422
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
423 @Override
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
424 public boolean isLogEnabled() {
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
425 return isLogEnabled;
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
426 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
427
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
428 public boolean isLogEnabledForMethod() {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
429 return isLogEnabled;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
430 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
431
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
432 @Override
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
433 public boolean isMeterEnabled() {
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
434 return isMeterEnabled;
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
435 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
436
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
437 @Override
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
438 public boolean isDumpEnabled() {
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
439 return isDumpEnabled;
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
440 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
441
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
442 public boolean isDumpEnabledForMethod() {
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
443 return isDumpEnabled;
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
444 }
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13197
diff changeset
445
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
446 @Override
4394
cf609017d3d4 Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4369
diff changeset
447 public boolean isTimeEnabled() {
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
448 return isTimerEnabled;
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
449 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
450
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
451 @Override
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
452 public RuntimeException interceptException(Throwable e) {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
453 return null;
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
454 }
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
455
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
456 @Override
6584
a3eb814ea564 added more javadoc to DebugConfig interface
Doug Simon <doug.simon@oracle.com>
parents: 5620
diff changeset
457 public Collection<DebugDumpHandler> dumpHandlers() {
4428
0bb7ab1add7e enable dumping graphs upon exception, new constructor for NodeInputList, initialize debug system for non-compiler threads
Lukas Stadler <lukas.stadler@jku.at>
parents: 4406
diff changeset
458 return dumpHandlers;
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4361
diff changeset
459 }
5302
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
460
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
461 @Override
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
462 public PrintStream output() {
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
463 return output;
55bf72fafc41 (preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents: 5251
diff changeset
464 }
5620
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
465
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
466 @Override
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
467 public void addToContext(Object o) {
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
468 }
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
469
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
470 @Override
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
471 public void removeFromContext(Object o) {
2a44192a8b24 added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents: 5302
diff changeset
472 }
4361
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
473 };
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
474 }
18b52fec79f1 Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4357
diff changeset
475
4356
249752adcb8d Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4353
diff changeset
476 private static final DebugMetric VOID_METRIC = new DebugMetric() {
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
478 public void increment() {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
479 }
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
480
7557
db90c8b5a861 changed DebugMetric.add() to take a long parameter instead of an int
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
481 public void add(long value) {
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
482 }
11562
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
483
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
484 public void setConditional(boolean flag) {
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
485 throw new InternalError("Cannot make void metric conditional");
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
486 }
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
487
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
488 public boolean isConditional() {
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
489 return false;
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
490 }
12778
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
491
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
492 public long getCurrentValue() {
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
493 return 0L;
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
494 }
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
495 };
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
496
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
497 /**
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
498 * @see #timer(String)
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
499 */
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
500 public static final String ENABLE_TIMER_PROPERTY_NAME_PREFIX = "graal.debug.timer.";
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
501
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
502 /**
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
503 * @see #metric(String)
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
504 */
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
505 public static final String ENABLE_METRIC_PROPERTY_NAME_PREFIX = "graal.debug.metric.";
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
506
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
507 /**
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
508 * Creates a {@linkplain DebugTimer timer} that is enabled iff debugging is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
509 * {@linkplain #isEnabled() enabled} or the system property whose name is formed by adding to
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
510 * {@value #ENABLE_TIMER_PROPERTY_NAME_PREFIX} to {@code name} is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
511 * {@linkplain Boolean#getBoolean(String) true}. If the latter condition is true, then the
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
512 * returned timer is {@linkplain DebugMetric#isConditional() unconditional} otherwise it is
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
513 * conditional.
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
514 * <p>
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
515 * A disabled timer has virtually no overhead.
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
516 */
4356
249752adcb8d Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4353
diff changeset
517 public static DebugTimer timer(String name) {
12776
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
518 if (Boolean.getBoolean(ENABLE_TIMER_PROPERTY_NAME_PREFIX + name)) {
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
519 return new TimerImpl(name, false);
a7990d87c26e added support for unconditionally enabling a DebugTimer or DebugMetric, regardless of whether general Debug capabilities are enabled
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
520 } else if (ENABLED) {
11562
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
521 return new TimerImpl(name, true);
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
522 } else {
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
523 return VOID_TIMER;
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 }
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 }
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526
4356
249752adcb8d Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4353
diff changeset
527 private static final DebugTimer VOID_TIMER = new DebugTimer() {
4477
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
528
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
529 public TimerCloseable start() {
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
530 return TimerImpl.VOID_CLOSEABLE;
27c5466afd55 Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents: 4433
diff changeset
531 }
11562
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
532
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
533 public void setConditional(boolean flag) {
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
534 throw new InternalError("Cannot make void timer conditional");
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
535 }
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
536
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
537 public boolean isConditional() {
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
538 return false;
6b6c6e5d0fc2 added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents: 11551
diff changeset
539 }
12778
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
540
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
541 public long getCurrentValue() {
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
542 return 0L;
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
543 }
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
544
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
545 public TimeUnit getTimeUnit() {
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
546 return null;
c125485642e2 added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents: 12776
diff changeset
547 }
4349
7e974a026889 More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4348
diff changeset
548 };
4343
f03c71a0aeb8 Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
549 }