annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java @ 21556:48c1ebd24120

renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 May 2015 00:36:16 +0200
parents b1530a6cce8c
children d563baeca9df
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 */
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot;
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
25 import com.oracle.jvmci.code.CompilationResult;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
26 import com.oracle.jvmci.code.InstalledCode;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
27 import com.oracle.jvmci.code.CallingConvention;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
28 import com.oracle.jvmci.code.BailoutException;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
29 import com.oracle.jvmci.meta.JavaType;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
30 import com.oracle.jvmci.meta.ResolvedJavaMethod;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
31 import com.oracle.jvmci.meta.ProfilingInfo;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
32 import static com.oracle.jvmci.code.CallingConvention.Type.*;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
33 import static com.oracle.jvmci.code.CodeUtil.*;
13239
Doug Simon <doug.simon@oracle.com>
parents: 13233 13217
diff changeset
34 import static com.oracle.graal.compiler.GraalCompiler.*;
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15162
diff changeset
35 import static com.oracle.graal.compiler.common.GraalOptions.*;
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
36 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
17153
646ddd52d79a only generate extra debug info if on HotSpot *and* compiling for HotSpot execution
Doug Simon <doug.simon@oracle.com>
parents: 17113
diff changeset
37 import static com.oracle.graal.hotspot.meta.HotSpotSuitesProvider.*;
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
38 import static com.oracle.graal.nodes.StructuredGraph.*;
21541
5e868236654f moved UnsafeAccess to com.oracle.jvmci.common (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21527
diff changeset
39 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
40 import static com.oracle.jvmci.debug.Debug.*;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21541
diff changeset
41 import static com.oracle.jvmci.hotspot.InitTimer.*;
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
42
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
43 import java.lang.management.*;
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 import java.util.concurrent.*;
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
46 import com.oracle.jvmci.code.CallingConvention.Type;
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
47 import com.oracle.graal.api.runtime.*;
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
48 import com.oracle.graal.hotspot.events.*;
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
49 import com.oracle.graal.hotspot.events.EventProvider.CompilationEvent;
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
50 import com.oracle.graal.hotspot.events.EventProvider.CompilerFailureEvent;
5548
8872bc0eebdf Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
51 import com.oracle.graal.hotspot.meta.*;
13452
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
52 import com.oracle.graal.hotspot.phases.*;
13229
325b4e4efb60 added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents: 13228
diff changeset
53 import com.oracle.graal.lir.asm.*;
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19050
diff changeset
54 import com.oracle.graal.lir.phases.*;
5138
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5137
diff changeset
55 import com.oracle.graal.nodes.*;
19774
31fac91ea3b7 disallow method substitution to be compilation root
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
56 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6500
diff changeset
57 import com.oracle.graal.phases.*;
18920
4af661af76fd Restructuring in the GraphBuilder to have less fields in the phase instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18690
diff changeset
58 import com.oracle.graal.phases.OptimisticOptimizations.Optimization;
9968
3df534c97af1 Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents: 9920
diff changeset
59 import com.oracle.graal.phases.tiers.*;
16106
5d84706642ce ensure a DebugEnvironment is initialized for native compiler threads
Doug Simon <doug.simon@oracle.com>
parents: 16015
diff changeset
60 import com.oracle.graal.printer.*;
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
61 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
62 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
63 import com.oracle.jvmci.debug.internal.*;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21541
diff changeset
64 import com.oracle.jvmci.hotspot.*;
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65
16015
19a48d9834e1 exclude CompilationTask from JaCoCo
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
66 //JaCoCo Exclude
19a48d9834e1 exclude CompilationTask from JaCoCo
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
67
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
68 public class CompilationTask {
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
69
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
70 static {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
71 try (InitTimer t = timer("initialize CompilationTask")) {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
72 // Must be first to ensure any options accessed by the rest of the class
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
73 // initializer are initialized from the command line.
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
74 HotSpotOptions.initialize();
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
75 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
76 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
77
14016
555867401850 Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13912
diff changeset
78 private static final DebugMetric BAILOUTS = Debug.metric("Bailouts");
555867401850 Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13912
diff changeset
79
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
80 private final HotSpotBackend backend;
5554
70f715dfbb41 Bring Java renamings and restructurings to the C++ part.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5548
diff changeset
81 private final HotSpotResolvedJavaMethod method;
6677
3dddb311395f hotspot infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6676
diff changeset
82 private final int entryBCI;
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
83 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
84
17371
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
85 /**
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
86 * 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
87 * {@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
88 */
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
89 private final boolean installAsDefault;
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
90
9813
c010c12ab682 put disassembling of installed code under the control of Debug.log(); use -G:Log=CodeInstall to show disassembly for all installed code
Doug Simon <doug.simon@oracle.com>
parents: 9807
diff changeset
91 private StructuredGraph graph;
c010c12ab682 put disassembling of installed code under the control of Debug.log(); use -G:Log=CodeInstall to show disassembly for all installed code
Doug Simon <doug.simon@oracle.com>
parents: 9807
diff changeset
92
13859
1e01e2644a5d Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13630
diff changeset
93 /**
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
94 * 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
95 * current compiler thread, e.g. total allocated bytes.
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
96 */
15696
5f1373b3527d make CompilationTask.threadMXBean static
Doug Simon <doug.simon@oracle.com>
parents: 15695
diff changeset
97 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
98
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
99 /**
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
100 * 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
101 */
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
102 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
103
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
104 public CompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, long graalEnv, int id, boolean installAsDefault) {
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
105 this.backend = backend;
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 this.method = method;
6677
3dddb311395f hotspot infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6676
diff changeset
107 this.entryBCI = entryBCI;
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
108 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
109 this.graalEnv = graalEnv;
17371
58f45b63b802 CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents: 17153
diff changeset
110 this.installAsDefault = installAsDefault;
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
111 }
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
112
6721
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
113 public ResolvedJavaMethod getMethod() {
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
114 return method;
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
115 }
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
116
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
117 /**
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
118 * Returns the compilation id of this task.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
119 *
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
120 * @return compile id
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
121 */
10640
88672775a26c Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10577
diff changeset
122 public int getId() {
88672775a26c Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10577
diff changeset
123 return id;
88672775a26c Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10577
diff changeset
124 }
88672775a26c Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10577
diff changeset
125
6721
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
126 public int getEntryBCI() {
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
127 return entryBCI;
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
128 }
98d691bc23da make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents: 6684
diff changeset
129
13859
1e01e2644a5d Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13630
diff changeset
130 /**
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
131 * 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
132 */
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
133 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
134
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
135 /**
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
136 * Meters the {@linkplain StructuredGraph#getBytecodeSize() bytecodes} compiled.
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
137 */
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
138 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
139
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
140 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
141
13353
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13239
diff changeset
142 protected Suites getSuites(HotSpotProviders providers) {
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13239
diff changeset
143 return providers.getSuites().getDefaultSuites();
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13239
diff changeset
144 }
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13239
diff changeset
145
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19232
diff changeset
146 protected LIRSuites getLIRSuites(HotSpotProviders providers) {
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19232
diff changeset
147 return providers.getSuites().getDefaultLIRSuites();
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19050
diff changeset
148 }
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19050
diff changeset
149
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
150 protected PhaseSuite<HighTierContext> getGraphBuilderSuite(HotSpotProviders providers) {
17153
646ddd52d79a only generate extra debug info if on HotSpot *and* compiling for HotSpot execution
Doug Simon <doug.simon@oracle.com>
parents: 17113
diff changeset
151 PhaseSuite<HighTierContext> suite = withSimpleDebugInfoIfRequested(providers.getSuites().getDefaultGraphBuilderSuite());
646ddd52d79a only generate extra debug info if on HotSpot *and* compiling for HotSpot execution
Doug Simon <doug.simon@oracle.com>
parents: 17113
diff changeset
152
13452
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
153 boolean osrCompilation = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI;
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
154 if (osrCompilation) {
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
155 suite = suite.copy();
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
156 suite.appendPhase(new OnStackReplacementPhase());
13452
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
157 }
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
158 return suite;
13452
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
159 }
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
160
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
161 protected OptimisticOptimizations getOptimisticOpts(ProfilingInfo profilingInfo) {
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
162 return new OptimisticOptimizations(profilingInfo);
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
163 }
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
164
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
165 protected ProfilingInfo getProfilingInfo() {
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
166 boolean osrCompilation = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI;
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
167 return method.getCompilationProfilingInfo(osrCompilation);
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
168 }
8275a0d0c90a create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents: 13366
diff changeset
169
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
170 public void runCompilation() {
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
171 HotSpotVMConfig config = backend.getRuntime().getConfig();
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
172 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
173 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
174 HotSpotInstalledCode installedCode = null;
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
175 final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI;
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
176
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
177 // Log a compilation event.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
178 EventProvider eventProvider = Graal.getRequiredCapability(EventProvider.class);
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
179 CompilationEvent compilationEvent = eventProvider.newCompilationEvent();
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
180
21476
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
181 // 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
182 // 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
183 // 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
184 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
185 return;
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
186 }
73713483b8ac fixed npe in CompileTheWorld for methods that are already compiled
Doug Simon <doug.simon@oracle.com>
parents: 21473
diff changeset
187
19693
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19346
diff changeset
188 try (DebugCloseable a = CompilationTime.start()) {
14107
800057208a2c enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14104
diff changeset
189 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
190 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
191 if (printCompilation) {
11828
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
192 TTY.println(getMethodDescription() + "...");
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 }
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194
5546
e42c0df7212a Rename CiTargetMethod => CompilationResult.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
195 CompilationResult result = null;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
196 TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method);
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
197 final long start = System.currentTimeMillis();
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
198 final long allocatedBytesBefore = threadMXBean.getThreadAllocatedBytes(threadId);
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
199
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
200 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
201 // Begin the compilation event.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
202 compilationEvent.begin();
14831
cbf616a24600 Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14552
diff changeset
203
19332
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
204 HotSpotProviders providers = backend.getProviders();
19774
31fac91ea3b7 disallow method substitution to be compilation root
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
205 graph = new StructuredGraph(method, entryBCI, AllowAssumptions.from(OptAssumptions.getValue()));
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
206 if (shouldDisableMethodInliningRecording(config)) {
19774
31fac91ea3b7 disallow method substitution to be compilation root
Doug Simon <doug.simon@oracle.com>
parents: 19693
diff changeset
207 graph.disableInlinedMethodRecording();
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
208 }
19332
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
209 CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
210 if (graph.getEntryBCI() != StructuredGraph.INVOCATION_ENTRY_BCI) {
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
211 // for OSR, only a pointer is passed to the method.
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
212 JavaType[] parameterTypes = new JavaType[]{providers.getMetaAccess().lookupJavaType(long.class)};
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
213 CallingConvention tmp = providers.getCodeCache().getRegisterConfig().getCallingConvention(JavaCallee, providers.getMetaAccess().lookupJavaType(void.class), parameterTypes,
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
214 backend.getTarget(), false);
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
215 cc = new CallingConvention(cc.getStackSize(), cc.getReturn(), tmp.getArgument(0));
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
216 }
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
217 Suites suites = getSuites(providers);
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
218 LIRSuites lirSuites = getLIRSuites(providers);
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
219 ProfilingInfo profilingInfo = getProfilingInfo();
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
220 OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo);
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
221 if (isOSR) {
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
222 // In OSR compiles, we cannot rely on never executed code profiles, because
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
223 // all code after the OSR loop is never executed.
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
224 optimisticOpts.remove(Optimization.RemoveNeverExecutedCode);
833d0361c3e2 Temporarily remove the baseline compiler experiment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19321
diff changeset
225 }
20068
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19965
diff changeset
226 result = compileGraph(graph, cc, method, providers, backend, backend.getTarget(), getGraphBuilderSuite(providers), optimisticOpts, profilingInfo, method.getSpeculationLog(), suites,
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19965
diff changeset
227 lirSuites, new CompilationResult(), CompilationResultBuilderFactory.Default);
13630
b1838411e896 Use compile ids assigned by hotspot
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13585
diff changeset
228 result.setId(getId());
b1838411e896 Use compile ids assigned by hotspot
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13585
diff changeset
229 result.setEntryBCI(entryBCI);
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
230 } 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
231 throw Debug.handle(e);
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 } finally {
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
233 // End the compilation event.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
234 compilationEvent.end();
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
235
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 filter.remove();
11828
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
237 final boolean printAfterCompilation = PrintAfterCompilation.getValue() && !TTY.isSuppressed();
14753
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
238
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
239 if (printAfterCompilation || printCompilation) {
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
240 final long stop = System.currentTimeMillis();
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
241 final int targetCodeSize = result != null ? result.getTargetCodeSize() : -1;
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
242 final long allocatedBytesAfter = threadMXBean.getThreadAllocatedBytes(threadId);
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
243 final long allocatedBytes = (allocatedBytesAfter - allocatedBytesBefore) / 1024;
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
244
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
245 if (printAfterCompilation) {
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
246 TTY.println(getMethodDescription() + String.format(" | %4dms %5dB %5dkB", stop - start, targetCodeSize, allocatedBytes));
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
247 } else if (printCompilation) {
b5cdbf6d793a print total allocated bytes for compilations
twisti
parents: 14724
diff changeset
248 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
249 }
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 }
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 }
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
252
19693
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19346
diff changeset
253 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
254 installedCode = (HotSpotInstalledCode) installMethod(result);
14543
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
255 if (!isOSR) {
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
256 ProfilingInfo profile = method.getProfilingInfo();
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
257 profile.setCompilerIRSize(StructuredGraph.class, graph.getNodeCount());
12eaf1a47a90 removed ResolvedJavaMethod.getCompilerStorage(); moved last compiled graph node count into profiling info (i.e. MethodData metadata)
Doug Simon <doug.simon@oracle.com>
parents: 14172
diff changeset
258 }
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
259 }
14545
4877b0cb446f removed ResolvedJavaMethod.getCompiledCodeSize()
Doug Simon <doug.simon@oracle.com>
parents: 14543
diff changeset
260 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
261 } catch (BailoutException bailout) {
14016
555867401850 Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13912
diff changeset
262 BAILOUTS.increment();
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
263 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
264 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
265 bailout.printStackTrace(TTY.cachedOut);
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 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
267 } 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
268 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
269 bailout.printStackTrace(TTY.cachedOut);
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 }
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
271 } 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
272 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
273 t.printStackTrace(TTY.cachedOut);
9dcd6f8a843b CompileTask: add option to print exception on compile error
Bernhard Urban <bernhard.urban@jku.at>
parents: 9790
diff changeset
274 }
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
275
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
276 // Log a failure event.
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
277 CompilerFailureEvent event = eventProvider.newCompilerFailureEvent();
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
278 if (event.shouldWrite()) {
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
279 event.setCompileId(getId());
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
280 event.setMessage(t.getMessage());
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
281 event.commit();
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
282 }
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
283
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
284 if (ExitVMOnException.getValue()) {
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 System.exit(-1);
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 }
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10019
diff changeset
287 } finally {
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
288 final int compiledBytecodes = graph.getBytecodeSize();
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
289 CompiledBytecodes.add(compiledBytecodes);
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
290
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
291 // Log a compilation event.
19965
9bd252b8e3ad Check for null installedCode when reporting events
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19774
diff changeset
292 if (compilationEvent.shouldWrite() && installedCode != null) {
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
293 compilationEvent.setMethod(method.format("%H.%n(%p)"));
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
294 compilationEvent.setCompileId(getId());
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
295 compilationEvent.setCompileLevel(config.compilationLevelFullOptimization);
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
296 compilationEvent.setSucceeded(true);
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
297 compilationEvent.setIsOsr(isOSR);
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
298 compilationEvent.setCodeSize(installedCode.getSize());
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
299 compilationEvent.setInlinedBytes(compiledBytecodes);
15663
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
300 compilationEvent.commit();
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
301 }
7340fe377764 added Java Flight Recorder (JFR) event support
twisti
parents: 15470
diff changeset
302
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
303 if (graalEnv != 0) {
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
304 long ctask = unsafe.getAddress(graalEnv + config.graalEnvTaskOffset);
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
305 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
306 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
307 }
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
308 long compilationTime = System.nanoTime() - startCompilationTime;
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
309 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
310 long timeUnitsPerSecond = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
13103
c0b0974dd509 moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents: 12779
diff changeset
311 CompilerToVM c2vm = backend.getRuntime().getCompilerToVM();
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
312 c2vm.notifyCompilationStatistics(id, method, entryBCI != 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
313 }
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 }
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
315 }
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
316
21473
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
317 /**
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
318 * Determines whether to {@linkplain StructuredGraph#disableInlinedMethodRecording() disable}
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
319 * method inlining recording for the method being compiled.
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
320 *
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
321 * @see StructuredGraph#getBytecodeSize()
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
322 */
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
323 private boolean shouldDisableMethodInliningRecording(HotSpotVMConfig config) {
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
324 if (config.ciTime || config.ciTimeEach || CompiledBytecodes.isEnabled()) {
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
325 return false;
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
326 }
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
327 if (graalEnv == 0 || unsafe.getByte(graalEnv + config.graalEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0) {
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
328 return false;
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
329 }
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
330 return true;
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
331 }
923c37b10fb4 compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents: 20068
diff changeset
332
11828
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
333 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
334 return String.format("%-6d Graal %-70s %-45s %-50s %s", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature().toMethodDescriptor(),
11828
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
335 entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") ");
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
336 }
1d64bfb3f481 new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents: 11487
diff changeset
337
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
338 private InstalledCode installMethod(final CompilationResult compResult) {
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
339 final HotSpotCodeCacheProvider codeCache = backend.getProviders().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
340 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
341 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
342 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
343 } 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
344 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
345 }
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
346 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
347 }
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
348
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5138
diff changeset
349 @Override
7382
31d1cc9219d8 gave CompilationTask a toString() method
Doug Simon <doug.simon@oracle.com>
parents: 7377
diff changeset
350 public String toString() {
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
351 return "Compilation[id=" + id + ", " + method.format("%H.%n(%p)") + (entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "@" + entryBCI) + "]";
7382
31d1cc9219d8 gave CompilationTask a toString() method
Doug Simon <doug.simon@oracle.com>
parents: 7377
diff changeset
352 }
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
353
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
354 /**
16106
5d84706642ce ensure a DebugEnvironment is initialized for native compiler threads
Doug Simon <doug.simon@oracle.com>
parents: 16015
diff changeset
355 * Schedules compilation of a metaspace Method.
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
356 *
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
357 * Called from the VM.
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
358 *
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
359 * @param metaspaceMethod
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
360 * @param entryBCI
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
361 * @param graalEnv address of native GraalEnv object
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
362 * @param id CompileTask::_compile_id
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
363 */
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
364 @SuppressWarnings("unused")
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
365 private static void compileMetaspaceMethod(long metaspaceMethod, int entryBCI, long graalEnv, int id) {
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
366 // Ensure a Graal runtime is initialized prior to Debug being initialized as the former
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
367 // may include processing command line options used by the latter.
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
368 Graal.getRuntime();
16106
5d84706642ce ensure a DebugEnvironment is initialized for native compiler threads
Doug Simon <doug.simon@oracle.com>
parents: 16015
diff changeset
369
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
370 // Ensure a debug configuration for this thread is initialized
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
371 if (Debug.isEnabled() && DebugScope.getConfig() == null) {
16405
9bfc4247262f send log output to native tty
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16399
diff changeset
372 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
373 }
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
374
18222
a8cff27ca2e1 converted HotSpotResolvedJavaMethod to an interface
Doug Simon <doug.simon@oracle.com>
parents: 17371
diff changeset
375 HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod);
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
376 compileMethod(method, entryBCI, graalEnv, id);
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
377 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
378
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
379 /**
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
380 * Compiles a method to machine code.
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
381 */
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
382 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
383 HotSpotBackend backend = runtime().getHostBackend();
19321
98592ae4b1fa only record method dependencies if JVMTI hotswapping or breakpointing is enabled
Doug Simon <doug.simon@oracle.com>
parents: 19306
diff changeset
384 CompilationTask task = new CompilationTask(backend, 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
385 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
386 task.runCompilation();
abcff66a23b0 Add ability to programmatically set the dump level
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18222
diff changeset
387 }
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16243
diff changeset
388 return;
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15702
diff changeset
389 }
5136
8f4f0ebffca2 Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 }