annotate src/share/vm/graal/graalCompiler.cpp @ 18119:6997fce99fa3

graal/hotspot: fix memleak
author Bernhard Urban <bernhard.urban@jku.at>
date Fri, 17 Oct 2014 13:33:31 +0200
parents e98942f26fa4
children 6a2f814224b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2516
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
1 /*
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
4 *
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
7 * published by the Free Software Foundation.
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
8 *
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
13 * accompanied this code).
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
14 *
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
15 * You should have received a copy of the GNU General Public License version
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
18 *
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
21 * questions.
1410
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
22 */
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
23
2045
9c96c873c42b Fix includes to match new hotspot mechanism.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1942
diff changeset
24 #include "precompiled.hpp"
6559
d5f7e737827f fixed compilation issues on Solaris. When using SunStudio compiler, Solaris build with DONT_USE_PRECOMPILED_HEADER
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6442
diff changeset
25 #include "memory/oopFactory.hpp"
d5f7e737827f fixed compilation issues on Solaris. When using SunStudio compiler, Solaris build with DONT_USE_PRECOMPILED_HEADER
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6442
diff changeset
26 #include "runtime/javaCalls.hpp"
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
27 #include "graal/graalCompiler.hpp"
3637
ff6a991c6e3c Use GraalEnv to look up types.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3634
diff changeset
28 #include "graal/graalEnv.hpp"
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 7115
diff changeset
29 #include "graal/graalRuntime.hpp"
5150
fdd9dd4508fa some GC fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5130
diff changeset
30 #include "runtime/compilationPolicy.hpp"
14881
1415a62ac8b2 allow to force bootstrap in tiered
Bernhard Urban <bernhard.urban@jku.at>
parents: 14875
diff changeset
31 #include "runtime/globals_extension.hpp"
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
32
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
33 GraalCompiler* GraalCompiler::_instance = NULL;
17374
4a6e24a8fc2c Track code installation time
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17053
diff changeset
34 elapsedTimer GraalCompiler::_codeInstallTimer;
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
35
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7126
diff changeset
36 GraalCompiler::GraalCompiler() : AbstractCompiler(graal) {
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
37 #ifdef COMPILERGRAAL
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
38 _bootstrapping = false;
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
39 _methodsCompiled = 0;
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
40 #endif
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
41 assert(_instance == NULL, "only one instance allowed");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
42 _instance = this;
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
43 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
44
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
45 // Initialization
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
46 void GraalCompiler::initialize() {
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
47 #ifdef COMPILERGRAAL
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
48 if (!UseCompiler || !should_perform_init()) {
15463
a20be10ad437 made Graal work with the HotSpot compiler queue and compiler threads, enabled by -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 15106
diff changeset
49 return;
a20be10ad437 made Graal work with the HotSpot compiler queue and compiler threads, enabled by -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 15106
diff changeset
50 }
a20be10ad437 made Graal work with the HotSpot compiler queue and compiler threads, enabled by -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 15106
diff changeset
51
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
52 BufferBlob* buffer_blob = GraalRuntime::initialize_buffer_blob();
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
53 if (buffer_blob == NULL) {
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
54 set_state(failed);
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
55 } else {
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
56 set_state(initialized);
13156
2e76d94f8383 propagate code-cache-full message up to Java to throw exception instead of crashing VM
twisti
parents: 13106
diff changeset
57 }
13096
b65b34c524cb Ensure _non_oop_bits is initialized before starting compile
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13089
diff changeset
58
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1434
diff changeset
59 {
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1434
diff changeset
60 HandleMark hm;
11561
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 10770
diff changeset
61
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15582
diff changeset
62 // Graal is considered as application code so we need to
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15582
diff changeset
63 // stop the VM deferring compilation now.
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
64 CompilationPolicy::completed_vm_startup();
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15582
diff changeset
65
12652
0dd597c6c9c7 fixed performance regression in hosted CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents: 12647
diff changeset
66 #ifndef PRODUCT
17053
7404e1113697 enable CompileTheWorld in non-hosted mode
Doug Simon <doug.simon@oracle.com>
parents: 16428
diff changeset
67 if (CompileTheWorld && !BootstrapGraal) {
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
68 compile_the_world();
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
69 }
12652
0dd597c6c9c7 fixed performance regression in hosted CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents: 12647
diff changeset
70 #endif
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1434
diff changeset
71 }
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
72 #endif // COMPILERGRAAL
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
73 }
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
74
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
75 #ifdef COMPILERGRAAL
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
76 void GraalCompiler::bootstrap() {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
77 JavaThread* THREAD = JavaThread::current();
18118
e98942f26fa4 graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
Bernhard Urban <bernhard.urban@jku.at>
parents: 18043
diff changeset
78 #ifndef PRODUCT
e98942f26fa4 graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
Bernhard Urban <bernhard.urban@jku.at>
parents: 18043
diff changeset
79 // We turn off CompileTheWorld so that compilation requests are not ignored during bootstrap.
e98942f26fa4 graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
Bernhard Urban <bernhard.urban@jku.at>
parents: 18043
diff changeset
80 bool doCTW = CompileTheWorld;
e98942f26fa4 graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
Bernhard Urban <bernhard.urban@jku.at>
parents: 18043
diff changeset
81 if (CompileTheWorld) {
e98942f26fa4 graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
Bernhard Urban <bernhard.urban@jku.at>
parents: 18043
diff changeset
82 CompileTheWorld = false;
e98942f26fa4 graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
Bernhard Urban <bernhard.urban@jku.at>
parents: 18043
diff changeset
83 }
e98942f26fa4 graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
Bernhard Urban <bernhard.urban@jku.at>
parents: 18043
diff changeset
84 #endif
16136
d32be0297274 support -XX:+BootstrapGraal in conjunction with -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16105
diff changeset
85 _bootstrapping = true;
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
86 ResourceMark rm;
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
87 HandleMark hm;
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
88 if (PrintBootstrap) {
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
89 tty->print("Bootstrapping Graal");
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
90 }
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
91 jlong start = os::javaTimeMillis();
16136
d32be0297274 support -XX:+BootstrapGraal in conjunction with -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16105
diff changeset
92
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
93 Array<Method*>* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods();
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
94 // Initialize compile queue with a selected set of methods.
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
95 int len = objectMethods->length();
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
96 for (int i = 0; i < len; i++) {
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
97 methodHandle mh = objectMethods->at(i);
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
98 if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) {
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
99 ResourceMark rm;
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
100 int hot_count = 10; // TODO: what's the appropriate value?
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
101 CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD);
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
102 }
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
103 }
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
104
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
105 int qsize;
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
106 jlong sleep_time = 1000;
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
107 int z = 0;
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
108 do {
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
109 os::sleep(THREAD, sleep_time, true);
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
110 sleep_time = 100;
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
111 qsize = CompileBroker::queue_size(CompLevel_full_optimization);
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
112 if (PrintBootstrap) {
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
113 while (z < (_methodsCompiled / 100)) {
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
114 ++z;
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
115 tty->print_raw(".");
16136
d32be0297274 support -XX:+BootstrapGraal in conjunction with -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16105
diff changeset
116 }
d32be0297274 support -XX:+BootstrapGraal in conjunction with -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16105
diff changeset
117 }
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
118 } while (qsize != 0);
16136
d32be0297274 support -XX:+BootstrapGraal in conjunction with -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16105
diff changeset
119
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
120 if (PrintBootstrap) {
18043
f55f2d400797 Fix some format strings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 17374
diff changeset
121 tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled);
16136
d32be0297274 support -XX:+BootstrapGraal in conjunction with -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16105
diff changeset
122 }
d32be0297274 support -XX:+BootstrapGraal in conjunction with -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16105
diff changeset
123 _bootstrapping = false;
17053
7404e1113697 enable CompileTheWorld in non-hosted mode
Doug Simon <doug.simon@oracle.com>
parents: 16428
diff changeset
124 #ifndef PRODUCT
18118
e98942f26fa4 graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
Bernhard Urban <bernhard.urban@jku.at>
parents: 18043
diff changeset
125 if (doCTW) {
17053
7404e1113697 enable CompileTheWorld in non-hosted mode
Doug Simon <doug.simon@oracle.com>
parents: 16428
diff changeset
126 compile_the_world();
7404e1113697 enable CompileTheWorld in non-hosted mode
Doug Simon <doug.simon@oracle.com>
parents: 16428
diff changeset
127 }
7404e1113697 enable CompileTheWorld in non-hosted mode
Doug Simon <doug.simon@oracle.com>
parents: 16428
diff changeset
128 #endif
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
129 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
130
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
131 void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task) {
7126
ce248dc0a656 removed all Graal modifications to ci and c1
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
132 GRAAL_EXCEPTION_CONTEXT
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
133
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
134 bool is_osr = entry_bci != InvocationEntryBci;
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
135 if (_bootstrapping && is_osr) {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
136 // no OSR compilations during bootstrap - the compiler is just too slow at this point,
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
137 // and we know that there are no endless loops
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
138 return;
3651
a31028282e3e Support blocking compilation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
139 }
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6699
diff changeset
140
16105
e54507c88a93 placed HandleMark around Graal compilation performed on a native compiler thread
Doug Simon <doug.simon@oracle.com>
parents: 16014
diff changeset
141 HandleMark hm;
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3649
diff changeset
142 ResourceMark rm;
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
143 JavaValue result(T_VOID);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
144 JavaCallArguments args;
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
145 args.push_long((jlong) (address) method());
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
146 args.push_int(entry_bci);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
147 args.push_long((jlong) (address) task);
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
148 args.push_int(task->compile_id());
16428
78ddecd6255f added CHECK macros in uses of SymbolTable::new_symbol; added CHECK_ABORT macros for TRAPS functions that must abort the VM if they throw an exception
Doug Simon <doug.simon@oracle.com>
parents: 16399
diff changeset
149 JavaCalls::call_static(&result, SystemDictionary::CompilationTask_klass(), vmSymbols::compileMetaspaceMethod_name(), vmSymbols::compileMetaspaceMethod_signature(), &args, CHECK_ABORT);
16136
d32be0297274 support -XX:+BootstrapGraal in conjunction with -XX:-UseGraalCompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16105
diff changeset
150
16399
4481cf549cfc removed (Java based) CompilationQueue
Doug Simon <doug.simon@oracle.com>
parents: 16146
diff changeset
151 _methodsCompiled++;
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3649
diff changeset
152 }
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3649
diff changeset
153
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
154
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
155 // Compilation entry point for methods
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
156 void GraalCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
3651
a31028282e3e Support blocking compilation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
157 ShouldNotReachHere();
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
158 }
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
159
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
160 // Print compilation timers and statistics
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
161 void GraalCompiler::print_timers() {
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
162 TRACE_graal_1("GraalCompiler::print_timers");
17374
4a6e24a8fc2c Track code installation time
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 17053
diff changeset
163 tty->print_cr(" Graal code install time: %6.3f s", _codeInstallTimer.seconds());
1410
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
164 }
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
165
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 15495
diff changeset
166 #endif // COMPILERGRAAL
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
167
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
168 #ifndef PRODUCT
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
169 void GraalCompiler::compile_the_world() {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
170 // We turn off CompileTheWorld so that Graal can
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
171 // be compiled by C1/C2 when Graal does a CTW.
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
172 CompileTheWorld = false;
18119
6997fce99fa3 graal/hotspot: fix memleak
Bernhard Urban <bernhard.urban@jku.at>
parents: 18118
diff changeset
173 HandleMark hm;
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
174
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
175 JavaThread* THREAD = JavaThread::current();
16428
78ddecd6255f added CHECK macros in uses of SymbolTable::new_symbol; added CHECK_ABORT macros for TRAPS functions that must abort the VM if they throw an exception
Doug Simon <doug.simon@oracle.com>
parents: 16399
diff changeset
176 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT);
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
177 KlassHandle klass = GraalRuntime::load_required_class(name);
16428
78ddecd6255f added CHECK macros in uses of SymbolTable::new_symbol; added CHECK_ABORT macros for TRAPS functions that must abort the VM if they throw an exception
Doug Simon <doug.simon@oracle.com>
parents: 16399
diff changeset
178 TempNewSymbol compileTheWorld = SymbolTable::new_symbol("compileTheWorld", CHECK_ABORT);
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
179 JavaValue result(T_VOID);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
180 JavaCallArguments args;
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
181 args.push_oop(GraalRuntime::get_HotSpotGraalRuntime());
16428
78ddecd6255f added CHECK macros in uses of SymbolTable::new_symbol; added CHECK_ABORT macros for TRAPS functions that must abort the VM if they throw an exception
Doug Simon <doug.simon@oracle.com>
parents: 16399
diff changeset
182 JavaCalls::call_special(&result, klass, compileTheWorld, vmSymbols::void_method_signature(), &args, CHECK_ABORT);
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
183 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
184 #endif