Wed, 09 Nov 2011 06:14:32 -0800
7109887: java/util/Arrays/CopyMethods.java fails with -XX:+DeoptimizeALot
Summary: zero array when compiled code is deoptimized.
Reviewed-by: never, twisti
1 /*
2 * Copyright (c) 1999, 2011, 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 */
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
40 #ifdef TARGET_ARCH_MODEL_arm
41 # include "adfiles/ad_arm.hpp"
42 #endif
43 #ifdef TARGET_ARCH_MODEL_ppc
44 # include "adfiles/ad_ppc.hpp"
45 #endif
48 volatile int C2Compiler::_runtimes = uninitialized;
50 // register information defined by ADLC
51 extern const char register_save_policy[];
52 extern const int register_save_type[];
54 const char* C2Compiler::retry_no_subsuming_loads() {
55 return "retry without subsuming loads";
56 }
57 const char* C2Compiler::retry_no_escape_analysis() {
58 return "retry without escape analysis";
59 }
60 void C2Compiler::initialize_runtime() {
62 // Check assumptions used while running ADLC
63 Compile::adlc_verification();
64 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
66 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
67 OptoReg::vm2opto[i] = OptoReg::Bad;
68 }
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 }
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 }
87 DEBUG_ONLY( Node::init_NodeProperty(); )
89 Compile::pd_compiler2_init();
91 CompilerThread* thread = CompilerThread::current();
93 HandleMark handle_mark(thread);
95 OptoRuntime::generate(thread->env());
97 }
100 void C2Compiler::initialize() {
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.
106 // There is a race possible once at startup and then we're fine
108 // Note that this is being called from a compiler thread not the
109 // main startup thread.
111 if (_runtimes != initialized) {
112 initialize_runtimes( initialize_runtime, &_runtimes);
113 }
115 // Mark this compiler object as ready to roll
116 mark_initialized();
117 }
119 void C2Compiler::compile_method(ciEnv* env,
120 ciMethod* target,
121 int entry_bci) {
122 if (!is_initialized()) {
123 initialize();
124 }
125 bool subsume_loads = SubsumeLoads;
126 bool do_escape_analysis = DoEscapeAnalysis &&
127 !env->jvmti_can_access_local_variables();
128 while (!env->failing()) {
129 // Attempt to compile while subsuming loads into machine instructions.
130 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis);
133 // Check result and retry if appropriate.
134 if (C.failure_reason() != NULL) {
135 if (C.failure_reason_is(retry_no_subsuming_loads())) {
136 assert(subsume_loads, "must make progress");
137 subsume_loads = false;
138 continue; // retry
139 }
140 if (C.failure_reason_is(retry_no_escape_analysis())) {
141 assert(do_escape_analysis, "must make progress");
142 do_escape_analysis = 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 }
161 // No retry; just break the loop.
162 break;
163 }
164 }
167 void C2Compiler::print_timers() {
168 // do nothing
169 }