Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java @ 16015:19a48d9834e1
exclude CompilationTask from JaCoCo
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 04 Jun 2014 15:58:28 +0200 |
parents | 66a9286203a2 |
children | 5d84706642ce |
rev | line source |
---|---|
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
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 |
13912
766de6735435
Setup the OSR calling convention before calling compileGraph rather than patching it in the LIRGenerator
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13859
diff
changeset
|
25 import static com.oracle.graal.api.code.CallingConvention.Type.*; |
9612
66db0353f55a
compilation is explicitly given a CallingConvention for the graph being compiled instead of deriving it from a method
Doug Simon <doug.simon@oracle.com>
parents:
9041
diff
changeset
|
26 import static com.oracle.graal.api.code.CodeUtil.*; |
13239 | 27 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
|
28 import static com.oracle.graal.compiler.common.GraalOptions.*; |
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
|
29 import static com.oracle.graal.compiler.common.UnsafeAccess.*; |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
30 import static com.oracle.graal.hotspot.CompilationQueue.*; |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
31 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
32 import static com.oracle.graal.hotspot.InitTimer.*; |
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
|
33 import static com.oracle.graal.nodes.StructuredGraph.*; |
15470
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15463
diff
changeset
|
34 import static com.oracle.graal.phases.common.inlining.InliningUtil.*; |
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
|
35 |
14027
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
36 import java.io.*; |
14753 | 37 import java.lang.management.*; |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
38 import java.security.*; |
14172
cd22c8dbda4f
Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents:
14163
diff
changeset
|
39 import java.util.*; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 import java.util.concurrent.*; |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
41 import java.util.concurrent.atomic.*; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
43 import com.oracle.graal.api.code.*; |
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
|
44 import com.oracle.graal.api.code.CallingConvention.Type; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5432
diff
changeset
|
45 import com.oracle.graal.api.meta.*; |
15663 | 46 import com.oracle.graal.api.runtime.*; |
14831
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
47 import com.oracle.graal.baseline.*; |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14552
diff
changeset
|
48 import com.oracle.graal.compiler.*; |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15162
diff
changeset
|
49 import com.oracle.graal.compiler.common.*; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 import com.oracle.graal.debug.*; |
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
|
51 import com.oracle.graal.debug.Debug.Scope; |
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
|
52 import com.oracle.graal.debug.internal.*; |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
53 import com.oracle.graal.hotspot.CompilationQueue.Options; |
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
|
54 import com.oracle.graal.hotspot.bridge.*; |
15663 | 55 import com.oracle.graal.hotspot.events.*; |
56 import com.oracle.graal.hotspot.events.EventProvider.CompilationEvent; | |
57 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
|
58 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
|
59 import com.oracle.graal.hotspot.phases.*; |
14831
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
60 import com.oracle.graal.java.*; |
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
|
61 import com.oracle.graal.lir.asm.*; |
5138 | 62 import com.oracle.graal.nodes.*; |
8637
ce5750014c3d
moved Replacements and MacroSubstitution from the graal.api.replacements project to graal.nodes project and reversed the dependency between these two projects (the latter now/again depends on the former)
Doug Simon <doug.simon@oracle.com>
parents:
8636
diff
changeset
|
63 import com.oracle.graal.nodes.spi.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6500
diff
changeset
|
64 import com.oracle.graal.phases.*; |
9968
3df534c97af1
Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents:
9920
diff
changeset
|
65 import com.oracle.graal.phases.tiers.*; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
67 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
14776
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14753
diff
changeset
|
68 |
16015
19a48d9834e1
exclude CompilationTask from JaCoCo
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
69 //JaCoCo Exclude |
19a48d9834e1
exclude CompilationTask from JaCoCo
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
70 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14991
diff
changeset
|
71 public class CompilationTask implements Runnable, Comparable<Object> { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
72 |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
73 static { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
74 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
|
75 // 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
|
76 // 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
|
77 HotSpotOptions.initialize(); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
78 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
79 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
80 |
14027
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
81 // Keep static finals in a group with withinEnqueue as the last one. CompilationTask can be |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
82 // called from within it's own clinit so it needs to be careful about accessing state. Once |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
83 // withinEnqueue is non-null we assume that CompilationTask is fully initialized. |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
84 private static final AtomicLong uniqueTaskIds = new AtomicLong(); |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
85 |
14016
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13912
diff
changeset
|
86 private static final DebugMetric BAILOUTS = Debug.metric("Bailouts"); |
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13912
diff
changeset
|
87 |
14027
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
88 private static final ThreadLocal<Boolean> withinEnqueue = new ThreadLocal<Boolean>() { |
5183
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
89 |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
90 @Override |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
91 protected Boolean initialValue() { |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
92 return Boolean.valueOf(Thread.currentThread() instanceof CompilerThread); |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
93 } |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
94 }; |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
95 |
14027
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
96 public static final boolean isWithinEnqueue() { |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
97 // It's possible this can be called before the <clinit> has completed so check for null |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
98 return withinEnqueue == null || withinEnqueue.get(); |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
99 } |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
100 |
14102
43a80ad2730a
rename BeginEnqueue to Enqueueing
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14027
diff
changeset
|
101 public static class Enqueueing implements Closeable { |
43a80ad2730a
rename BeginEnqueue to Enqueueing
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14027
diff
changeset
|
102 public Enqueueing() { |
14027
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
103 assert !withinEnqueue.get(); |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
104 withinEnqueue.set(Boolean.TRUE); |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
105 } |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
106 |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
107 public void close() { |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
108 withinEnqueue.set(Boolean.FALSE); |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
109 } |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
110 } |
aba77882e314
be more careful with clinit of CompilationTask
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14016
diff
changeset
|
111 |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
112 private enum CompilationStatus { |
14908
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14852
diff
changeset
|
113 Queued, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14852
diff
changeset
|
114 Running, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14852
diff
changeset
|
115 Finished |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
116 } |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
118 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
|
119 private final HotSpotResolvedJavaMethod method; |
6677
3dddb311395f
hotspot infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents:
6676
diff
changeset
|
120 private final int entryBCI; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
121 private final int id; |
10076
25de9c96a032
Minor CompilationTask refactoring.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10056
diff
changeset
|
122 private final AtomicReference<CompilationStatus> status; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 |
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
|
124 /** |
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
|
125 * The executor processing the Graal compilation queue this task was placed on. This will be |
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
|
126 * null for blocking compilations or if compilations are scheduled as native HotSpot |
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
|
127 * {@linkplain #ctask CompileTask}s. |
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
|
128 */ |
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
|
129 private final ExecutorService executor; |
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
|
130 |
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
|
131 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
|
132 |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
133 /** |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
134 * A long representing the sequence number of this task. Used for sorting the compile queue. |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
135 */ |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
136 private long taskId; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
137 |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
138 private boolean blocking; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
139 |
14753 | 140 /** |
141 * A {@link com.sun.management.ThreadMXBean} to be able to query some information about the | |
142 * current compiler thread, e.g. total allocated bytes. | |
143 */ | |
15696
5f1373b3527d
make CompilationTask.threadMXBean static
Doug Simon <doug.simon@oracle.com>
parents:
15695
diff
changeset
|
144 private static final com.sun.management.ThreadMXBean threadMXBean = (com.sun.management.ThreadMXBean) ManagementFactory.getThreadMXBean(); |
14753 | 145 |
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
|
146 /** |
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
|
147 * The address of the native CompileTask associated with this compilation. If 0L, then this |
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
|
148 * compilation is being managed by a Graal compilation queue otherwise its managed by a native |
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
|
149 * HotSpot compilation queue. |
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
|
150 */ |
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
|
151 private final long ctask; |
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
|
152 |
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
|
153 public CompilationTask(ExecutorService executor, HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, long ctask, boolean blocking) { |
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
|
154 this.executor = executor; |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
155 this.backend = backend; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 this.method = method; |
6677
3dddb311395f
hotspot infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents:
6676
diff
changeset
|
157 this.entryBCI = entryBCI; |
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
|
158 if (ctask == 0L) { |
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
|
159 this.id = method.allocateCompileId(entryBCI); |
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
|
160 } else { |
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
|
161 this.id = unsafe.getInt(ctask + backend.getRuntime().getConfig().compileTaskCompileIdOffset); |
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
|
162 } |
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
|
163 this.ctask = ctask; |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
164 this.blocking = blocking; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
165 this.taskId = uniqueTaskIds.incrementAndGet(); |
10078
7bcc4bf839fe
Bugfix for compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10076
diff
changeset
|
166 this.status = new AtomicReference<>(CompilationStatus.Queued); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
167 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
168 |
6721
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
169 public ResolvedJavaMethod getMethod() { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
170 return method; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
171 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
172 |
15663 | 173 /** |
174 * Returns the compilation id of this task. | |
175 * | |
176 * @return compile id | |
177 */ | |
10640
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
178 public int getId() { |
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
179 return id; |
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
180 } |
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
181 |
6721
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
182 public int getEntryBCI() { |
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
183 return entryBCI; |
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
184 } |
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
185 |
14776
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14753
diff
changeset
|
186 @SuppressFBWarnings(value = "NN_NAKED_NOTIFY") |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 public void run() { |
5183
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
188 withinEnqueue.set(Boolean.FALSE); |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
189 try { |
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
|
190 runCompilation(); |
8525
54f0a88e4523
Be a little bit more careful around compilation task queuing
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8508
diff
changeset
|
191 } finally { |
5183
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
192 withinEnqueue.set(Boolean.TRUE); |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
193 status.set(CompilationStatus.Finished); |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
194 synchronized (this) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
195 notifyAll(); |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
196 } |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
197 } |
5183
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
198 } |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
199 |
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
|
200 /** |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
201 * Block waiting till the compilation completes. |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
202 */ |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
203 public synchronized void block() { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
204 while (status.get() != CompilationStatus.Finished) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
205 try { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
206 wait(); |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
207 } catch (InterruptedException e) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
208 // Ignore and retry |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
209 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
210 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
211 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
212 |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
213 /** |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
214 * Sort blocking tasks before non-blocking ones and then by lowest taskId within the group. |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
215 */ |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
216 public int compareTo(Object o) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
217 if (!(o instanceof CompilationTask)) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
218 return 1; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
219 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
220 CompilationTask task2 = (CompilationTask) o; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
221 if (this.blocking != task2.blocking) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
222 // Blocking CompilationTasks are always higher than CompilationTasks |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
223 return task2.blocking ? 1 : -1; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
224 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
225 // Within the two groups sort by sequence id, so they are processed in insertion order. |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
226 return this.taskId > task2.taskId ? 1 : -1; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
227 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
228 |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
229 /** |
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
|
230 * 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
|
231 */ |
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
|
232 public static final DebugTimer CompilationTime = Debug.timer("CompilationTime"); |
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
|
233 |
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
|
234 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
|
235 |
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
|
236 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
|
237 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
|
238 } |
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
|
239 |
13585 | 240 protected PhaseSuite<HighTierContext> getGraphBuilderSuite(HotSpotProviders providers) { |
241 PhaseSuite<HighTierContext> suite = providers.getSuites().getDefaultGraphBuilderSuite(); | |
242 | |
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
|
243 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
|
244 if (osrCompilation) { |
13585 | 245 suite = suite.copy(); |
246 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
|
247 } |
13585 | 248 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
|
249 } |
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
|
250 |
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
|
251 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
|
252 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
|
253 } |
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
|
254 |
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
|
255 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
|
256 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
|
257 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
|
258 } |
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
|
259 |
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
|
260 public void runCompilation() { |
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
|
261 if (executor != null && executor.isShutdown()) { |
15702
c66c28e1f866
minor spelling and modifier fix
Doug Simon <doug.simon@oracle.com>
parents:
15696
diff
changeset
|
262 // We don't want to do any unnecessary compilation if the Graal compilation |
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
|
263 // queue has been shutdown. Note that we leave the JVM_ACC_QUEUED bit set |
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
|
264 // for the method so that it won't be re-scheduled for compilation. |
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
|
265 return; |
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
|
266 } |
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
|
267 |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
268 /* |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
269 * no code must be outside this try/finally because it could happen otherwise that |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
270 * clearQueuedForCompilation() is not executed |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
271 */ |
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
|
272 |
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
|
273 HotSpotVMConfig config = backend.getRuntime().getConfig(); |
14753 | 274 final long threadId = Thread.currentThread().getId(); |
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
|
275 long previousInlinedBytecodes = InlinedBytecodes.getCurrentValue(); |
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
|
276 long previousCompilationTime = CompilationTime.getCurrentValue(); |
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
|
277 HotSpotInstalledCode installedCode = null; |
15663 | 278 final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; |
279 | |
280 // Log a compilation event. | |
281 EventProvider eventProvider = Graal.getRequiredCapability(EventProvider.class); | |
282 CompilationEvent compilationEvent = eventProvider.newCompilationEvent(); | |
14753 | 283 |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
284 try (TimerCloseable a = CompilationTime.start()) { |
14107
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
285 if (!tryToChangeStatus(CompilationStatus.Queued, CompilationStatus.Running)) { |
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
286 return; |
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
287 } |
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
288 |
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
289 // If there is already compiled code for this method on our level we simply return. |
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
290 // Graal compiles are always at the highest compile level, even in non-tiered mode so we |
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
291 // only need to check for that value. |
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
292 if (method.hasCodeAtLevel(entryBCI, config.compilationLevelFullOptimization)) { |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
293 return; |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
294 } |
10640
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
295 |
14107
800057208a2c
enable C1 + Graal tiered
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14104
diff
changeset
|
296 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
|
297 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
|
298 if (printCompilation) { |
11828
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
299 TTY.println(getMethodDescription() + "..."); |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 } |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
301 if (HotSpotPrintCompilation.getValue()) { |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
302 printCompilation(); |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
303 } |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 |
5546
e42c0df7212a
Rename CiTargetMethod => CompilationResult.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
305 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
|
306 TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); |
14753 | 307 final long start = System.currentTimeMillis(); |
308 final long allocatedBytesBefore = threadMXBean.getThreadAllocatedBytes(threadId); | |
309 | |
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
|
310 try (Scope s = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) { |
15663 | 311 // Begin the compilation event. |
312 compilationEvent.begin(); | |
14831
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
313 |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
314 if (UseBaselineCompiler.getValue() == true) { |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
315 HotSpotProviders providers = backend.getProviders(); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
316 BaselineCompiler baselineCompiler = new BaselineCompiler(GraphBuilderConfiguration.getDefault(), providers.getMetaAccess()); |
14919
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14908
diff
changeset
|
317 OptimisticOptimizations optimisticOpts = OptimisticOptimizations.ALL; |
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14908
diff
changeset
|
318 result = baselineCompiler.generate(method, -1, backend, new CompilationResult(), method, CompilationResultBuilderFactory.Default, optimisticOpts); |
14831
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
319 } else { |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
320 Map<ResolvedJavaMethod, StructuredGraph> graphCache = null; |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
321 if (GraalOptions.CacheGraphs.getValue()) { |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
322 graphCache = new HashMap<>(); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
323 } |
12488
1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12465
diff
changeset
|
324 |
14831
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
325 HotSpotProviders providers = backend.getProviders(); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
326 Replacements replacements = providers.getReplacements(); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
327 graph = replacements.getMethodSubstitution(method); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
328 if (graph == null || entryBCI != INVOCATION_ENTRY_BCI) { |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
329 graph = new StructuredGraph(method, entryBCI); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
330 } else { |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
331 // Compiling method substitution - must clone the graph |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
332 graph = graph.copy(); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
333 } |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
334 InlinedBytecodes.add(method.getCodeSize()); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
335 CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
336 if (graph.getEntryBCI() != StructuredGraph.INVOCATION_ENTRY_BCI) { |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
337 // for OSR, only a pointer is passed to the method. |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
338 JavaType[] parameterTypes = new JavaType[]{providers.getMetaAccess().lookupJavaType(long.class)}; |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
339 CallingConvention tmp = providers.getCodeCache().getRegisterConfig().getCallingConvention(JavaCallee, providers.getMetaAccess().lookupJavaType(void.class), parameterTypes, |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
340 backend.getTarget(), false); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
341 cc = new CallingConvention(cc.getStackSize(), cc.getReturn(), tmp.getArgument(0)); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
342 } |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
343 Suites suites = getSuites(providers); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
344 ProfilingInfo profilingInfo = getProfilingInfo(); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
345 OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo); |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
346 result = compileGraph(graph, null, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo, |
cbf616a24600
Added baseline path in runCompilation
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14552
diff
changeset
|
347 method.getSpeculationLog(), suites, new CompilationResult(), CompilationResultBuilderFactory.Default); |
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
|
348 } |
13630
b1838411e896
Use compile ids assigned by hotspot
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13585
diff
changeset
|
349 result.setId(getId()); |
b1838411e896
Use compile ids assigned by hotspot
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13585
diff
changeset
|
350 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
|
351 } 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
|
352 throw Debug.handle(e); |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
353 } finally { |
15663 | 354 // End the compilation event. |
355 compilationEvent.end(); | |
356 | |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
357 filter.remove(); |
11828
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
358 final boolean printAfterCompilation = PrintAfterCompilation.getValue() && !TTY.isSuppressed(); |
14753 | 359 |
360 if (printAfterCompilation || printCompilation) { | |
361 final long stop = System.currentTimeMillis(); | |
362 final int targetCodeSize = result != null ? result.getTargetCodeSize() : -1; | |
363 final long allocatedBytesAfter = threadMXBean.getThreadAllocatedBytes(threadId); | |
364 final long allocatedBytes = (allocatedBytesAfter - allocatedBytesBefore) / 1024; | |
365 | |
366 if (printAfterCompilation) { | |
367 TTY.println(getMethodDescription() + String.format(" | %4dms %5dB %5dkB", stop - start, targetCodeSize, allocatedBytes)); | |
368 } else if (printCompilation) { | |
369 TTY.println(String.format("%-6d Graal %-70s %-45s %-50s | %4dms %5dB %5dkB", id, "", "", "", stop - start, targetCodeSize, allocatedBytes)); | |
370 } | |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
371 } |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
372 } |
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
|
373 |
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
|
374 try (TimerCloseable 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
|
375 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
|
376 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
|
377 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
|
378 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
|
379 } |
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
|
380 } |
14545
4877b0cb446f
removed ResolvedJavaMethod.getCompiledCodeSize()
Doug Simon <doug.simon@oracle.com>
parents:
14543
diff
changeset
|
381 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
|
382 } catch (BailoutException bailout) { |
14016
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13912
diff
changeset
|
383 BAILOUTS.increment(); |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
384 if (ExitVMOnBailout.getValue()) { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5603
diff
changeset
|
385 TTY.cachedOut.println(MetaUtil.format("Bailout in %H.%n(%p)", method)); |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
386 bailout.printStackTrace(TTY.cachedOut); |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
387 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
|
388 } else if (PrintBailout.getValue()) { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5603
diff
changeset
|
389 TTY.cachedOut.println(MetaUtil.format("Bailout in %H.%n(%p)", method)); |
5201
891399c54706
Add a PrintBailout option
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5188
diff
changeset
|
390 bailout.printStackTrace(TTY.cachedOut); |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
391 } |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
392 } 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
|
393 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
|
394 t.printStackTrace(TTY.cachedOut); |
9dcd6f8a843b
CompileTask: add option to print exception on compile error
Bernhard Urban <bernhard.urban@jku.at>
parents:
9790
diff
changeset
|
395 } |
15663 | 396 |
397 // Log a failure event. | |
398 CompilerFailureEvent event = eventProvider.newCompilerFailureEvent(); | |
399 if (event.shouldWrite()) { | |
400 event.setCompileId(getId()); | |
401 event.setMessage(t.getMessage()); | |
402 event.commit(); | |
403 } | |
404 | |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
405 if (ExitVMOnException.getValue()) { |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
406 System.exit(-1); |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
407 } |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
408 } finally { |
15663 | 409 final int processedBytes = (int) (InlinedBytecodes.getCurrentValue() - previousInlinedBytecodes); |
410 | |
411 // Log a compilation event. | |
412 if (compilationEvent.shouldWrite()) { | |
413 compilationEvent.setMethod(MetaUtil.format("%H.%n(%p)", method)); | |
414 compilationEvent.setCompileId(getId()); | |
415 compilationEvent.setCompileLevel(config.compilationLevelFullOptimization); | |
416 compilationEvent.setSucceeded(true); | |
417 compilationEvent.setIsOsr(isOSR); | |
418 compilationEvent.setCodeSize(installedCode.getSize()); | |
419 compilationEvent.setInlinedBytes(processedBytes); | |
420 compilationEvent.commit(); | |
421 } | |
422 | |
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
|
423 if (ctask != 0L) { |
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
|
424 unsafe.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, processedBytes); |
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
|
425 } |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
426 if ((config.ciTime || config.ciTimeEach || Options.PrintCompRate.getValue() != 0) && installedCode != null) { |
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
|
427 long time = CompilationTime.getCurrentValue() - previousCompilationTime; |
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
|
428 TimeUnit timeUnit = CompilationTime.getTimeUnit(); |
13103
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
12779
diff
changeset
|
429 long timeUnitsPerSecond = timeUnit.convert(1, TimeUnit.SECONDS); |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
12779
diff
changeset
|
430 CompilerToVM c2vm = backend.getRuntime().getCompilerToVM(); |
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
|
431 c2vm.notifyCompilationStatistics(id, method, entryBCI != INVOCATION_ENTRY_BCI, processedBytes, time, 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
|
432 } |
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
|
433 |
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
|
434 if (executor != null) { |
13366
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
435 assert method.isQueuedForCompilation(); |
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
436 method.clearQueuedForCompilation(); |
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
437 } |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 } |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
439 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
440 |
11828
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
441 private String getMethodDescription() { |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
442 return String.format("%-6d Graal %-70s %-45s %-50s %s", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature().getMethodDescriptor(), |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
443 entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") "); |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
444 } |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
445 |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
446 /** |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
447 * Print a HotSpot-style compilation message to the console. |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
448 */ |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
449 private void printCompilation() { |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
450 final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; |
14549
36d39c597c79
Respect CIPrintCompilerName and output a timestamp in Graal's PrintCompilation implementation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14545
diff
changeset
|
451 String compilerName = ""; |
36d39c597c79
Respect CIPrintCompilerName and output a timestamp in Graal's PrintCompilation implementation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14545
diff
changeset
|
452 if (HotSpotCIPrintCompilerName.getValue()) { |
36d39c597c79
Respect CIPrintCompilerName and output a timestamp in Graal's PrintCompilation implementation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14545
diff
changeset
|
453 compilerName = "Graal:"; |
36d39c597c79
Respect CIPrintCompilerName and output a timestamp in Graal's PrintCompilation implementation
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14545
diff
changeset
|
454 } |
14551
bf7d914b8ef7
Print compilation level in Graal's PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14549
diff
changeset
|
455 HotSpotVMConfig config = backend.getRuntime().getConfig(); |
bf7d914b8ef7
Print compilation level in Graal's PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14549
diff
changeset
|
456 int compLevel = config.compilationLevelFullOptimization; |
15045
0286888f792b
fix PrintCompilation formatting and use same time source
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15040
diff
changeset
|
457 String compLevelString; |
14551
bf7d914b8ef7
Print compilation level in Graal's PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14549
diff
changeset
|
458 if (config.tieredCompilation) { |
15045
0286888f792b
fix PrintCompilation formatting and use same time source
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15040
diff
changeset
|
459 compLevelString = "- "; |
14551
bf7d914b8ef7
Print compilation level in Graal's PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14549
diff
changeset
|
460 if (compLevel != -1) { |
15045
0286888f792b
fix PrintCompilation formatting and use same time source
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15040
diff
changeset
|
461 compLevelString = (char) ('0' + compLevel) + " "; |
14551
bf7d914b8ef7
Print compilation level in Graal's PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14549
diff
changeset
|
462 } |
bf7d914b8ef7
Print compilation level in Graal's PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14549
diff
changeset
|
463 } else { |
15045
0286888f792b
fix PrintCompilation formatting and use same time source
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15040
diff
changeset
|
464 compLevelString = ""; |
14551
bf7d914b8ef7
Print compilation level in Graal's PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14549
diff
changeset
|
465 } |
14552
2c78ee2a890f
Graal PrintCompilation: print exception handlers and blocking flags
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14551
diff
changeset
|
466 boolean hasExceptionHandlers = method.getExceptionHandlers().length > 0; |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
467 TTY.println(String.format("%s%7d %4d %c%c%c%c%c %s %s %s(%d bytes)", compilerName, backend.getRuntime().compilerToVm.getTimeStamp(), id, isOSR ? '%' : ' ', method.isSynchronized() ? 's' |
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
468 : ' ', hasExceptionHandlers ? '!' : ' ', blocking ? 'b' : ' ', method.isNative() ? 'n' : ' ', compLevelString, MetaUtil.format("%H::%n(%p)", method), isOSR ? "@ " + entryBCI + |
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
469 " " : "", method.getCodeSize())); |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
470 } |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
471 |
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
|
472 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
|
473 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
|
474 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
|
475 try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(id), true), codeCache, method)) { |
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
|
476 installedCode = codeCache.installMethod(method, compResult, ctask); |
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
|
477 } 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
|
478 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
|
479 } |
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
|
480 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
|
481 } |
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
|
482 |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
483 private boolean tryToChangeStatus(CompilationStatus from, CompilationStatus to) { |
10076
25de9c96a032
Minor CompilationTask refactoring.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10056
diff
changeset
|
484 return status.compareAndSet(from, to); |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
485 } |
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
486 |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
487 @Override |
7382
31d1cc9219d8
gave CompilationTask a toString() method
Doug Simon <doug.simon@oracle.com>
parents:
7377
diff
changeset
|
488 public String toString() { |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
489 return "Compilation[id=" + id + ", " + MetaUtil.format("%H.%n(%p)", method) + (entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "@" + entryBCI) + "]"; |
7382
31d1cc9219d8
gave CompilationTask a toString() method
Doug Simon <doug.simon@oracle.com>
parents:
7377
diff
changeset
|
490 } |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
491 |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
492 /** |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
493 * Entry point for the VM to schedule a compilation for a metaspace Method. |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
494 * |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
495 * Called from the VM. |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
496 */ |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
497 @SuppressWarnings("unused") |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
498 private static void compileMetaspaceMethod(long metaspaceMethod, final int entryBCI, long ctask, final boolean blocking) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
499 final HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
500 if (ctask != 0L) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
501 // This is on a VM CompilerThread - no user frames exist |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
502 compileMethod(method, entryBCI, ctask, false); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
503 } else { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
504 // We have to use a privileged action here because compilations are |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
505 // enqueued from user code which very likely contains unprivileged frames. |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
506 AccessController.doPrivileged(new PrivilegedAction<Void>() { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
507 public Void run() { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
508 compileMethod(method, entryBCI, 0L, blocking); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
509 return null; |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
510 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
511 }); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
512 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
513 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
514 |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
515 /** |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
516 * 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
|
517 */ |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
518 static void compileMethod(final HotSpotResolvedJavaMethod method, final int entryBCI, long ctask, final boolean blocking) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
519 if (ctask != 0L) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
520 HotSpotBackend backend = runtime().getHostBackend(); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
521 CompilationTask task = new CompilationTask(null, backend, method, entryBCI, ctask, false); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
522 task.runCompilation(); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
523 return; |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
524 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
525 |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
526 if (isWithinEnqueue()) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
527 // This is required to avoid deadlocking a compiler thread. The issue is that a |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
528 // java.util.concurrent.BlockingQueue is used to implement the compilation worker |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
529 // queues. If a compiler thread triggers a compilation, then it may be blocked trying |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
530 // to add something to its own queue. |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
531 return; |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
532 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
533 |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
534 // Don't allow blocking compiles from CompilerThreads |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
535 boolean block = blocking && !(Thread.currentThread() instanceof CompilerThread); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
536 try (Enqueueing enqueueing = new Enqueueing()) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
537 if (method.tryToQueueForCompilation()) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
538 assert method.isQueuedForCompilation(); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
539 |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
540 try { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
541 CompilationQueue queue = queue(); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
542 if (!queue.executor.isShutdown()) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
543 HotSpotBackend backend = runtime().getHostBackend(); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
544 CompilationTask task = new CompilationTask(queue.executor, backend, method, entryBCI, ctask, block); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
545 queue.execute(task); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
546 if (block) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
547 task.block(); |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
548 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
549 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
550 } catch (RejectedExecutionException e) { |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
551 // The compile queue was already shut down. |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
552 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
553 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
554 } |
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15702
diff
changeset
|
555 } |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 } |