author | thartmann |
Mon, 24 Nov 2014 08:48:15 +0100 | |
changeset 27706 | 3f10f4ac2bd6 |
parent 26913 | 9ad70cd32368 |
child 28395 | fbe08d791778 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24673
diff
changeset
|
2 |
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5353
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5353
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5353
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "opto/c2compiler.hpp" |
|
26796 | 27 |
#include "opto/compile.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24673
diff
changeset
|
28 |
#include "opto/optoreg.hpp" |
26796 | 29 |
#include "opto/output.hpp" |
7397 | 30 |
#include "opto/runtime.hpp" |
1 | 31 |
|
32 |
// register information defined by ADLC |
|
33 |
extern const char register_save_policy[]; |
|
34 |
extern const int register_save_type[]; |
|
35 |
||
36 |
const char* C2Compiler::retry_no_subsuming_loads() { |
|
37 |
return "retry without subsuming loads"; |
|
38 |
} |
|
211
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
39 |
const char* C2Compiler::retry_no_escape_analysis() { |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
40 |
return "retry without escape analysis"; |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
41 |
} |
20707
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
42 |
bool C2Compiler::init_c2_runtime() { |
1 | 43 |
|
44 |
// Check assumptions used while running ADLC |
|
45 |
Compile::adlc_verification(); |
|
46 |
assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts"); |
|
47 |
||
48 |
for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) { |
|
49 |
OptoReg::vm2opto[i] = OptoReg::Bad; |
|
50 |
} |
|
51 |
||
52 |
for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) { |
|
53 |
VMReg r = OptoReg::as_VMReg(i); |
|
54 |
if (r->is_valid()) { |
|
55 |
OptoReg::vm2opto[r->value()] = i; |
|
56 |
} |
|
57 |
} |
|
58 |
||
59 |
// Check that runtime and architecture description agree on callee-saved-floats |
|
60 |
bool callee_saved_floats = false; |
|
61 |
for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) { |
|
62 |
// Is there a callee-saved float or double? |
|
63 |
if( register_save_policy[i] == 'E' /* callee-saved */ && |
|
64 |
(register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) { |
|
65 |
callee_saved_floats = true; |
|
66 |
} |
|
67 |
} |
|
68 |
||
69 |
DEBUG_ONLY( Node::init_NodeProperty(); ) |
|
70 |
||
71 |
Compile::pd_compiler2_init(); |
|
72 |
||
73 |
CompilerThread* thread = CompilerThread::current(); |
|
74 |
||
20707
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
75 |
HandleMark handle_mark(thread); |
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
76 |
return OptoRuntime::generate(thread->env()); |
1 | 77 |
} |
78 |
||
79 |
||
80 |
void C2Compiler::initialize() { |
|
81 |
// The first compiler thread that gets here will initialize the |
|
20707
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
82 |
// small amount of global state (and runtime stubs) that C2 needs. |
1 | 83 |
|
84 |
// There is a race possible once at startup and then we're fine |
|
85 |
||
86 |
// Note that this is being called from a compiler thread not the |
|
87 |
// main startup thread. |
|
20707
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
88 |
if (should_perform_init()) { |
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
89 |
bool successful = C2Compiler::init_c2_runtime(); |
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
90 |
int new_state = (successful) ? initialized : failed; |
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
91 |
set_state(new_state); |
1 | 92 |
} |
93 |
} |
|
94 |
||
20707
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
95 |
void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { |
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
96 |
assert(is_initialized(), "Compiler thread must be initialized"); |
b3b658c6d1f8
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
anoll
parents:
17383
diff
changeset
|
97 |
|
6180 | 98 |
bool subsume_loads = SubsumeLoads; |
22893
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22234
diff
changeset
|
99 |
bool do_escape_analysis = DoEscapeAnalysis && !env->should_retain_local_variables(); |
17383 | 100 |
bool eliminate_boxing = EliminateAutoBox; |
1 | 101 |
while (!env->failing()) { |
102 |
// Attempt to compile while subsuming loads into machine instructions. |
|
17383 | 103 |
Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing); |
1 | 104 |
|
105 |
// Check result and retry if appropriate. |
|
106 |
if (C.failure_reason() != NULL) { |
|
211
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
107 |
if (C.failure_reason_is(retry_no_subsuming_loads())) { |
1 | 108 |
assert(subsume_loads, "must make progress"); |
109 |
subsume_loads = false; |
|
27706
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
26913
diff
changeset
|
110 |
env->report_failure(C.failure_reason()); |
1 | 111 |
continue; // retry |
112 |
} |
|
211
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
113 |
if (C.failure_reason_is(retry_no_escape_analysis())) { |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
114 |
assert(do_escape_analysis, "must make progress"); |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
115 |
do_escape_analysis = false; |
27706
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
26913
diff
changeset
|
116 |
env->report_failure(C.failure_reason()); |
211
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
117 |
continue; // retry |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
118 |
} |
17383 | 119 |
if (C.has_boxed_value()) { |
120 |
// Recompile without boxing elimination regardless failure reason. |
|
121 |
assert(eliminate_boxing, "must make progress"); |
|
122 |
eliminate_boxing = false; |
|
27706
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
26913
diff
changeset
|
123 |
env->report_failure(C.failure_reason()); |
17383 | 124 |
continue; // retry |
125 |
} |
|
1 | 126 |
// Pass any other failure reason up to the ciEnv. |
127 |
// Note that serious, irreversible failures are already logged |
|
128 |
// on the ciEnv via env->record_method_not_compilable(). |
|
129 |
env->record_failure(C.failure_reason()); |
|
130 |
} |
|
6180 | 131 |
if (StressRecompilation) { |
132 |
if (subsume_loads) { |
|
133 |
subsume_loads = false; |
|
134 |
continue; // retry |
|
135 |
} |
|
136 |
if (do_escape_analysis) { |
|
137 |
do_escape_analysis = false; |
|
138 |
continue; // retry |
|
139 |
} |
|
140 |
} |
|
1 | 141 |
|
24673
2ec56802b829
8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents:
22894
diff
changeset
|
142 |
// print inlining for last compilation only |
2ec56802b829
8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents:
22894
diff
changeset
|
143 |
C.dump_print_inlining(); |
2ec56802b829
8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents:
22894
diff
changeset
|
144 |
|
1 | 145 |
// No retry; just break the loop. |
146 |
break; |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
||
151 |
void C2Compiler::print_timers() { |
|
26913 | 152 |
Compile::print_timers(); |
1 | 153 |
} |
26796 | 154 |
|
155 |
int C2Compiler::initial_code_buffer_size() { |
|
156 |
assert(SegmentedCodeCache, "Should be only used with a segmented code cache"); |
|
157 |
return Compile::MAX_inst_size + Compile::MAX_locs_size + initial_const_capacity; |
|
158 |
} |