author | vlivanov |
Tue, 10 Sep 2013 14:51:48 -0700 (2013-09-10) | |
changeset 19770 | 7cb9f982ea81 |
parent 17383 | 3665c0901a0d |
child 20707 | b3b658c6d1f8 |
child 22807 | 1cf02ef734e2 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
8921
14bfe81f2a9d
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
8107
diff
changeset
|
2 |
* Copyright (c) 1999, 2011, 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" |
|
27 |
#include "opto/runtime.hpp" |
|
28 |
#ifdef TARGET_ARCH_MODEL_x86_32 |
|
29 |
# include "adfiles/ad_x86_32.hpp" |
|
30 |
#endif |
|
31 |
#ifdef TARGET_ARCH_MODEL_x86_64 |
|
32 |
# include "adfiles/ad_x86_64.hpp" |
|
33 |
#endif |
|
34 |
#ifdef TARGET_ARCH_MODEL_sparc |
|
35 |
# include "adfiles/ad_sparc.hpp" |
|
36 |
#endif |
|
37 |
#ifdef TARGET_ARCH_MODEL_zero |
|
38 |
# include "adfiles/ad_zero.hpp" |
|
39 |
#endif |
|
8107
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
40 |
#ifdef TARGET_ARCH_MODEL_arm |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
41 |
# include "adfiles/ad_arm.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
42 |
#endif |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
43 |
#ifdef TARGET_ARCH_MODEL_ppc |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
44 |
# include "adfiles/ad_ppc.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7397
diff
changeset
|
45 |
#endif |
1 | 46 |
|
47 |
||
48 |
volatile int C2Compiler::_runtimes = uninitialized; |
|
49 |
||
50 |
// register information defined by ADLC |
|
51 |
extern const char register_save_policy[]; |
|
52 |
extern const int register_save_type[]; |
|
53 |
||
54 |
const char* C2Compiler::retry_no_subsuming_loads() { |
|
55 |
return "retry without subsuming loads"; |
|
56 |
} |
|
211
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
57 |
const char* C2Compiler::retry_no_escape_analysis() { |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
58 |
return "retry without escape analysis"; |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
59 |
} |
1 | 60 |
void C2Compiler::initialize_runtime() { |
61 |
||
62 |
// Check assumptions used while running ADLC |
|
63 |
Compile::adlc_verification(); |
|
64 |
assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts"); |
|
65 |
||
66 |
for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) { |
|
67 |
OptoReg::vm2opto[i] = OptoReg::Bad; |
|
68 |
} |
|
69 |
||
70 |
for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) { |
|
71 |
VMReg r = OptoReg::as_VMReg(i); |
|
72 |
if (r->is_valid()) { |
|
73 |
OptoReg::vm2opto[r->value()] = i; |
|
74 |
} |
|
75 |
} |
|
76 |
||
77 |
// Check that runtime and architecture description agree on callee-saved-floats |
|
78 |
bool callee_saved_floats = false; |
|
79 |
for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) { |
|
80 |
// Is there a callee-saved float or double? |
|
81 |
if( register_save_policy[i] == 'E' /* callee-saved */ && |
|
82 |
(register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) { |
|
83 |
callee_saved_floats = true; |
|
84 |
} |
|
85 |
} |
|
86 |
||
87 |
DEBUG_ONLY( Node::init_NodeProperty(); ) |
|
88 |
||
89 |
Compile::pd_compiler2_init(); |
|
90 |
||
91 |
CompilerThread* thread = CompilerThread::current(); |
|
92 |
||
93 |
HandleMark handle_mark(thread); |
|
94 |
||
95 |
OptoRuntime::generate(thread->env()); |
|
96 |
||
97 |
} |
|
98 |
||
99 |
||
100 |
void C2Compiler::initialize() { |
|
101 |
||
102 |
// This method can only be called once per C2Compiler object |
|
103 |
// The first compiler thread that gets here will initialize the |
|
104 |
// small amount of global state (and runtime stubs) that c2 needs. |
|
105 |
||
106 |
// There is a race possible once at startup and then we're fine |
|
107 |
||
108 |
// Note that this is being called from a compiler thread not the |
|
109 |
// main startup thread. |
|
110 |
||
111 |
if (_runtimes != initialized) { |
|
112 |
initialize_runtimes( initialize_runtime, &_runtimes); |
|
113 |
} |
|
114 |
||
115 |
// Mark this compiler object as ready to roll |
|
116 |
mark_initialized(); |
|
117 |
} |
|
118 |
||
119 |
void C2Compiler::compile_method(ciEnv* env, |
|
120 |
ciMethod* target, |
|
121 |
int entry_bci) { |
|
122 |
if (!is_initialized()) { |
|
123 |
initialize(); |
|
124 |
} |
|
6180 | 125 |
bool subsume_loads = SubsumeLoads; |
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
670
diff
changeset
|
126 |
bool do_escape_analysis = DoEscapeAnalysis && |
5353
30f4b75f8005
6943485: JVMTI always on capabilities change code generation too much
never
parents:
3261
diff
changeset
|
127 |
!env->jvmti_can_access_local_variables(); |
17383 | 128 |
bool eliminate_boxing = EliminateAutoBox; |
1 | 129 |
while (!env->failing()) { |
130 |
// Attempt to compile while subsuming loads into machine instructions. |
|
17383 | 131 |
Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing); |
1 | 132 |
|
6180 | 133 |
|
1 | 134 |
// Check result and retry if appropriate. |
135 |
if (C.failure_reason() != NULL) { |
|
211
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
136 |
if (C.failure_reason_is(retry_no_subsuming_loads())) { |
1 | 137 |
assert(subsume_loads, "must make progress"); |
138 |
subsume_loads = false; |
|
139 |
continue; // retry |
|
140 |
} |
|
211
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
141 |
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
|
142 |
assert(do_escape_analysis, "must make progress"); |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
143 |
do_escape_analysis = false; |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
144 |
continue; // retry |
e2b60448c234
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
1
diff
changeset
|
145 |
} |
17383 | 146 |
if (C.has_boxed_value()) { |
147 |
// Recompile without boxing elimination regardless failure reason. |
|
148 |
assert(eliminate_boxing, "must make progress"); |
|
149 |
eliminate_boxing = false; |
|
150 |
continue; // retry |
|
151 |
} |
|
1 | 152 |
// Pass any other failure reason up to the ciEnv. |
153 |
// Note that serious, irreversible failures are already logged |
|
154 |
// on the ciEnv via env->record_method_not_compilable(). |
|
155 |
env->record_failure(C.failure_reason()); |
|
156 |
} |
|
6180 | 157 |
if (StressRecompilation) { |
158 |
if (subsume_loads) { |
|
159 |
subsume_loads = false; |
|
160 |
continue; // retry |
|
161 |
} |
|
162 |
if (do_escape_analysis) { |
|
163 |
do_escape_analysis = false; |
|
164 |
continue; // retry |
|
165 |
} |
|
166 |
} |
|
1 | 167 |
|
168 |
// No retry; just break the loop. |
|
169 |
break; |
|
170 |
} |
|
171 |
} |
|
172 |
||
173 |
||
174 |
void C2Compiler::print_timers() { |
|
175 |
// do nothing |
|
176 |
} |