author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 59056 | 15936b142f86 |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
53193
184c51e48260
8216262: Remove develop flag DelayCompilationDuringStartup
redestad
parents:
52934
diff
changeset
|
2 |
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
33160 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
#include "precompiled.hpp" |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
25 |
#include "compiler/compileBroker.hpp" |
54647
c0d9bc9b4e1f
8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents:
53417
diff
changeset
|
26 |
#include "classfile/moduleEntry.hpp" |
33160 | 27 |
#include "jvmci/jvmciEnv.hpp" |
28 |
#include "jvmci/jvmciRuntime.hpp" |
|
54799
2a25ece54fd8
8223639: [JVMCI] jvmciCompiler.cpp needs to include "oops/objArrayOop.inline.hpp""
gziemski
parents:
54669
diff
changeset
|
29 |
#include "oops/objArrayOop.inline.hpp" |
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
47765
diff
changeset
|
30 |
#include "runtime/handles.inline.hpp" |
33160 | 31 |
|
32 |
JVMCICompiler* JVMCICompiler::_instance = NULL; |
|
33 |
elapsedTimer JVMCICompiler::_codeInstallTimer; |
|
34 |
||
42040
70ec5a09a0d5
8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents:
41322
diff
changeset
|
35 |
JVMCICompiler::JVMCICompiler() : AbstractCompiler(compiler_jvmci) { |
33160 | 36 |
_bootstrapping = false; |
38674
eacc567feae8
8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents:
38666
diff
changeset
|
37 |
_bootstrap_compilation_request_handled = false; |
35845
30025047885d
8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents:
35592
diff
changeset
|
38 |
_methods_compiled = 0; |
33160 | 39 |
assert(_instance == NULL, "only one instance allowed"); |
40 |
_instance = this; |
|
41 |
} |
|
42 |
||
43 |
// Initialization |
|
44 |
void JVMCICompiler::initialize() { |
|
45 |
if (!UseCompiler || !EnableJVMCI || !UseJVMCICompiler || !should_perform_init()) { |
|
46 |
return; |
|
47 |
} |
|
48 |
||
49 |
set_state(initialized); |
|
50 |
} |
|
51 |
||
38674
eacc567feae8
8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents:
38666
diff
changeset
|
52 |
void JVMCICompiler::bootstrap(TRAPS) { |
58041
d8902e9c307c
8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents:
54799
diff
changeset
|
53 |
assert(THREAD->is_Java_thread(), "must be"); |
33632 | 54 |
if (Arguments::mode() == Arguments::_int) { |
55 |
// Nothing to do in -Xint mode |
|
56 |
return; |
|
57 |
} |
|
33160 | 58 |
_bootstrapping = true; |
59 |
ResourceMark rm; |
|
60 |
HandleMark hm; |
|
61 |
if (PrintBootstrap) { |
|
62 |
tty->print("Bootstrapping JVMCI"); |
|
63 |
} |
|
64 |
jlong start = os::javaTimeMillis(); |
|
65 |
||
33602 | 66 |
Array<Method*>* objectMethods = SystemDictionary::Object_klass()->methods(); |
33160 | 67 |
// Initialize compile queue with a selected set of methods. |
68 |
int len = objectMethods->length(); |
|
69 |
for (int i = 0; i < len; i++) { |
|
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
58177
diff
changeset
|
70 |
methodHandle mh(THREAD, objectMethods->at(i)); |
33160 | 71 |
if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { |
72 |
ResourceMark rm; |
|
73 |
int hot_count = 10; // TODO: what's the appropriate value? |
|
38218 | 74 |
CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, CompileTask::Reason_Bootstrap, THREAD); |
33160 | 75 |
} |
76 |
} |
|
77 |
||
78 |
int qsize; |
|
79 |
bool first_round = true; |
|
80 |
int z = 0; |
|
81 |
do { |
|
82 |
// Loop until there is something in the queue. |
|
83 |
do { |
|
58095 | 84 |
((JavaThread*)THREAD)->sleep(100); |
33160 | 85 |
qsize = CompileBroker::queue_size(CompLevel_full_optimization); |
38674
eacc567feae8
8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents:
38666
diff
changeset
|
86 |
} while (!_bootstrap_compilation_request_handled && first_round && qsize == 0); |
33160 | 87 |
first_round = false; |
88 |
if (PrintBootstrap) { |
|
35845
30025047885d
8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents:
35592
diff
changeset
|
89 |
while (z < (_methods_compiled / 100)) { |
33160 | 90 |
++z; |
91 |
tty->print_raw("."); |
|
92 |
} |
|
93 |
} |
|
94 |
} while (qsize != 0); |
|
95 |
||
96 |
if (PrintBootstrap) { |
|
35845
30025047885d
8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents:
35592
diff
changeset
|
97 |
tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methods_compiled); |
33160 | 98 |
} |
99 |
_bootstrapping = false; |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
100 |
JVMCI::compiler_runtime()->bootstrap_finished(CHECK); |
33160 | 101 |
} |
102 |
||
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
58177
diff
changeset
|
103 |
bool JVMCICompiler::force_comp_at_level_simple(const methodHandle& method) { |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
104 |
if (UseJVMCINativeLibrary) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
105 |
// This mechanism exists to force compilation of a JVMCI compiler by C1 |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
106 |
// to reduces the compilation time spent on the JVMCI compiler itself. In |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
107 |
// +UseJVMCINativeLibrary mode, the JVMCI compiler is AOT compiled. |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
108 |
return false; |
33160 | 109 |
} |
110 |
||
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
111 |
if (_bootstrapping) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
112 |
// When bootstrapping, the JVMCI compiler can compile its own methods. |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
113 |
return false; |
33160 | 114 |
} |
115 |
||
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
116 |
JVMCIRuntime* runtime = JVMCI::compiler_runtime(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
117 |
if (runtime != NULL && runtime->is_HotSpotJVMCIRuntime_initialized()) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
118 |
JavaThread* thread = JavaThread::current(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
119 |
HandleMark hm(thread); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
120 |
THREAD_JVMCIENV(thread); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
121 |
JVMCIObject receiver = runtime->get_HotSpotJVMCIRuntime(JVMCIENV); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
122 |
objArrayHandle excludeModules(thread, HotSpotJVMCI::HotSpotJVMCIRuntime::excludeFromJVMCICompilation(JVMCIENV, HotSpotJVMCI::resolve(receiver))); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
123 |
if (excludeModules.not_null()) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
124 |
ModuleEntry* moduleEntry = method->method_holder()->module(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
125 |
for (int i = 0; i < excludeModules->length(); i++) { |
58177 | 126 |
if (excludeModules->obj_at(i) == moduleEntry->module()) { |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
127 |
return true; |
35592
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35557
diff
changeset
|
128 |
} |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35557
diff
changeset
|
129 |
} |
5814f874d736
8147432: JVMCI should report bailouts in PrintCompilation output
never
parents:
35557
diff
changeset
|
130 |
} |
33632 | 131 |
} |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54647
diff
changeset
|
132 |
return false; |
35143
33daaea9d5c2
8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents:
34185
diff
changeset
|
133 |
} |
33160 | 134 |
|
135 |
// Compilation entry point for methods |
|
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33160
diff
changeset
|
136 |
void JVMCICompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, DirectiveSet* directive) { |
33160 | 137 |
ShouldNotReachHere(); |
138 |
} |
|
139 |
||
140 |
// Print compilation timers and statistics |
|
141 |
void JVMCICompiler::print_timers() { |
|
142 |
print_compilation_timers(); |
|
143 |
} |
|
144 |
||
145 |
// Print compilation timers and statistics |
|
146 |
void JVMCICompiler::print_compilation_timers() { |
|
147 |
TRACE_jvmci_1("JVMCICompiler::print_timers"); |
|
148 |
tty->print_cr(" JVMCI code install time: %6.3f s", _codeInstallTimer.seconds()); |
|
149 |
} |