annotate graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/CompilationTask.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.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java@77acf6ba2fc0
children 5b9adb645217
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
8f4f0ebffca2 Move compilation task logic to separate class.
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: 21631
diff changeset
23 package com.oracle.jvmci.hotspot;
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
21541
5e868236654f moved UnsafeAccess to com.oracle.jvmci.common (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21527
diff changeset
25 import static com.oracle.jvmci.common.UnsafeAccess.*;
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
26 import static com.oracle.jvmci.debug.Debug.*;
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
27 import static com.oracle.jvmci.compiler.Compiler.*;
7361
b79ad92d5a26 compile the intrinsic graph for a method if the method is scheduled for compilation (in addition to intrinsifiying it when it is called)
Doug Simon <doug.simon@oracle.com>
parents: 6963
diff changeset
28
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
29 import java.lang.management.*;
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.util.concurrent.*;
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
21562
Doug Simon <doug.simon@oracle.com>
parents: 21559 21522
diff changeset
32 import com.oracle.jvmci.code.*;
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
33 import com.oracle.jvmci.compiler.Compiler;
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
34 import com.oracle.jvmci.debug.*;
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
35 import com.oracle.jvmci.debug.Debug.Scope;
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
36 import com.oracle.jvmci.debug.internal.*;
21631
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
37 import com.oracle.jvmci.hotspot.events.*;
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
38 import com.oracle.jvmci.hotspot.events.EventProvider.CompilationEvent;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
39 import com.oracle.jvmci.hotspot.events.EventProvider.CompilerFailureEvent;
21562
Doug Simon <doug.simon@oracle.com>
parents: 21559 21522
diff changeset
40 import com.oracle.jvmci.meta.*;
21631
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
41 import com.oracle.jvmci.service.*;
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42
16015
19a48d9834e1 exclude CompilationTask from JaCoCo
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
43 //JaCoCo Exclude
19a48d9834e1 exclude CompilationTask from JaCoCo
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
44
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
45 public class CompilationTask {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
46
14016
555867401850 Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13912
diff changeset
47 private static final DebugMetric BAILOUTS = Debug.metric("Bailouts");
555867401850 Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13912
diff changeset
48
21631
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
49 private static final EventProvider eventProvider;
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
50 static {
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
51 EventProvider provider = Services.loadSingle(EventProvider.class, false);
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
52 if (provider == null) {
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
53 eventProvider = new EmptyEventProvider();
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
54 } else {
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
55 eventProvider = provider;
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
56 }
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
57 }
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
58 private static final Compiler compiler = Services.loadSingle(Compiler.class, true);
21631
77acf6ba2fc0 Move EventProvider to jvmci.hotspot, make it a JVMCI Service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21630
diff changeset
59
5554
70f715dfbb41 Bring Java renamings and restructurings to the C++ part.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5548
diff changeset
60 private final HotSpotResolvedJavaMethod method;
6677
3dddb311395f hotspot infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6676
diff changeset
61 private final int entryBCI;
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
62 private final int id;
15695
128359d7cddc once the Graal compilation queue has been shutdown, don't process any pending compilations and be more defensive about preventing future compilations to be queued
Doug Simon <doug.simon@oracle.com>
parents: 15663
diff changeset
63
17371
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
64 /**
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
65 * Specifies whether the compilation result is installed as the
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
66 * {@linkplain HotSpotNmethod#isDefault() default} nmethod for the compiled method.
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
67 */
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
68 private final boolean installAsDefault;
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
69
13859
1e01e2644a5d Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13630
diff changeset
70 /**
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
71 * A {@link com.sun.management.ThreadMXBean} to be able to query some information about the
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
72 * current compiler thread, e.g. total allocated bytes.
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
73 */
15696
5f1373b3527d make CompilationTask.threadMXBean static
Doug Simon <doug.simon@oracle.com>
parents: 15695
diff changeset
74 private static final com.sun.management.ThreadMXBean threadMXBean = (com.sun.management.ThreadMXBean) ManagementFactory.getThreadMXBean();
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
75
15463
a20be10ad437 made Graal work with the HotSpot compiler queue and compiler threads, enabled by -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 15311
diff changeset
76 /**
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
77 * The address of the GraalEnv associated with this compilation or 0L if no such object exists.
15463
a20be10ad437 made Graal work with the HotSpot compiler queue and compiler threads, enabled by -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 15311
diff changeset
78 */
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
79 private final long graalEnv;
15463
a20be10ad437 made Graal work with the HotSpot compiler queue and compiler threads, enabled by -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 15311
diff changeset
80
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
81 public CompilationTask(HotSpotResolvedJavaMethod method, int entryBCI, long graalEnv, int id, boolean installAsDefault) {
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 this.method = method;
6677
3dddb311395f hotspot infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6676
diff changeset
83 this.entryBCI = entryBCI;
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
84 this.id = id;
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
85 this.graalEnv = graalEnv;
17371
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
86 this.installAsDefault = installAsDefault;
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
87 }
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
88
6721
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
89 public ResolvedJavaMethod getMethod() {
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
90 return method;
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
91 }
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
92
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
93 /**
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
94 * Returns the compilation id of this task.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
95 *
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
96 * @return compile id
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
97 */
10640
88672775a26c Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10577
diff changeset
98 public int getId() {
88672775a26c Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10577
diff changeset
99 return id;
88672775a26c Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10577
diff changeset
100 }
88672775a26c Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10577
diff changeset
101
6721
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
102 public int getEntryBCI() {
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
103 return entryBCI;
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
104 }
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
105
13859
1e01e2644a5d Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13630
diff changeset
106 /**
7558
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
107 * Time spent in compilation.
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
108 */
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
109 private static final DebugTimer CompilationTime = Debug.timer("CompilationTime");
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
110
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
111 /**
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
112 * Meters the {@linkplain CompilationResult#getBytecodeSize() bytecodes} compiled.
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
113 */
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
114 private static final DebugMetric CompiledBytecodes = Debug.metric("CompiledBytecodes");
7558
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7552
diff changeset
115
11487
21738e530332 added metrics for timing front-end, back-end and code installation (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 10672
diff changeset
116 public static final DebugTimer CodeInstallationTime = Debug.timer("CodeInstallation");
21738e530332 added metrics for timing front-end, back-end and code installation (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 10672
diff changeset
117
15695
128359d7cddc once the Graal compilation queue has been shutdown, don't process any pending compilations and be more defensive about preventing future compilations to be queued
Doug Simon <doug.simon@oracle.com>
parents: 15663
diff changeset
118 public void runCompilation() {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
119 HotSpotVMConfig config = HotSpotJVMCIRuntime.runtime().getConfig();
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
120 final long threadId = Thread.currentThread().getId();
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
121 long startCompilationTime = System.nanoTime();
12779
f6c511451e4a made Graal report its compilation info under -XX:+CITime in the same format as c1 and c2
Doug Simon <doug.simon@oracle.com>
parents: 12614
diff changeset
122 HotSpotInstalledCode installedCode = null;
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
123 final boolean isOSR = entryBCI != Compiler.INVOCATION_ENTRY_BCI;
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
124
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
125 // Log a compilation event.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
126 CompilationEvent compilationEvent = eventProvider.newCompilationEvent();
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
127
21476
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
128 // If there is already compiled code for this method on our level we simply return.
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
129 // Graal compiles are always at the highest compile level, even in non-tiered mode so we
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
130 // only need to check for that value.
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
131 if (method.hasCodeAtLevel(entryBCI, config.compilationLevelFullOptimization)) {
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
132 return;
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
133 }
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
134
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
135 CompilationResult result = null;
19693
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19346
diff changeset
136 try (DebugCloseable a = CompilationTime.start()) {
14107
800057208a2c enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14104
diff changeset
137 CompilationStatistics stats = CompilationStatistics.create(method, isOSR);
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
138 final boolean printCompilation = PrintCompilation.getValue() && !TTY.isSuppressed();
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 if (printCompilation) {
11828
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
140 TTY.println(getMethodDescription() + "...");
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 }
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
143 TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method);
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
144 final long start = System.currentTimeMillis();
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
145 final long allocatedBytesBefore = threadMXBean.getThreadAllocatedBytes(threadId);
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
146
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: 13106
diff changeset
147 try (Scope s = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) {
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
148 // Begin the compilation event.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
149 compilationEvent.begin();
14831
cbf616a24600 Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14552
diff changeset
150
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
151 result = compiler.compile(method, entryBCI, mustRecordMethodInlining(config));
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
152
13630
b1838411e896 Use compile ids assigned by hotspot
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13585
diff changeset
153 result.setId(getId());
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: 13106
diff changeset
154 } 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: 13106
diff changeset
155 throw Debug.handle(e);
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 } finally {
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
157 // End the compilation event.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
158 compilationEvent.end();
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
159
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 filter.remove();
11828
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
161 final boolean printAfterCompilation = PrintAfterCompilation.getValue() && !TTY.isSuppressed();
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
162
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
163 if (printAfterCompilation || printCompilation) {
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
164 final long stop = System.currentTimeMillis();
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
165 final int targetCodeSize = result != null ? result.getTargetCodeSize() : -1;
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
166 final long allocatedBytesAfter = threadMXBean.getThreadAllocatedBytes(threadId);
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
167 final long allocatedBytes = (allocatedBytesAfter - allocatedBytesBefore) / 1024;
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
168
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
169 if (printAfterCompilation) {
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
170 TTY.println(getMethodDescription() + String.format(" | %4dms %5dB %5dkB", stop - start, targetCodeSize, allocatedBytes));
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
171 } else if (printCompilation) {
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
172 TTY.println(String.format("%-6d Graal %-70s %-45s %-50s | %4dms %5dB %5dkB", id, "", "", "", stop - start, targetCodeSize, allocatedBytes));
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
173 }
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 }
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 }
5275
290b3025b66f added support for disassembling code after installation (so that the result of patching and relocation can be seen)
Doug Simon <doug.simon@oracle.com>
parents: 5226
diff changeset
176
19693
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19346
diff changeset
177 try (DebugCloseable b = CodeInstallationTime.start()) {
15162
dbb1fe8348e6 Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15045
diff changeset
178 installedCode = (HotSpotInstalledCode) installMethod(result);
11487
21738e530332 added metrics for timing front-end, back-end and code installation (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 10672
diff changeset
179 }
14545
4877b0cb446f removed ResolvedJavaMethod.getCompiledCodeSize()
Doug Simon <doug.simon@oracle.com>
parents: 14543
diff changeset
180 stats.finish(method, installedCode);
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
181 } catch (BailoutException bailout) {
14016
555867401850 Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13912
diff changeset
182 BAILOUTS.increment();
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
183 if (ExitVMOnBailout.getValue()) {
16480
10c12d09a8d2 moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 16405
diff changeset
184 TTY.cachedOut.println(method.format("Bailout in %H.%n(%p)"));
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 bailout.printStackTrace(TTY.cachedOut);
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 System.exit(-1);
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
187 } else if (PrintBailout.getValue()) {
16480
10c12d09a8d2 moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 16405
diff changeset
188 TTY.cachedOut.println(method.format("Bailout in %H.%n(%p)"));
5201
891399c54706 Add a PrintBailout option
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5188
diff changeset
189 bailout.printStackTrace(TTY.cachedOut);
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 } catch (Throwable t) {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
192 if (PrintStackTraceOnException.getValue() || ExitVMOnException.getValue()) {
9802
9dcd6f8a843b CompileTask: add option to print exception on compile error
Bernhard Urban <bernhard.urban@jku.at>
parents: 9790
diff changeset
193 t.printStackTrace(TTY.cachedOut);
9dcd6f8a843b CompileTask: add option to print exception on compile error
Bernhard Urban <bernhard.urban@jku.at>
parents: 9790
diff changeset
194 }
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
195
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
196 // Log a failure event.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
197 CompilerFailureEvent event = eventProvider.newCompilerFailureEvent();
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
198 if (event.shouldWrite()) {
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
199 event.setCompileId(getId());
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
200 event.setMessage(t.getMessage());
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
201 event.commit();
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
202 }
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
203
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
204 if (ExitVMOnException.getValue()) {
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 System.exit(-1);
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 }
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10019
diff changeset
207 } finally {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
208 int compiledBytecodes = 0;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
209 int codeSize = 0;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
210 if (result != null) {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
211 compiledBytecodes = result.getBytecodeSize();
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
212 }
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
213 if (installedCode != null) {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
214 codeSize = installedCode.getSize();
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
215 }
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
216 CompiledBytecodes.add(compiledBytecodes);
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
217
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
218 // Log a compilation event.
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
219 if (compilationEvent.shouldWrite()) {
16480
10c12d09a8d2 moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 16405
diff changeset
220 compilationEvent.setMethod(method.format("%H.%n(%p)"));
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
221 compilationEvent.setCompileId(getId());
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
222 compilationEvent.setCompileLevel(config.compilationLevelFullOptimization);
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
223 compilationEvent.setSucceeded(result != null && installedCode != null);
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
224 compilationEvent.setIsOsr(isOSR);
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
225 compilationEvent.setCodeSize(codeSize);
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
226 compilationEvent.setInlinedBytes(compiledBytecodes);
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
227 compilationEvent.commit();
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
228 }
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
229
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
230 if (graalEnv != 0) {
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21558
diff changeset
231 long ctask = unsafe.getAddress(graalEnv + config.jvmciEnvTaskOffset);
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
232 assert ctask != 0L;
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
233 unsafe.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, compiledBytecodes);
15463
a20be10ad437 made Graal work with the HotSpot compiler queue and compiler threads, enabled by -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 15311
diff changeset
234 }
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
235 long compilationTime = System.nanoTime() - startCompilationTime;
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
236 if ((config.ciTime || config.ciTimeEach) && installedCode != null) {
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
237 long timeUnitsPerSecond = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
238 CompilerToVM c2vm = HotSpotJVMCIRuntime.runtime().getCompilerToVM();
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
239 c2vm.notifyCompilationStatistics(id, method, entryBCI != Compiler.INVOCATION_ENTRY_BCI, compiledBytecodes, compilationTime, timeUnitsPerSecond, installedCode);
12779
f6c511451e4a made Graal report its compilation info under -XX:+CITime in the same format as c1 and c2
Doug Simon <doug.simon@oracle.com>
parents: 12614
diff changeset
240 }
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 }
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
242 }
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
243
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
244 /**
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
245 * Determines whether to disable method inlining recording for the method being compiled.
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
246 */
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
247 private boolean mustRecordMethodInlining(HotSpotVMConfig config) {
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
248 if (config.ciTime || config.ciTimeEach || CompiledBytecodes.isEnabled()) {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
249 return true;
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
250 }
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21558
diff changeset
251 if (graalEnv == 0 || unsafe.getByte(graalEnv + config.jvmciEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0) {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
252 return true;
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
253 }
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
254 return false;
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
255 }
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
256
11828
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
257 private String getMethodDescription() {
16483
3c3cd36a3836 moved signatureToMethodDescriptor(Signature sig) from MetaUtil to be a default method in Signature
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
258 return String.format("%-6d Graal %-70s %-45s %-50s %s", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature().toMethodDescriptor(),
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
259 entryBCI == Compiler.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") ");
11828
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
260 }
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
261
15162
dbb1fe8348e6 Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15045
diff changeset
262 private InstalledCode installMethod(final CompilationResult compResult) {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
263 final HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) HotSpotJVMCIRuntime.runtime().getHostJVMCIBackend().getCodeCache();
15162
dbb1fe8348e6 Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15045
diff changeset
264 InstalledCode installedCode = null;
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: 13106
diff changeset
265 try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(id), true), codeCache, method)) {
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
266 installedCode = codeCache.installMethod(method, compResult, graalEnv, installAsDefault);
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: 13106
diff changeset
267 } 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: 13106
diff changeset
268 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: 13106
diff changeset
269 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
270 return installedCode;
5275
290b3025b66f added support for disassembling code after installation (so that the result of patching and relocation can be seen)
Doug Simon <doug.simon@oracle.com>
parents: 5226
diff changeset
271 }
290b3025b66f added support for disassembling code after installation (so that the result of patching and relocation can be seen)
Doug Simon <doug.simon@oracle.com>
parents: 5226
diff changeset
272
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
273 @Override
7382
31d1cc9219d8 gave CompilationTask a toString() method
Doug Simon <doug.simon@oracle.com>
parents: 7377
diff changeset
274 public String toString() {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
275 return "Compilation[id=" + id + ", " + method.format("%H.%n(%p)") + (entryBCI == Compiler.INVOCATION_ENTRY_BCI ? "" : "@" + entryBCI) + "]";
7382
31d1cc9219d8 gave CompilationTask a toString() method
Doug Simon <doug.simon@oracle.com>
parents: 7377
diff changeset
276 }
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
277
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
278 /**
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
279 * Compiles a method to machine code.
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
280 */
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
281 public static void compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long graalEnv, int id) {
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
282 // Ensure a debug configuration for this thread is initialized
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
283 if (Debug.isEnabled() && DebugScope.getConfig() == null) {
16405
9bfc4247262f send log output to native tty
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16399
diff changeset
284 DebugEnvironment.initialize(TTY.cachedOut);
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
285 }
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
286
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21631
diff changeset
287 CompilationTask task = new CompilationTask(method, entryBCI, graalEnv, id, true);
18690
abcff66a23b0 Add ability to programmatically set the dump level
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18222
diff changeset
288 try (DebugConfigScope dcs = setConfig(new TopLevelDebugConfig())) {
abcff66a23b0 Add ability to programmatically set the dump level
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18222
diff changeset
289 task.runCompilation();
abcff66a23b0 Add ability to programmatically set the dump level
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18222
diff changeset
290 }
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
291 return;
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
292 }
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 }