annotate src/share/vm/opto/c2compiler.cpp @ 4710:41406797186b

7113012: G1: rename not-fully-young GCs as "mixed" Summary: Renamed partially-young GCs as mixed and fully-young GCs as young. Change all external output that includes those terms (GC log and GC ergo log) as well as any comments, fields, methods, etc. The changeset also includes very minor code tidying up (added some curly brackets). Reviewed-by: johnc, brutisso
author tonyp
date Fri, 16 Dec 2011 02:14:27 -0500
parents 1d1603768966
children 6f3fd5150b67
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2192
diff changeset
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1397
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1397
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1397
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
26 #include "opto/c2compiler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
27 #include "opto/runtime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
28 #ifdef TARGET_ARCH_MODEL_x86_32
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
29 # include "adfiles/ad_x86_32.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
30 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
31 #ifdef TARGET_ARCH_MODEL_x86_64
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
32 # include "adfiles/ad_x86_64.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
33 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
34 #ifdef TARGET_ARCH_MODEL_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
35 # include "adfiles/ad_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
36 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
37 #ifdef TARGET_ARCH_MODEL_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
38 # include "adfiles/ad_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1685
diff changeset
39 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
40 #ifdef TARGET_ARCH_MODEL_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
41 # include "adfiles/ad_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
42 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
43 #ifdef TARGET_ARCH_MODEL_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
44 # include "adfiles/ad_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
45 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 volatile int C2Compiler::_runtimes = uninitialized;
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // register information defined by ADLC
a61af66fc99e Initial load
duke
parents:
diff changeset
51 extern const char register_save_policy[];
a61af66fc99e Initial load
duke
parents:
diff changeset
52 extern const int register_save_type[];
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 const char* C2Compiler::retry_no_subsuming_loads() {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 return "retry without subsuming loads";
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
38
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
57 const char* C2Compiler::retry_no_escape_analysis() {
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
58 return "retry without escape analysis";
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
59 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60 void C2Compiler::initialize_runtime() {
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Check assumptions used while running ADLC
a61af66fc99e Initial load
duke
parents:
diff changeset
63 Compile::adlc_verification();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 OptoReg::vm2opto[i] = OptoReg::Bad;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 VMReg r = OptoReg::as_VMReg(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 if (r->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 OptoReg::vm2opto[r->value()] = i;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Check that runtime and architecture description agree on callee-saved-floats
a61af66fc99e Initial load
duke
parents:
diff changeset
78 bool callee_saved_floats = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(_last_Mach_Reg); i = OptoReg::add(i,1) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Is there a callee-saved float or double?
a61af66fc99e Initial load
duke
parents:
diff changeset
81 if( register_save_policy[i] == 'E' /* callee-saved */ &&
a61af66fc99e Initial load
duke
parents:
diff changeset
82 (register_save_type[i] == Op_RegF || register_save_type[i] == Op_RegD) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 callee_saved_floats = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 DEBUG_ONLY( Node::init_NodeProperty(); )
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 Compile::pd_compiler2_init();
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 CompilerThread* thread = CompilerThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 HandleMark handle_mark(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 OptoRuntime::generate(thread->env());
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void C2Compiler::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // This method can only be called once per C2Compiler object
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // The first compiler thread that gets here will initialize the
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // small amount of global state (and runtime stubs) that c2 needs.
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // There is a race possible once at startup and then we're fine
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Note that this is being called from a compiler thread not the
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // main startup thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (_runtimes != initialized) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 initialize_runtimes( initialize_runtime, &_runtimes);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Mark this compiler object as ready to roll
a61af66fc99e Initial load
duke
parents:
diff changeset
116 mark_initialized();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void C2Compiler::compile_method(ciEnv* env,
a61af66fc99e Initial load
duke
parents:
diff changeset
120 ciMethod* target,
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int entry_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 if (!is_initialized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
1685
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
125 bool subsume_loads = SubsumeLoads;
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 196
diff changeset
126 bool do_escape_analysis = DoEscapeAnalysis &&
1397
b4776199210f 6943485: JVMTI always on capabilities change code generation too much
never
parents: 844
diff changeset
127 !env->jvmti_can_access_local_variables();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 while (!env->failing()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Attempt to compile while subsuming loads into machine instructions.
38
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
130 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
131
1685
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
132
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Check result and retry if appropriate.
a61af66fc99e Initial load
duke
parents:
diff changeset
134 if (C.failure_reason() != NULL) {
38
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
135 if (C.failure_reason_is(retry_no_subsuming_loads())) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136 assert(subsume_loads, "must make progress");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 subsume_loads = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 continue; // retry
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
38
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
140 if (C.failure_reason_is(retry_no_escape_analysis())) {
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
141 assert(do_escape_analysis, "must make progress");
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
142 do_escape_analysis = false;
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
143 continue; // retry
b789bcaf2dd9 6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents: 0
diff changeset
144 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // Pass any other failure reason up to the ciEnv.
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // Note that serious, irreversible failures are already logged
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // on the ciEnv via env->record_method_not_compilable().
a61af66fc99e Initial load
duke
parents:
diff changeset
148 env->record_failure(C.failure_reason());
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
1685
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
150 if (StressRecompilation) {
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
151 if (subsume_loads) {
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
152 subsume_loads = false;
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
153 continue; // retry
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
154 }
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
155 if (do_escape_analysis) {
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
156 do_escape_analysis = false;
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
157 continue; // retry
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
158 }
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1552
diff changeset
159 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // No retry; just break the loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
162 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 void C2Compiler::print_timers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // do nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }