Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/opto/c2compiler.cpp
32285 views
1
/*
2
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
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
25
#include "precompiled.hpp"
26
#include "opto/c2compiler.hpp"
27
#include "opto/runtime.hpp"
28
#if defined AD_MD_HPP
29
# include AD_MD_HPP
30
#elif defined TARGET_ARCH_MODEL_x86_32
31
# include "adfiles/ad_x86_32.hpp"
32
#elif defined TARGET_ARCH_MODEL_x86_64
33
# include "adfiles/ad_x86_64.hpp"
34
#elif defined TARGET_ARCH_MODEL_aarch32
35
# include "adfiles/ad_aarch32.hpp"
36
#elif defined TARGET_ARCH_MODEL_aarch64
37
# include "adfiles/ad_aarch64.hpp"
38
#elif defined TARGET_ARCH_MODEL_sparc
39
# include "adfiles/ad_sparc.hpp"
40
#elif defined TARGET_ARCH_MODEL_zero
41
# include "adfiles/ad_zero.hpp"
42
#elif defined TARGET_ARCH_MODEL_ppc_64
43
# include "adfiles/ad_ppc_64.hpp"
44
#endif
45
46
// register information defined by ADLC
47
extern const char register_save_policy[];
48
extern const int register_save_type[];
49
50
const char* C2Compiler::retry_no_subsuming_loads() {
51
return "retry without subsuming loads";
52
}
53
const char* C2Compiler::retry_no_escape_analysis() {
54
return "retry without escape analysis";
55
}
56
const char* C2Compiler::retry_class_loading_during_parsing() {
57
return "retry class loading during parsing";
58
}
59
bool C2Compiler::init_c2_runtime() {
60
61
// Check assumptions used while running ADLC
62
Compile::adlc_verification();
63
assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
64
65
for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
66
OptoReg::vm2opto[i] = OptoReg::Bad;
67
}
68
69
for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
70
VMReg r = OptoReg::as_VMReg(i);
71
if (r->is_valid()) {
72
OptoReg::vm2opto[r->value()] = i;
73
}
74
}
75
76
// Check that runtime and architecture description agree on callee-saved-floats
77
bool callee_saved_floats = false;
78
for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {
79
// Is there a callee-saved float or double?
80
if( register_save_policy[i] == 'E' /* callee-saved */ &&
81
(register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {
82
callee_saved_floats = true;
83
}
84
}
85
86
DEBUG_ONLY( Node::init_NodeProperty(); )
87
88
Compile::pd_compiler2_init();
89
90
CompilerThread* thread = CompilerThread::current();
91
92
HandleMark handle_mark(thread);
93
return OptoRuntime::generate(thread->env());
94
}
95
96
97
void C2Compiler::initialize() {
98
// The first compiler thread that gets here will initialize the
99
// small amount of global state (and runtime stubs) that C2 needs.
100
101
// There is a race possible once at startup and then we're fine
102
103
// Note that this is being called from a compiler thread not the
104
// main startup thread.
105
if (should_perform_init()) {
106
bool successful = C2Compiler::init_c2_runtime();
107
int new_state = (successful) ? initialized : failed;
108
set_state(new_state);
109
}
110
}
111
112
void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
113
assert(is_initialized(), "Compiler thread must be initialized");
114
115
bool subsume_loads = SubsumeLoads;
116
bool do_escape_analysis = DoEscapeAnalysis && !env->should_retain_local_variables();
117
bool eliminate_boxing = EliminateAutoBox;
118
while (!env->failing()) {
119
// Attempt to compile while subsuming loads into machine instructions.
120
Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);
121
122
123
// Check result and retry if appropriate.
124
if (C.failure_reason() != NULL) {
125
if (C.failure_reason_is(retry_class_loading_during_parsing())) {
126
env->record_failure(C.failure_reason());
127
continue; // retry
128
}
129
if (C.failure_reason_is(retry_no_subsuming_loads())) {
130
assert(subsume_loads, "must make progress");
131
subsume_loads = false;
132
continue; // retry
133
}
134
if (C.failure_reason_is(retry_no_escape_analysis())) {
135
assert(do_escape_analysis, "must make progress");
136
do_escape_analysis = false;
137
continue; // retry
138
}
139
if (C.has_boxed_value()) {
140
// Recompile without boxing elimination regardless failure reason.
141
assert(eliminate_boxing, "must make progress");
142
eliminate_boxing = false;
143
continue; // retry
144
}
145
// Pass any other failure reason up to the ciEnv.
146
// Note that serious, irreversible failures are already logged
147
// on the ciEnv via env->record_method_not_compilable().
148
env->record_failure(C.failure_reason());
149
}
150
if (StressRecompilation) {
151
if (subsume_loads) {
152
subsume_loads = false;
153
continue; // retry
154
}
155
if (do_escape_analysis) {
156
do_escape_analysis = false;
157
continue; // retry
158
}
159
}
160
161
// No retry; just break the loop.
162
break;
163
}
164
}
165
166
167
void C2Compiler::print_timers() {
168
// do nothing
169
}
170
171