Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java @ 15851:94a2df2f8e58
preserve context in Debug.forceLog
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 22 May 2014 14:04:55 +0200 |
parents | 4ead444b15aa |
children | af9f3a5f091b |
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.*; |
15115
de406a971984
enhanced API for scoped overriding of the current DebugConfig
Doug Simon <doug.simon@oracle.com>
parents:
15040
diff
changeset
|
26 import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*; |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
27 import static java.util.FormattableFlags.*; |
5302
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5251
diff
changeset
|
28 |
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5251
diff
changeset
|
29 import java.io.*; |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
30 import java.util.*; |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
31 import java.util.concurrent.*; |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
32 |
11611
a27678c47948
made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
33 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
|
34 |
a27678c47948
made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
35 /** |
a27678c47948
made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
36 * 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
|
37 * 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
|
38 * 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
|
39 */ |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
40 public class Debug { |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
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 * 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
|
44 */ |
11612
54dff87002e0
check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents:
11611
diff
changeset
|
45 public static class Initialization { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
46 |
11611
a27678c47948
made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
47 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
|
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 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
|
50 |
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 * 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
|
53 */ |
54dff87002e0
check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents:
11611
diff
changeset
|
54 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
|
55 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
|
56 } |
54dff87002e0
check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents:
11611
diff
changeset
|
57 |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
58 } |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 |
11611
a27678c47948
made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents:
11562
diff
changeset
|
60 @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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
67 |
11612
54dff87002e0
check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents:
11611
diff
changeset
|
68 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
|
69 |
4369
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
70 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
|
71 return ENABLED; |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
72 } |
efc430d943c0
Drafted regexp filters. Rewrote logging statements of floating read phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4363
diff
changeset
|
73 |
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
|
74 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
|
75 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
|
76 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
|
77 } |
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 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
|
79 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
|
80 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
|
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 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
|
83 } |
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
|
84 |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
85 public static boolean isDumpEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
86 return ENABLED && DebugScope.getInstance().isDumpEnabled(); |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
87 } |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
88 |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
89 public static boolean isMeterEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
90 return ENABLED && DebugScope.getInstance().isMeterEnabled(); |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
91 } |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
92 |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
93 public static boolean isTimeEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
94 return ENABLED && DebugScope.getInstance().isTimeEnabled(); |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
95 } |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
96 |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
97 public static boolean isMemUseTrackingEnabled() { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
98 return ENABLED && DebugScope.getInstance().isMemUseTrackingEnabled(); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
99 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
100 |
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
|
101 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
|
102 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
|
103 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
|
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 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
|
106 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
|
107 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
|
108 } |
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
|
109 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
|
110 } |
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
|
111 |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
112 public static boolean isLogEnabled() { |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
113 return ENABLED && DebugScope.getInstance().isLogEnabled(); |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
114 } |
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
115 |
5159
24c77ad284dc
fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents:
5137
diff
changeset
|
116 @SuppressWarnings("unused") |
5137
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
117 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
|
118 return runnable; |
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
119 } |
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
120 |
5159
24c77ad284dc
fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents:
5137
diff
changeset
|
121 @SuppressWarnings("unused") |
5137
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
122 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
|
123 return callable; |
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
124 } |
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
125 |
5159
24c77ad284dc
fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents:
5137
diff
changeset
|
126 @SuppressWarnings("unused") |
5137
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
127 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
|
128 return runnable; |
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
129 } |
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
130 |
5159
24c77ad284dc
fixed Eclipse compiler warnings about unused parameters
Doug Simon <doug.simon@oracle.com>
parents:
5137
diff
changeset
|
131 @SuppressWarnings("unused") |
5137
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
132 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
|
133 return callable; |
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
134 } |
09f66048738e
Added new decorate methods to the Debug class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5061
diff
changeset
|
135 |
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
|
136 /** |
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
|
137 * Gets a string composed of the names in the current nesting of debug |
14624
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
138 * {@linkplain #scope(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
|
139 */ |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
140 public static String currentScope() { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
141 if (ENABLED) { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
142 return DebugScope.getInstance().getQualifiedName(); |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
143 } else { |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
144 return ""; |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
145 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
146 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
147 |
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
|
148 /** |
14624
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
149 * Represents a debug scope entered by {@link Debug#scope(Object)} or |
14906 | 150 * {@link Debug#sandbox(CharSequence, DebugConfig, Object...)}. Leaving the scope is achieved |
151 * via {@link #close()}. | |
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
|
152 */ |
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 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
|
154 void close(); |
5009
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
155 } |
e3cc0d407bc6
Allow Debug context with multiple objects
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4579
diff
changeset
|
156 |
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
|
157 /** |
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 * 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
|
159 * <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
|
160 * 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
|
161 * debug scopes. For example: |
14779 | 162 * |
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
|
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 * try (Scope s = Debug.scope("InliningGraph", 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
|
165 * ... |
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 * } 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
|
167 * 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
|
168 * } |
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 * </pre> |
14779 | 170 * |
14620
a0baf4eeb018
removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
171 * The {@code name} argument is subject to the following type based conversion before having |
a0baf4eeb018
removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
172 * {@link Object#toString()} called on it: |
14779 | 173 * |
14620
a0baf4eeb018
removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
174 * <pre> |
a0baf4eeb018
removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
175 * Type | Conversion |
a0baf4eeb018
removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
176 * ------------------+----------------- |
a0baf4eeb018
removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
177 * java.lang.Class | arg.getSimpleName() |
a0baf4eeb018
removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
178 * | |
a0baf4eeb018
removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
179 * </pre> |
14779 | 180 * |
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
|
181 * @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
|
182 * @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
|
183 * 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
|
184 */ |
14624
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
185 public static Scope scope(Object name) { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
186 if (ENABLED) { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
187 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null); |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
188 } else { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
189 return null; |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
190 } |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
191 } |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
192 |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
193 /** |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
194 * @see #scope(Object) |
15140
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
195 * @param contextObjects an array of object to be appended to the {@linkplain #context() |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
196 * current} debug context |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
197 */ |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
198 public static Scope scope(Object name, Object[] contextObjects) { |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
199 if (ENABLED) { |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
200 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, contextObjects); |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
201 } else { |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
202 return null; |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
203 } |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
204 } |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
205 |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
206 /** |
393935e524e9
Fix inlining scoping: add a Debug.scope(Object name, Object[] contextObjects) method so that inlining can put all the necessary methods in the context.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15116
diff
changeset
|
207 * @see #scope(Object) |
14624
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
208 * @param context an object to be appended to the {@linkplain #context() current} debug context |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
209 */ |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
210 public static Scope scope(Object name, Object context) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
211 if (ENABLED) { |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
212 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context); |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
213 } 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
|
214 return null; |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
215 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
216 } |
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
217 |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
218 /** |
14624
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
219 * @see #scope(Object) |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
220 * @param context1 first object to be appended to the {@linkplain #context() current} debug |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
221 * context |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
222 * @param context2 second object to be appended to the {@linkplain #context() current} debug |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
223 * context |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
224 */ |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
225 public static Scope scope(Object name, Object context1, Object context2) { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
226 if (ENABLED) { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
227 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context1, context2); |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
228 } else { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
229 return null; |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
230 } |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
231 } |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
232 |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
233 /** |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
234 * @see #scope(Object) |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
235 * @param context1 first object to be appended to the {@linkplain #context() current} debug |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
236 * context |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
237 * @param context2 second object to be appended to the {@linkplain #context() current} debug |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
238 * context |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
239 * @param context3 third object to be appended to the {@linkplain #context() current} debug |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
240 * context |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
241 */ |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
242 public static Scope scope(Object name, Object context1, Object context2, Object context3) { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
243 if (ENABLED) { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
244 return DebugScope.getInstance().scope(convertFormatArg(name).toString(), null, context1, context2, context3); |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
245 } else { |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
246 return null; |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
247 } |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
248 } |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
249 |
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
250 /** |
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
|
251 * 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
|
252 * <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
|
253 * 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
|
254 * debug scopes. For example: |
14779 | 255 * |
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
|
256 * <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
|
257 * try (Scope s = Debug.sandbox("CompilingStub", 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
|
258 * ... |
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
|
259 * } 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
|
260 * 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
|
261 * } |
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
|
262 * </pre> |
14779 | 263 * |
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
|
264 * @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
|
265 * @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
|
266 * @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
|
267 * @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
|
268 * 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
|
269 */ |
14586
d2fe05d5cc96
added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents:
14582
diff
changeset
|
270 public static Scope sandbox(CharSequence name, DebugConfig config, Object... 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
|
271 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
|
272 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
|
273 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
|
274 } 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
|
275 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
|
276 } |
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
|
277 } |
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
|
278 |
14109
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13551
diff
changeset
|
279 public static Scope forceLog() { |
15851
94a2df2f8e58
preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15665
diff
changeset
|
280 ArrayList<Object> context = new ArrayList<>(); |
94a2df2f8e58
preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15665
diff
changeset
|
281 for (Object obj : context()) { |
94a2df2f8e58
preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15665
diff
changeset
|
282 context.add(obj); |
94a2df2f8e58
preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15665
diff
changeset
|
283 } |
94a2df2f8e58
preserve context in Debug.forceLog
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15665
diff
changeset
|
284 return Debug.sandbox("forceLog", new DelegatingDebugConfig().enable(LOG).enable(LOG_METHOD), context.toArray()); |
14109
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13551
diff
changeset
|
285 } |
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13551
diff
changeset
|
286 |
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
|
287 /** |
15116
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
288 * Opens a scope in which exception {@linkplain DebugConfig#interceptException(Throwable) |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
289 * interception} is disabled. It is recommended to use the try-with-resource statement for |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
290 * managing entering and leaving such scopes: |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
291 * |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
292 * <pre> |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
293 * try (DebugConfigScope s = Debug.disableIntercept()) { |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
294 * ... |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
295 * } |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
296 * </pre> |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
297 * |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
298 * This is particularly useful to suppress extraneous output in JUnit tests that are expected to |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
299 * throw an exception. |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
300 */ |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
301 public static DebugConfigScope disableIntercept() { |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
302 return Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT)); |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
303 } |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
304 |
0d296283e87d
HSAIL: suppressed output in unit tests
Doug Simon <doug.simon@oracle.com>
parents:
15115
diff
changeset
|
305 /** |
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
|
306 * 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
|
307 * must have the current scope as its parent which will be the case if the try-with-resource |
14624
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
308 * pattern recommended by {@link #scope(Object)} and |
14906 | 309 * {@link #sandbox(CharSequence, DebugConfig, Object...)} is used |
14779 | 310 * |
14624
f3510d0dcf67
removed use of varargs from Debug.scope() API
Doug Simon <doug.simon@oracle.com>
parents:
14620
diff
changeset
|
311 * @see #scope(Object) |
14906 | 312 * @see #sandbox(CharSequence, DebugConfig, Object...) |
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
|
313 */ |
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
|
314 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
|
315 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
|
316 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
|
317 } 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
|
318 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
|
319 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
|
320 } |
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
|
321 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
|
322 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
|
323 } |
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
|
324 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
|
325 } |
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
|
326 } |
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
|
327 |
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
|
328 /** |
14625
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
329 * Prints a message to the current debug scope's logging stream if logging is enabled. |
14779 | 330 * |
14625
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
331 * @param msg the message to log |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
332 */ |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
333 public static void log(String msg) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
334 if (ENABLED) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
335 DebugScope.getInstance().log(msg); |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
336 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
337 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
338 |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
339 /** |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
340 * Prints a message to the current debug scope's logging stream if logging is enabled. |
14779 | 341 * |
14625
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
342 * @param format a format string |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
343 * @param arg the argument referenced by the format specifiers in {@code format} |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
344 */ |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
345 public static void log(String format, Object arg) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
346 if (ENABLED) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
347 DebugScope.getInstance().log(format, arg); |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
348 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
349 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
350 |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
351 /** |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
352 * @see #log(String, Object) |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
353 */ |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
354 public static void log(String format, Object arg1, Object arg2) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
355 if (ENABLED) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
356 DebugScope.getInstance().log(format, arg1, arg2); |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
357 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
358 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
359 |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
360 /** |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
361 * @see #log(String, Object) |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
362 */ |
14625
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
363 public static void log(String format, Object arg1, Object arg2, Object arg3) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
364 if (ENABLED) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
365 DebugScope.getInstance().log(format, arg1, arg2, arg3); |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
366 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
367 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
368 |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
369 /** |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
370 * @see #log(String, Object) |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
371 */ |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
372 public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4) { |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
373 if (ENABLED) { |
14625
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
374 DebugScope.getInstance().log(format, arg1, arg2, arg3, arg4); |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
375 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
376 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
377 |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
378 /** |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
379 * @see #log(String, Object) |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
380 */ |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
381 public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
382 if (ENABLED) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
383 DebugScope.getInstance().log(format, arg1, arg2, arg3, arg4, arg5); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
384 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
385 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
386 |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
387 /** |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
388 * @see #log(String, Object) |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
389 */ |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
390 public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
391 if (ENABLED) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
392 DebugScope.getInstance().log(format, arg1, arg2, arg3, arg4, arg5, arg6); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
393 } |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
394 } |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
395 |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
396 /** |
14625
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
397 * Prints a message to the current debug scope's logging stream. This method must only be called |
14634
2496f9f49f6b
improved javadoc for Debug.logv() to explain why it should be avoided
Doug Simon <doug.simon@oracle.com>
parents:
14625
diff
changeset
|
398 * if debugging is {@linkplain Debug#isEnabled() enabled} as it incurs allocation at the call |
2496f9f49f6b
improved javadoc for Debug.logv() to explain why it should be avoided
Doug Simon <doug.simon@oracle.com>
parents:
14625
diff
changeset
|
399 * site. If possible, call one of the other {@code log()} methods in this class that take a |
2496f9f49f6b
improved javadoc for Debug.logv() to explain why it should be avoided
Doug Simon <doug.simon@oracle.com>
parents:
14625
diff
changeset
|
400 * fixed number of parameters. |
14779 | 401 * |
14625
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
402 * @param format a format string |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
403 * @param args the arguments referenced by the format specifiers in {@code format} |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
404 */ |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
405 public static void logv(String format, Object... args) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
406 if (!ENABLED) { |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
407 throw new InternalError("Use of Debug.logv() must be guarded by a test of Debug.isEnabled()"); |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
408 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
409 DebugScope.getInstance().log(format, args); |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
410 } |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
411 |
3ab42370f636
removed use of varargs from Debug.log() API
Doug Simon <doug.simon@oracle.com>
parents:
14624
diff
changeset
|
412 /** |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
413 * This override exists to catch cases when {@link #log(String, Object)} is called with one |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
414 * argument bound to a varargs method parameter. It will bind to this method instead of the |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
415 * single arg variant and produce a deprecation warning instead of silently wrapping the |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
416 * Object[] inside of another Object[]. |
14719
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14634
diff
changeset
|
417 */ |
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14634
diff
changeset
|
418 @Deprecated |
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14634
diff
changeset
|
419 public static void log(String format, Object[] args) { |
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14634
diff
changeset
|
420 assert false : "shouldn't use this"; |
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14634
diff
changeset
|
421 logv(format, args); |
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14634
diff
changeset
|
422 } |
0bdd0d157040
fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14634
diff
changeset
|
423 |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
424 public static void dump(Object object, String msg) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
425 if (ENABLED && DebugScope.getInstance().isDumpEnabled()) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
426 DebugScope.getInstance().dump(object, msg); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
427 } |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
428 } |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
429 |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
430 public static void dump(Object object, String format, Object arg) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
431 if (ENABLED && DebugScope.getInstance().isDumpEnabled()) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
432 DebugScope.getInstance().dump(object, format, arg); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
433 } |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
434 } |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
435 |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
436 public static void dump(Object object, String format, Object arg1, Object arg2) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
437 if (ENABLED && DebugScope.getInstance().isDumpEnabled()) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
438 DebugScope.getInstance().dump(object, format, arg1, arg2); |
10923 | 439 } |
440 } | |
441 | |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
442 public static void dump(Object object, String format, Object arg1, Object arg2, Object arg3) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
443 if (ENABLED && DebugScope.getInstance().isDumpEnabled()) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
444 DebugScope.getInstance().dump(object, format, arg1, arg2, arg3); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
445 } |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
446 } |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
447 |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
448 /** |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
449 * This override exists to catch cases when {@link #dump(Object, String, Object)} is called with |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
450 * one argument bound to a varargs method parameter. It will bind to this method instead of the |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
451 * single arg variant and produce a deprecation warning instead of silently wrapping the |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
452 * Object[] inside of another Object[]. |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
453 */ |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
454 @Deprecated |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
455 public static void dump(Object object, String format, Object[] args) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
456 assert false : "shouldn't use this"; |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
457 if (ENABLED && DebugScope.getInstance().isDumpEnabled()) { |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14871
diff
changeset
|
458 DebugScope.getInstance().dump(object, format, args); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
459 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
460 } |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
461 |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
462 /** |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
463 * Opens a new indentation level (by adding some spaces) based on the current indentation level. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
464 * This should be used in a {@linkplain Indent try-with-resources} pattern. |
14779 | 465 * |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
466 * @return an object that reverts to the current indentation level when |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
467 * {@linkplain Indent#close() closed} or null if debugging is disabled |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
468 * @see #logAndIndent(String) |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
469 * @see #logAndIndent(String, Object) |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
470 */ |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
471 public static Indent indent() { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
472 if (ENABLED) { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
473 DebugScope scope = DebugScope.getInstance(); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
474 return scope.pushIndentLogger(); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
475 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
476 return null; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
477 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
478 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
479 /** |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
480 * A convenience function which combines {@link #log(String)} and {@link #indent()}. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
481 * |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
482 * @param msg the message to log |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
483 * @return an object that reverts to the current indentation level when |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
484 * {@linkplain Indent#close() closed} or null if debugging is disabled |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
485 */ |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
486 public static Indent logAndIndent(String msg) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
487 if (ENABLED) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
488 return logvAndIndent(msg); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
489 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
490 return null; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
491 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
492 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
493 /** |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
494 * A convenience function which combines {@link #log(String, Object)} and {@link #indent()}. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
495 * |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
496 * @param format a format string |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
497 * @param arg the argument referenced by the format specifiers in {@code format} |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
498 * @return an object that reverts to the current indentation level when |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
499 * {@linkplain Indent#close() closed} or null if debugging is disabled |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
500 */ |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
501 public static Indent logAndIndent(String format, Object arg) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
502 if (ENABLED) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
503 return logvAndIndent(format, arg); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
504 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
505 return null; |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
506 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
507 |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
508 /** |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
509 * @see #logAndIndent(String, Object) |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
510 */ |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
511 public static Indent logAndIndent(String format, Object arg1, Object arg2) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
512 if (ENABLED) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
513 return logvAndIndent(format, arg1, arg2); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
514 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
515 return null; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
516 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
517 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
518 /** |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
519 * @see #logAndIndent(String, Object) |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
520 */ |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
521 public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
522 if (ENABLED) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
523 return logvAndIndent(format, arg1, arg2, arg3); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
524 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
525 return null; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
526 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
527 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
528 /** |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
529 * A convenience function which combines {@link #logv(String, Object...)} and {@link #indent()}. |
14779 | 530 * |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
531 * @param format a format string |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
532 * @param args the arguments referenced by the format specifiers in {@code format} |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
533 * @return an object that reverts to the current indentation level when |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
534 * {@linkplain Indent#close() closed} or null if debugging is disabled |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
535 */ |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
536 public static Indent logvAndIndent(String format, Object... args) { |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
537 if (ENABLED) { |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
538 DebugScope scope = DebugScope.getInstance(); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
539 scope.log(format, args); |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
540 return scope.pushIndentLogger(); |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
541 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
542 throw new InternalError("Use of Debug.logvAndIndent() must be guarded by a test of Debug.isEnabled()"); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
543 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
544 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
545 /** |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
546 * This override exists to catch cases when {@link #logAndIndent(String, Object)} is called with |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
547 * one argument bound to a varargs method parameter. It will bind to this method instead of the |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
548 * single arg variant and produce a deprecation warning instead of silently wrapping the |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
549 * Object[] inside of another Object[]. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
550 */ |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
551 @Deprecated |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
552 public static void logAndIndent(String format, Object[] args) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
553 assert false : "shouldn't use this"; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14779
diff
changeset
|
554 logvAndIndent(format, args); |
11382
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
555 } |
d7d12ef788ba
add logging with indentation in graal.Debug
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10923
diff
changeset
|
556 |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
557 public static Iterable<Object> context() { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
558 if (ENABLED) { |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
559 return DebugScope.getInstance().getCurrentContext(); |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
560 } else { |
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4349
diff
changeset
|
561 return Collections.emptyList(); |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
562 } |
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
563 } |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
564 |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
565 @SuppressWarnings("unchecked") |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
566 public static <T> List<T> contextSnapshot(Class<T> clazz) { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
567 if (ENABLED) { |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
568 List<T> result = new ArrayList<>(); |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
569 for (Object o : context()) { |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
570 if (clazz.isInstance(o)) { |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
571 result.add((T) o); |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
572 } |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
573 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
574 return result; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
575 } else { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
576 return Collections.emptyList(); |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
577 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
578 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
579 |
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
|
580 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6584
diff
changeset
|
581 * 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
|
582 * 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
|
583 */ |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
584 @SuppressWarnings("unchecked") |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
585 public static <T> T contextLookup(Class<T> clazz) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
586 if (ENABLED) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
587 for (Object o : context()) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
588 if (clazz.isInstance(o)) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
589 return ((T) o); |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
590 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
591 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
592 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
593 return null; |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
594 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
595 |
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
|
596 /** |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
597 * Creates a {@linkplain DebugMemUseTracker memory use tracker} that is enabled iff debugging is |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
598 * {@linkplain #isEnabled() enabled}. |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
599 * <p> |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
600 * A disabled tracker has virtually no overhead. |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
601 */ |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
602 public static DebugMemUseTracker memUseTracker(CharSequence name) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
603 if (!ENABLED) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
604 return VOID_MEM_USE_TRACKER; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
605 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
606 return createMemUseTracker("%s", name, null); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
607 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
608 |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
609 /** |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
610 * Creates a debug memory use tracker. Invoking this method is equivalent to: |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
611 * |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
612 * <pre> |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
613 * Debug.memUseTracker(format, arg, null) |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
614 * </pre> |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
615 * |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
616 * except that the string formatting only happens if metering is enabled. |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
617 * |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
618 * @see #metric(String, Object, Object) |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
619 */ |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
620 public static DebugMemUseTracker memUseTracker(String format, Object arg) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
621 if (!ENABLED) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
622 return VOID_MEM_USE_TRACKER; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
623 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
624 return createMemUseTracker(format, arg, null); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
625 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
626 |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
627 /** |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
628 * Creates a debug memory use tracker. Invoking this method is equivalent to: |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
629 * |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
630 * <pre> |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
631 * Debug.memUseTracker(String.format(format, arg1, arg2)) |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
632 * </pre> |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
633 * |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
634 * except that the string formatting only happens if memory use tracking is enabled. In |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
635 * addition, each argument is subject to the following type based conversion before being passed |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
636 * as an argument to {@link String#format(String, Object...)}: |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
637 * |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
638 * <pre> |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
639 * Type | Conversion |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
640 * ------------------+----------------- |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
641 * java.lang.Class | arg.getSimpleName() |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
642 * | |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
643 * </pre> |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
644 * |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
645 * @see #memUseTracker(CharSequence) |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
646 */ |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
647 public static DebugMemUseTracker memUseTracker(String format, Object arg1, Object arg2) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
648 if (!ENABLED) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
649 return VOID_MEM_USE_TRACKER; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
650 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
651 return createMemUseTracker(format, arg1, arg2); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
652 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
653 |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
654 private static DebugMemUseTracker createMemUseTracker(String format, Object arg1, Object arg2) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
655 String name = formatDebugName(format, arg1, arg2); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
656 return new MemUseTrackerImpl(name); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
657 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
658 |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
659 /** |
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
|
660 * 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
|
661 * {@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
|
662 * {@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
|
663 * {@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
|
664 * 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
|
665 * 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
|
666 * <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
|
667 * 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
|
668 */ |
14586
d2fe05d5cc96
added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents:
14582
diff
changeset
|
669 public static DebugMetric metric(CharSequence name) { |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
670 if (enabledMetrics == null && !ENABLED) { |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
671 return VOID_METRIC; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
672 } |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
673 return createMetric("%s", name, null); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
674 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
675 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
676 public static String applyFormattingFlagsAndWidth(String s, int flags, int width) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
677 if (flags == 0 && width < 0) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
678 return s; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
679 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
680 StringBuilder sb = new StringBuilder(s); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
681 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
682 // apply width and justification |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
683 int len = sb.length(); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
684 if (len < width) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
685 for (int i = 0; i < width - len; i++) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
686 if ((flags & LEFT_JUSTIFY) == LEFT_JUSTIFY) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
687 sb.append(' '); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
688 } else { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
689 sb.insert(0, ' '); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
690 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
691 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
692 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
693 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
694 String res = sb.toString(); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
695 if ((flags & UPPERCASE) == UPPERCASE) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
696 res = res.toUpperCase(); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
697 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
698 return res; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
699 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
700 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
701 /** |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
702 * Creates a debug metric. Invoking this method is equivalent to: |
14779 | 703 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
704 * <pre> |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
705 * Debug.metric(format, arg, null) |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
706 * </pre> |
14779 | 707 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
708 * except that the string formatting only happens if metering is enabled. |
14779 | 709 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
710 * @see #metric(String, Object, Object) |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
711 */ |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
712 public static DebugMetric metric(String format, Object arg) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
713 if (enabledMetrics == null && !ENABLED) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
714 return VOID_METRIC; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
715 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
716 return createMetric(format, arg, null); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
717 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
718 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
719 /** |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
720 * Creates a debug metric. Invoking this method is equivalent to: |
14779 | 721 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
722 * <pre> |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
723 * Debug.metric(String.format(format, arg1, arg2)) |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
724 * </pre> |
14779 | 725 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
726 * except that the string formatting only happens if metering is enabled. In addition, each |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
727 * argument is subject to the following type based conversion before being passed as an argument |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
728 * to {@link String#format(String, Object...)}: |
14779 | 729 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
730 * <pre> |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
731 * Type | Conversion |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
732 * ------------------+----------------- |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
733 * java.lang.Class | arg.getSimpleName() |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
734 * | |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
735 * </pre> |
14779 | 736 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
737 * @see #metric(CharSequence) |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
738 */ |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
739 public static DebugMetric metric(String format, Object arg1, Object arg2) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
740 if (enabledMetrics == null && !ENABLED) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
741 return VOID_METRIC; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
742 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
743 return createMetric(format, arg1, arg2); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
744 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
745 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
746 private static DebugMetric createMetric(String format, Object arg1, Object arg2) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
747 String name = formatDebugName(format, arg1, arg2); |
15665
4ead444b15aa
Fix inverted condition in Debug.create(Metric|Timer)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15581
diff
changeset
|
748 boolean conditional = enabledMetrics == null || !enabledMetrics.contains(name); |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
749 return new MetricImpl(name, conditional); |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
750 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
751 |
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
|
752 /** |
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
|
753 * Changes the debug configuration for the current thread. |
14779 | 754 * |
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
|
755 * @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
|
756 * @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
|
757 * 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
|
758 * 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
|
759 */ |
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
|
760 public static DebugConfigScope setConfig(DebugConfig config) { |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
761 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
|
762 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
|
763 } 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
|
764 return null; |
4357
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
765 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
766 } |
719ac1d92a52
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4356
diff
changeset
|
767 |
11551
63b4694d3627
split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
768 /** |
63b4694d3627
split DebugHistogram printing out into separate service
Doug Simon <doug.simon@oracle.com>
parents:
11382
diff
changeset
|
769 * 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
|
770 */ |
9103
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7557
diff
changeset
|
771 public static DebugHistogram createHistogram(String name) { |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7557
diff
changeset
|
772 return new DebugHistogramImpl(name); |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7557
diff
changeset
|
773 } |
e7541d478e38
Added DebugHistory utility and corresponding unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7557
diff
changeset
|
774 |
13189
f444a67ecbae
Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents:
13163
diff
changeset
|
775 public static DebugConfig silentConfig() { |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
776 return fixedConfig(false, false, false, false, false, Collections.<DebugDumpHandler> emptyList(), System.out); |
13189
f444a67ecbae
Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents:
13163
diff
changeset
|
777 } |
f444a67ecbae
Debug: use silent debug config for sandbox
Bernhard Urban <bernhard.urban@jku.at>
parents:
13163
diff
changeset
|
778 |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
779 public static DebugConfig fixedConfig(final boolean isLogEnabled, final boolean isDumpEnabled, final boolean isMeterEnabled, final boolean isMemUseTrackingEnabled, final boolean isTimerEnabled, |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6584
diff
changeset
|
780 final Collection<DebugDumpHandler> dumpHandlers, final PrintStream output) { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
781 return new DebugConfig() { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
782 |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
783 @Override |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
784 public boolean isLogEnabled() { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
785 return isLogEnabled; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
786 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
787 |
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
|
788 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
|
789 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
|
790 } |
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
|
791 |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
792 @Override |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
793 public boolean isMeterEnabled() { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
794 return isMeterEnabled; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
795 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
796 |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
797 @Override |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
798 public boolean isMemUseTrackingEnabled() { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
799 return isMemUseTrackingEnabled; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
800 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
801 |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
802 @Override |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
803 public boolean isDumpEnabled() { |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
804 return isDumpEnabled; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
805 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
806 |
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
|
807 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
|
808 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
|
809 } |
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
|
810 |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
811 @Override |
4394
cf609017d3d4
Fixed warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4369
diff
changeset
|
812 public boolean isTimeEnabled() { |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
813 return isTimerEnabled; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
814 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
815 |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
816 @Override |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
817 public RuntimeException interceptException(Throwable e) { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
818 return null; |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
819 } |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
820 |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
821 @Override |
6584
a3eb814ea564
added more javadoc to DebugConfig interface
Doug Simon <doug.simon@oracle.com>
parents:
5620
diff
changeset
|
822 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
|
823 return dumpHandlers; |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4361
diff
changeset
|
824 } |
5302
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5251
diff
changeset
|
825 |
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5251
diff
changeset
|
826 @Override |
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5251
diff
changeset
|
827 public PrintStream output() { |
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5251
diff
changeset
|
828 return output; |
55bf72fafc41
(preliminary) logging to file (-G:LogFile=asdf.txt)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5251
diff
changeset
|
829 } |
5620
2a44192a8b24
added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents:
5302
diff
changeset
|
830 |
2a44192a8b24
added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents:
5302
diff
changeset
|
831 @Override |
2a44192a8b24
added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents:
5302
diff
changeset
|
832 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
|
833 } |
2a44192a8b24
added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents:
5302
diff
changeset
|
834 |
2a44192a8b24
added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents:
5302
diff
changeset
|
835 @Override |
2a44192a8b24
added support for extending the filtering context of a DebugConfig
Doug Simon <doug.simon@oracle.com>
parents:
5302
diff
changeset
|
836 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
|
837 } |
4361
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
838 }; |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
839 } |
18b52fec79f1
Completed exception interception.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4357
diff
changeset
|
840 |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
841 private static final DebugMetric VOID_METRIC = new DebugMetric() { |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
842 |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
843 public void increment() { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
844 } |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
845 |
7557
db90c8b5a861
changed DebugMetric.add() to take a long parameter instead of an int
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
846 public void add(long value) { |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
847 } |
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
|
848 |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
11551
diff
changeset
|
849 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
|
850 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
|
851 } |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
11551
diff
changeset
|
852 |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
11551
diff
changeset
|
853 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
|
854 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
|
855 } |
12778
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
856 |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
857 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
|
858 return 0L; |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
859 } |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
860 }; |
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
861 |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
862 private static final DebugMemUseTracker VOID_MEM_USE_TRACKER = new DebugMemUseTracker() { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
863 |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
864 public Closeable start() { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
865 return MemUseTrackerImpl.VOID_CLOSEABLE; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
866 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
867 |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
868 public long getCurrentValue() { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
869 return 0; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
870 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
871 }; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
872 |
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
|
873 /** |
14586
d2fe05d5cc96
added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents:
14582
diff
changeset
|
874 * @see #timer(CharSequence) |
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
|
875 */ |
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
|
876 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
|
877 |
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
|
878 /** |
14586
d2fe05d5cc96
added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents:
14582
diff
changeset
|
879 * @see #metric(CharSequence) |
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
|
880 */ |
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
|
881 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
|
882 |
14582
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
883 private static final Set<String> enabledMetrics; |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
884 private static final Set<String> enabledTimers; |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
885 static { |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
886 Set<String> metrics = new HashSet<>(); |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
887 Set<String> timers = new HashSet<>(); |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
888 for (Map.Entry<Object, Object> e : System.getProperties().entrySet()) { |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
889 String name = e.getKey().toString(); |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
890 if (name.startsWith(ENABLE_METRIC_PROPERTY_NAME_PREFIX) && Boolean.parseBoolean(e.getValue().toString())) { |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
891 metrics.add(name.substring(ENABLE_METRIC_PROPERTY_NAME_PREFIX.length())); |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
892 } |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
893 if (name.startsWith(ENABLE_TIMER_PROPERTY_NAME_PREFIX) && Boolean.parseBoolean(e.getValue().toString())) { |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
894 timers.add(name.substring(ENABLE_TIMER_PROPERTY_NAME_PREFIX.length())); |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
895 } |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
896 } |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
897 enabledMetrics = metrics.isEmpty() ? null : metrics; |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
898 enabledTimers = timers.isEmpty() ? null : timers; |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
899 } |
5fc6b8b54d82
reduced overhead of Debug.metric() and Debug.timer() when no metrics or timers are enabled
Doug Simon <doug.simon@oracle.com>
parents:
14109
diff
changeset
|
900 |
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
|
901 /** |
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
|
902 * 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
|
903 * {@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
|
904 * {@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
|
905 * {@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
|
906 * 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
|
907 * 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
|
908 * <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
|
909 * 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
|
910 */ |
14586
d2fe05d5cc96
added support for lazy computation of names for use with Debug
Doug Simon <doug.simon@oracle.com>
parents:
14582
diff
changeset
|
911 public static DebugTimer timer(CharSequence name) { |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
912 if (enabledTimers == null && !ENABLED) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
913 return VOID_TIMER; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
914 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
915 return createTimer("%s", name, null); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
916 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
917 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
918 /** |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
919 * Creates a debug timer. Invoking this method is equivalent to: |
14779 | 920 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
921 * <pre> |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
922 * Debug.timer(format, arg, null) |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
923 * </pre> |
14779 | 924 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
925 * except that the string formatting only happens if timing is enabled. |
14779 | 926 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
927 * @see #timer(String, Object, Object) |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
928 */ |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
929 public static DebugTimer timer(String format, Object arg) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
930 if (enabledTimers == null && !ENABLED) { |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
931 return VOID_TIMER; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
932 } |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
933 return createTimer(format, arg, null); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
934 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
935 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
936 /** |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
937 * Creates a debug timer. Invoking this method is equivalent to: |
14779 | 938 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
939 * <pre> |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
940 * Debug.timer(String.format(format, arg1, arg2)) |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
941 * </pre> |
14779 | 942 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
943 * except that the string formatting only happens if timing is enabled. In addition, each |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
944 * argument is subject to the following type based conversion before being passed as an argument |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
945 * to {@link String#format(String, Object...)}: |
14779 | 946 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
947 * <pre> |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
948 * Type | Conversion |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
949 * ------------------+----------------- |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
950 * java.lang.Class | arg.getSimpleName() |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
951 * | |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
952 * </pre> |
14779 | 953 * |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
954 * @see #timer(CharSequence) |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
955 */ |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
956 public static DebugTimer timer(String format, Object arg1, Object arg2) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
957 if (enabledTimers == null && !ENABLED) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
958 return VOID_TIMER; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
959 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
960 return createTimer(format, arg1, arg2); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
961 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
962 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
963 public static Object convertFormatArg(Object arg) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
964 if (arg instanceof Class) { |
15581
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
965 Class<?> c = (Class<?>) arg; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
966 final String simpleName = c.getSimpleName(); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
967 Class<?> enclosingClass = c.getEnclosingClass(); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
968 if (enclosingClass != null) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
969 String prefix = ""; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
970 while (enclosingClass != null) { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
971 prefix = enclosingClass.getSimpleName() + "_" + prefix; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
972 enclosingClass = enclosingClass.getEnclosingClass(); |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
973 } |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
974 return prefix + simpleName; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
975 } else { |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
976 return simpleName; |
0dc0926cf0d8
added -G:TrackMemUse for measuring memory usage within scopes
Doug Simon <doug.simon@oracle.com>
parents:
15140
diff
changeset
|
977 } |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
978 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
979 return arg; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
980 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
981 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
982 private static String formatDebugName(String format, Object arg1, Object arg2) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
983 return String.format(format, convertFormatArg(arg1), convertFormatArg(arg2)); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
984 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
985 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
986 private static DebugTimer createTimer(String format, Object arg1, Object arg2) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
987 String name = formatDebugName(format, arg1, arg2); |
15665
4ead444b15aa
Fix inverted condition in Debug.create(Metric|Timer)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15581
diff
changeset
|
988 boolean conditional = enabledTimers == null || !enabledTimers.contains(name); |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14586
diff
changeset
|
989 return new TimerImpl(name, conditional); |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
990 } |
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
991 |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4353
diff
changeset
|
992 private static final DebugTimer VOID_TIMER = new DebugTimer() { |
4477
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
993 |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
994 public TimerCloseable start() { |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
995 return TimerImpl.VOID_CLOSEABLE; |
27c5466afd55
Changes to debug framework.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
996 } |
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
|
997 |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
11551
diff
changeset
|
998 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
|
999 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
|
1000 } |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
11551
diff
changeset
|
1001 |
6b6c6e5d0fc2
added support for DebugMetric and DebugTimer objects to be unconditionally enabled (GRAAL-195)
Doug Simon <doug.simon@oracle.com>
parents:
11551
diff
changeset
|
1002 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
|
1003 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
|
1004 } |
12778
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
1005 |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
1006 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
|
1007 return 0L; |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
1008 } |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
1009 |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
1010 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
|
1011 return null; |
c125485642e2
added getCurrentValue() to both DebugTimer and DebugValue; added getTimeUnit() to DebugTimer
Doug Simon <doug.simon@oracle.com>
parents:
12776
diff
changeset
|
1012 } |
4349
7e974a026889
More work on debug framework.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4348
diff
changeset
|
1013 }; |
4343
f03c71a0aeb8
Added draft debug classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1014 } |