Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java @ 14016:555867401850
Make Debug.metric objects static
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Tue, 25 Feb 2014 09:49:47 -0800 |
parents | 766de6735435 |
children | aba77882e314 |
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.*; |
13464
2236d18302e0
made -G:PrintCompRate incompatible with -XX:+CITime and -XX:+CITimeEach
Doug Simon <doug.simon@oracle.com>
parents:
13452
diff
changeset
|
28 import static com.oracle.graal.hotspot.bridge.VMToCompilerImpl.*; |
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
|
29 import static com.oracle.graal.nodes.StructuredGraph.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
30 import static com.oracle.graal.phases.GraalOptions.*; |
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
|
31 import static com.oracle.graal.phases.common.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
|
32 |
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
|
33 import java.lang.reflect.*; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 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
|
35 import java.util.concurrent.atomic.*; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
37 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
|
38 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
|
39 import com.oracle.graal.api.meta.*; |
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
|
40 import com.oracle.graal.compiler.CompilerThreadFactory.CompilerThread; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 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
|
42 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
|
43 import com.oracle.graal.debug.internal.*; |
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
|
44 import com.oracle.graal.hotspot.bridge.*; |
5548
8872bc0eebdf
Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
45 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
|
46 import com.oracle.graal.hotspot.phases.*; |
13229
325b4e4efb60
added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents:
13228
diff
changeset
|
47 import com.oracle.graal.lir.asm.*; |
5138 | 48 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
|
49 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
|
50 import com.oracle.graal.phases.*; |
9968
3df534c97af1
Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents:
9920
diff
changeset
|
51 import com.oracle.graal.phases.tiers.*; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
53 public class CompilationTask implements Runnable, Comparable { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
54 |
14016
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13912
diff
changeset
|
55 private static final DebugMetric BAILOUTS = Debug.metric("Bailouts"); |
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13912
diff
changeset
|
56 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7382
diff
changeset
|
57 public 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
|
58 |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
59 @Override |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
60 protected Boolean initialValue() { |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
61 return Boolean.valueOf(Thread.currentThread() instanceof CompilerThread); |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
62 } |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
63 }; |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
64 |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
65 private enum CompilationStatus { |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
66 Queued, Running, Finished |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
67 } |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
69 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
|
70 private final HotSpotResolvedJavaMethod method; |
6677
3dddb311395f
hotspot infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents:
6676
diff
changeset
|
71 private final int entryBCI; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
72 private final int id; |
10076
25de9c96a032
Minor CompilationTask refactoring.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10056
diff
changeset
|
73 private final AtomicReference<CompilationStatus> status; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 |
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
|
75 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
|
76 |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
77 private static final AtomicLong uniqueTaskIds = new AtomicLong(); |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
78 |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
79 /** |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
80 * 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
|
81 */ |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
82 private long taskId; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
83 |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
84 private boolean blocking; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
85 |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
86 public CompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, boolean blocking) { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
87 this.backend = backend; |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 this.method = method; |
6677
3dddb311395f
hotspot infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents:
6676
diff
changeset
|
89 this.entryBCI = entryBCI; |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
90 this.id = backend.getRuntime().getCompilerToVM().allocateCompileId(method, entryBCI); |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
91 this.blocking = blocking; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
92 this.taskId = uniqueTaskIds.incrementAndGet(); |
10078
7bcc4bf839fe
Bugfix for compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10076
diff
changeset
|
93 this.status = new AtomicReference<>(CompilationStatus.Queued); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
94 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
95 |
6721
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
96 public ResolvedJavaMethod getMethod() { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
97 return method; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
98 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
99 |
10640
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
100 public int getId() { |
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
101 return id; |
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
102 } |
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
103 |
6721
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
104 public int getEntryBCI() { |
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
105 return entryBCI; |
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
106 } |
98d691bc23da
make osr compilations asynchronous
Lukas Stadler <lukas.stadler@jku.at>
parents:
6684
diff
changeset
|
107 |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 public void run() { |
5183
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
109 withinEnqueue.set(Boolean.FALSE); |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
110 try { |
13366
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
111 runCompilation(true); |
8525
54f0a88e4523
Be a little bit more careful around compilation task queuing
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8508
diff
changeset
|
112 } finally { |
54f0a88e4523
Be a little bit more careful around compilation task queuing
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8508
diff
changeset
|
113 if (method.currentTask() == this) { |
5183
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
114 method.setCurrentTask(null); |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
115 } |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
116 withinEnqueue.set(Boolean.TRUE); |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
117 status.set(CompilationStatus.Finished); |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
118 synchronized (this) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
119 notifyAll(); |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
120 } |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
121 } |
5183
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
122 } |
e1e681a5558e
fix PriorityQueue, enable PriorityQueue and CacheGraphs
Lukas Stadler <lukas.stadler@jku.at>
parents:
5177
diff
changeset
|
123 |
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
|
124 /** |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
125 * Block waiting till the compilation completes. |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
126 */ |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
127 public synchronized void block() { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
128 while (status.get() != CompilationStatus.Finished) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
129 try { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
130 wait(); |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
131 } catch (InterruptedException e) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
132 // Ignore and retry |
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 } |
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 |
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 * 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
|
139 */ |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
140 public int compareTo(Object o) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
141 if (!(o instanceof CompilationTask)) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
142 return 1; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
143 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
144 CompilationTask task2 = (CompilationTask) o; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
145 if (this.blocking != task2.blocking) { |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
146 // Blocking CompilationTasks are always higher than CompilationTasks |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
147 return task2.blocking ? 1 : -1; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
148 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
149 // 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
|
150 return this.taskId > task2.taskId ? 1 : -1; |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
151 } |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
152 |
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
153 /** |
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
|
154 * 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
|
155 */ |
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
|
156 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
|
157 |
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
|
158 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
|
159 |
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
|
160 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
|
161 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
|
162 } |
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
|
163 |
13585 | 164 protected PhaseSuite<HighTierContext> getGraphBuilderSuite(HotSpotProviders providers) { |
165 PhaseSuite<HighTierContext> suite = providers.getSuites().getDefaultGraphBuilderSuite(); | |
166 | |
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
|
167 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
|
168 if (osrCompilation) { |
13585 | 169 suite = suite.copy(); |
170 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
|
171 } |
13585 | 172 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
|
173 } |
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
|
174 |
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
|
175 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
|
176 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
|
177 } |
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
|
178 |
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
|
179 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
|
180 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
|
181 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
|
182 } |
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
|
183 |
13366
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
184 public void runCompilation(boolean clearFromCompilationQueue) { |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
185 /* |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
186 * 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
|
187 * clearQueuedForCompilation() is not executed |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
188 */ |
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
|
189 |
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
|
190 HotSpotVMConfig config = backend.getRuntime().getConfig(); |
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
|
191 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
|
192 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
|
193 HotSpotInstalledCode installedCode = null; |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
194 try (TimerCloseable a = CompilationTime.start()) { |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
195 if (!tryToChangeStatus(CompilationStatus.Queued, CompilationStatus.Running) || method.hasCompiledCode()) { |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
196 return; |
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
197 } |
10640
88672775a26c
Compilation policy fixes and changed default compilation policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10577
diff
changeset
|
198 |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
199 CompilationStatistics stats = CompilationStatistics.create(method, entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI); |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
200 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
|
201 if (printCompilation) { |
11828
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
202 TTY.println(getMethodDescription() + "..."); |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 } |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
204 if (HotSpotPrintCompilation.getValue()) { |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
205 printCompilation(); |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
206 } |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 |
5546
e42c0df7212a
Rename CiTargetMethod => CompilationResult.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
208 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
|
209 TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); |
6684
28a158024338
Add OSR marker in -G:+PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6679
diff
changeset
|
210 long start = System.currentTimeMillis(); |
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
|
211 try (Scope s = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) { |
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
|
212 GraphCache graphCache = backend.getRuntime().getGraphCache(); |
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
|
213 if (graphCache != null) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13106
diff
changeset
|
214 graphCache.removeStaleGraphs(); |
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
|
215 } |
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
|
216 |
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
|
217 HotSpotProviders providers = backend.getProviders(); |
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
|
218 Replacements replacements = providers.getReplacements(); |
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
|
219 graph = replacements.getMethodSubstitution(method); |
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
|
220 if (graph == null || entryBCI != INVOCATION_ENTRY_BCI) { |
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
|
221 graph = new StructuredGraph(method, entryBCI); |
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
|
222 } else { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13106
diff
changeset
|
223 // Compiling method substitution - must clone the graph |
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
|
224 graph = graph.copy(); |
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
|
225 } |
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
|
226 InlinedBytecodes.add(method.getCodeSize()); |
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
|
227 CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); |
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
|
228 if (graph.getEntryBCI() != StructuredGraph.INVOCATION_ENTRY_BCI) { |
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
|
229 // for OSR, only a pointer is passed to the method. |
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
|
230 JavaType[] parameterTypes = new JavaType[]{providers.getMetaAccess().lookupJavaType(long.class)}; |
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
|
231 CallingConvention tmp = providers.getCodeCache().getRegisterConfig().getCallingConvention(JavaCallee, providers.getMetaAccess().lookupJavaType(void.class), parameterTypes, |
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
|
232 backend.getTarget(), false); |
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
|
233 cc = new CallingConvention(cc.getStackSize(), cc.getReturn(), tmp.getArgument(0)); |
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
|
234 } |
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
|
235 Suites suites = getSuites(providers); |
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
|
236 ProfilingInfo 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
|
237 OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo); |
13585 | 238 result = compileGraph(graph, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo, |
239 method.getSpeculationLog(), suites, true, new CompilationResult(), CompilationResultBuilderFactory.Default); | |
13630
b1838411e896
Use compile ids assigned by hotspot
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13585
diff
changeset
|
240 result.setId(getId()); |
b1838411e896
Use compile ids assigned by hotspot
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13585
diff
changeset
|
241 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
|
242 } 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
|
243 throw Debug.handle(e); |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 } finally { |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 filter.remove(); |
11828
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
246 final boolean printAfterCompilation = PrintAfterCompilation.getValue() && !TTY.isSuppressed(); |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
247 if (printAfterCompilation) { |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
248 TTY.println(getMethodDescription() + String.format(" | %4dms %5dB", System.currentTimeMillis() - start, (result != null ? result.getTargetCodeSize() : -1))); |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
249 } else if (printCompilation) { |
6684
28a158024338
Add OSR marker in -G:+PrintCompilation output
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6679
diff
changeset
|
250 TTY.println(String.format("%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, (result != null ? result.getTargetCodeSize() : -1))); |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
251 } |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
252 } |
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
|
253 |
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
|
254 try (TimerCloseable b = CodeInstallationTime.start()) { |
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
|
255 installedCode = installMethod(result); |
11487
21738e530332
added metrics for timing front-end, back-end and code installation (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
256 } |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
257 stats.finish(method); |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
258 } catch (BailoutException bailout) { |
14016
555867401850
Make Debug.metric objects static
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13912
diff
changeset
|
259 BAILOUTS.increment(); |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
260 if (ExitVMOnBailout.getValue()) { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5603
diff
changeset
|
261 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
|
262 bailout.printStackTrace(TTY.cachedOut); |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
263 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
|
264 } else if (PrintBailout.getValue()) { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5603
diff
changeset
|
265 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
|
266 bailout.printStackTrace(TTY.cachedOut); |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
267 } |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
268 } 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
|
269 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
|
270 t.printStackTrace(TTY.cachedOut); |
9dcd6f8a843b
CompileTask: add option to print exception on compile error
Bernhard Urban <bernhard.urban@jku.at>
parents:
9790
diff
changeset
|
271 } |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
272 if (ExitVMOnException.getValue()) { |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 System.exit(-1); |
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 } |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
275 } finally { |
13464
2236d18302e0
made -G:PrintCompRate incompatible with -XX:+CITime and -XX:+CITimeEach
Doug Simon <doug.simon@oracle.com>
parents:
13452
diff
changeset
|
276 if ((config.ciTime || config.ciTimeEach || 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
|
277 long processedBytes = InlinedBytecodes.getCurrentValue() - previousInlinedBytecodes; |
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
|
278 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
|
279 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
|
280 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
|
281 CompilerToVM c2vm = backend.getRuntime().getCompilerToVM(); |
c0b0974dd509
moved notification of Graal compilation statistics from VMToCompiler to CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
12779
diff
changeset
|
282 c2vm.notifyCompilationStatistics(id, method, entryBCI != INVOCATION_ENTRY_BCI, (int) 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
|
283 } |
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
|
284 |
13366
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
285 if (clearFromCompilationQueue) { |
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
286 assert method.isQueuedForCompilation(); |
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
287 method.clearQueuedForCompilation(); |
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
288 } |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 } |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
290 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
291 |
11828
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
292 private String getMethodDescription() { |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
293 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
|
294 entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "(OSR@" + entryBCI + ") "); |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
295 } |
1d64bfb3f481
new PrintAfterCompilation option, simplify PrintCompilation output
Lukas Stadler <lukas.stadler@jku.at>
parents:
11487
diff
changeset
|
296 |
8996
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
297 /** |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
298 * Print a HotSpot-style compilation message to the console. |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
299 */ |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
300 private void printCompilation() { |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
301 final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
302 final int mod = method.getModifiers(); |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
303 TTY.println(String.format("%7d %4d %c%c%c%c%c %s %s(%d bytes)", 0, id, isOSR ? '%' : ' ', Modifier.isSynchronized(mod) ? 's' : ' ', ' ', ' ', Modifier.isNative(mod) ? 'n' : ' ', |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
304 MetaUtil.format("%H::%n(%p)", method), isOSR ? "@ " + entryBCI + " " : "", method.getCodeSize())); |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
305 } |
6d86ce1297bc
GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents:
8637
diff
changeset
|
306 |
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
|
307 private HotSpotInstalledCode 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
|
308 final HotSpotCodeCacheProvider codeCache = backend.getProviders().getCodeCache(); |
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
|
309 HotSpotInstalledCode installedCode = null; |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13106
diff
changeset
|
310 try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(id), true), codeCache, method)) { |
13630
b1838411e896
Use compile ids assigned by hotspot
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13585
diff
changeset
|
311 installedCode = codeCache.installMethod(method, compResult); |
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
|
312 } 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
|
313 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
|
314 } |
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
|
315 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
|
316 } |
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
|
317 |
10056
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
318 private boolean tryToChangeStatus(CompilationStatus from, CompilationStatus to) { |
10076
25de9c96a032
Minor CompilationTask refactoring.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10056
diff
changeset
|
319 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
|
320 } |
a323a9e20f9d
Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10019
diff
changeset
|
321 |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5138
diff
changeset
|
322 @Override |
7382
31d1cc9219d8
gave CompilationTask a toString() method
Doug Simon <doug.simon@oracle.com>
parents:
7377
diff
changeset
|
323 public String toString() { |
10672
e7d07c9bb779
Removed priority compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
10640
diff
changeset
|
324 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
|
325 } |
5136
8f4f0ebffca2
Move compilation task logic to separate class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 } |