Mercurial > hg > graal-compiler
annotate graal/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/DebugEnvironment.java @ 21780:3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 15:47:54 +0200 |
parents | graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java@b1530a6cce8c |
children | 5b9adb645217 |
rev | line source |
---|---|
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
23 package com.oracle.jvmci.debug; |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
25 import static com.oracle.jvmci.debug.JVMCIDebugConfig.*; |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
26 |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import java.io.*; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
30 import com.oracle.jvmci.service.*; |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 public class DebugEnvironment { |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
34 public static JVMCIDebugConfig initialize(PrintStream log) { |
15591
55977f9fa56f
fixed assertion position and documented critical class initialization dependency
Doug Simon <doug.simon@oracle.com>
parents:
15590
diff
changeset
|
35 |
55977f9fa56f
fixed assertion position and documented critical class initialization dependency
Doug Simon <doug.simon@oracle.com>
parents:
15590
diff
changeset
|
36 // Ensure Graal runtime is initialized prior to Debug being initialized as the former |
16106
5d84706642ce
ensure a DebugEnvironment is initialized for native compiler threads
Doug Simon <doug.simon@oracle.com>
parents:
15591
diff
changeset
|
37 // may include processing command line options used by the latter. |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
38 // Graal.getRuntime(); |
15591
55977f9fa56f
fixed assertion position and documented critical class initialization dependency
Doug Simon <doug.simon@oracle.com>
parents:
15590
diff
changeset
|
39 |
11611
a27678c47948
made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents:
11379
diff
changeset
|
40 if (!Debug.isEnabled()) { |
11612
54dff87002e0
check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents:
11611
diff
changeset
|
41 log.println("WARNING: Scope debugging needs to be enabled with -esa or -D" + Debug.Initialization.INITIALIZER_PROPERTY_NAME + "=true"); |
12611
63c378b7c1c3
made Truffle compiler threads be named and have a debug configuration
Doug Simon <doug.simon@oracle.com>
parents:
11612
diff
changeset
|
42 return null; |
11611
a27678c47948
made Debug.ENABLED static (i.e. a compile-time constant)
Doug Simon <doug.simon@oracle.com>
parents:
11379
diff
changeset
|
43 } |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 List<DebugDumpHandler> dumpHandlers = new ArrayList<>(); |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
45 List<DebugVerifyHandler> verifyHandlers = new ArrayList<>(); |
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
46 JVMCIDebugConfig debugConfig = new JVMCIDebugConfig(Log.getValue(), Meter.getValue(), TrackMemUse.getValue(), Time.getValue(), Dump.getValue(), Verify.getValue(), MethodFilter.getValue(), |
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
47 log, dumpHandlers, verifyHandlers); |
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
48 |
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
49 for (DebugConfigCustomizer customizer : Services.load(DebugConfigCustomizer.class)) { |
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
50 customizer.customize(debugConfig); |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 } |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21554
diff
changeset
|
52 |
12611
63c378b7c1c3
made Truffle compiler threads be named and have a debug configuration
Doug Simon <doug.simon@oracle.com>
parents:
11612
diff
changeset
|
53 Debug.setConfig(debugConfig); |
63c378b7c1c3
made Truffle compiler threads be named and have a debug configuration
Doug Simon <doug.simon@oracle.com>
parents:
11612
diff
changeset
|
54 return debugConfig; |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 } |
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 } |