annotate src/share/vm/c1/c1_Compilation.cpp @ 1204:18a389214829

6921352: JSR 292 needs its own deopt handler Summary: We need to introduce a new MH deopt handler so we can easily determine if the deopt happened at a MH call site or not. Reviewed-by: never, jrose
author twisti
date Mon, 01 Feb 2010 19:29:46 +0100
parents 24128c2ffa87
children 9f5b60a14736
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
2 * Copyright 1999-2010 Sun Microsystems, Inc. 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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_c1_Compilation.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 typedef enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
30 _t_compile,
a61af66fc99e Initial load
duke
parents:
diff changeset
31 _t_setup,
a61af66fc99e Initial load
duke
parents:
diff changeset
32 _t_optimizeIR,
a61af66fc99e Initial load
duke
parents:
diff changeset
33 _t_buildIR,
a61af66fc99e Initial load
duke
parents:
diff changeset
34 _t_emit_lir,
a61af66fc99e Initial load
duke
parents:
diff changeset
35 _t_linearScan,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 _t_lirGeneration,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 _t_lir_schedule,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 _t_codeemit,
a61af66fc99e Initial load
duke
parents:
diff changeset
39 _t_codeinstall,
a61af66fc99e Initial load
duke
parents:
diff changeset
40 max_phase_timers
a61af66fc99e Initial load
duke
parents:
diff changeset
41 } TimerName;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static const char * timer_name[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 "compile",
a61af66fc99e Initial load
duke
parents:
diff changeset
45 "setup",
a61af66fc99e Initial load
duke
parents:
diff changeset
46 "optimizeIR",
a61af66fc99e Initial load
duke
parents:
diff changeset
47 "buildIR",
a61af66fc99e Initial load
duke
parents:
diff changeset
48 "emit_lir",
a61af66fc99e Initial load
duke
parents:
diff changeset
49 "linearScan",
a61af66fc99e Initial load
duke
parents:
diff changeset
50 "lirGeneration",
a61af66fc99e Initial load
duke
parents:
diff changeset
51 "lir_schedule",
a61af66fc99e Initial load
duke
parents:
diff changeset
52 "codeemit",
a61af66fc99e Initial load
duke
parents:
diff changeset
53 "codeinstall"
a61af66fc99e Initial load
duke
parents:
diff changeset
54 };
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 static elapsedTimer timers[max_phase_timers];
a61af66fc99e Initial load
duke
parents:
diff changeset
57 static int totalInstructionNodes = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 class PhaseTraceTime: public TraceTime {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
61 JavaThread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
64 PhaseTraceTime(TimerName timer):
a61af66fc99e Initial load
duke
parents:
diff changeset
65 TraceTime("", &timers[timer], CITime || CITimeEach, Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 };
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 Arena* Compilation::_arena = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 Compilation* Compilation::_compilation = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Implementation of Compilation
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 void Compilation::maybe_print_current_instruction() {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if (_current_instruction != NULL && _last_instruction_printed != _current_instruction) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _last_instruction_printed = _current_instruction;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _current_instruction->print_line();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 DebugInformationRecorder* Compilation::debug_info_recorder() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return _env->debug_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 Dependencies* Compilation::dependency_recorder() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return _env->dependencies();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void Compilation::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Use an oop recorder bound to the CI environment.
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // (The default oop recorder is ignorant of the CI.)
a61af66fc99e Initial load
duke
parents:
diff changeset
99 OopRecorder* ooprec = new OopRecorder(_env->arena());
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _env->set_oop_recorder(ooprec);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _env->set_debug_info(new DebugInformationRecorder(ooprec));
a61af66fc99e Initial load
duke
parents:
diff changeset
102 debug_info_recorder()->set_oopmaps(new OopMapSet());
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _env->set_dependencies(new Dependencies(_env));
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 void Compilation::build_hir() {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // setup ir
a61af66fc99e Initial load
duke
parents:
diff changeset
111 _hir = new IR(this, method(), osr_bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (!_hir->is_valid()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 bailout("invalid parsing");
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (PrintCFGToFile) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 CFGPrinter::print_cfg(_hir, "After Generation of HIR", true, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if (PrintCFG || PrintCFG0) { tty->print_cr("CFG after parsing"); _hir->print(true); }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 if (PrintIR || PrintIR0 ) { tty->print_cr("IR after parsing"); _hir->print(false); }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 _hir->verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (UseC1Optimizations) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 NEEDS_CLEANUP
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // optimization
a61af66fc99e Initial load
duke
parents:
diff changeset
133 PhaseTraceTime timeit(_t_optimizeIR);
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 _hir->optimize();
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 _hir->verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 _hir->split_critical_edges();
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after optimizations"); _hir->print(true); }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (PrintIR || PrintIR1 ) { tty->print_cr("IR after optimizations"); _hir->print(false); }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 _hir->verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // compute block ordering for code generation
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // the control flow must not be changed from here on
a61af66fc99e Initial load
duke
parents:
diff changeset
151 _hir->compute_code();
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if (UseGlobalValueNumbering) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 int instructions = Instruction::number_of_instructions();
a61af66fc99e Initial load
duke
parents:
diff changeset
156 GlobalValueNumbering gvn(_hir);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 assert(instructions == Instruction::number_of_instructions(),
a61af66fc99e Initial load
duke
parents:
diff changeset
158 "shouldn't have created an instructions");
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // compute use counts after global value numbering
a61af66fc99e Initial load
duke
parents:
diff changeset
162 _hir->compute_use_counts();
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (PrintCFG || PrintCFG2) { tty->print_cr("CFG before code generation"); _hir->code()->print(true); }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (PrintIR || PrintIR2 ) { tty->print_cr("IR before code generation"); _hir->code()->print(false, true); }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 _hir->verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 void Compilation::emit_lir() {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 LIRGenerator gen(this, method());
a61af66fc99e Initial load
duke
parents:
diff changeset
177 {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 PhaseTraceTime timeit(_t_lirGeneration);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 hir()->iterate_linear_scan_order(&gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 PhaseTraceTime timeit(_t_linearScan);
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 LinearScan* allocator = new LinearScan(hir(), &gen, frame_map());
a61af66fc99e Initial load
duke
parents:
diff changeset
188 set_allocator(allocator);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // Assign physical registers to LIR operands using a linear scan algorithm.
a61af66fc99e Initial load
duke
parents:
diff changeset
190 allocator->do_linear_scan();
a61af66fc99e Initial load
duke
parents:
diff changeset
191 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 _max_spills = allocator->max_spills();
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 if (BailoutAfterLIR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 if (PrintLIR && !bailed_out()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 print_LIR(hir()->code());
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 bailout("Bailing out because of -XX:+BailoutAfterLIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 void Compilation::emit_code_epilog(LIR_Assembler* assembler) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
207
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
208 CodeOffsets* code_offsets = assembler->offsets();
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
209
0
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // generate code or slow cases
a61af66fc99e Initial load
duke
parents:
diff changeset
211 assembler->emit_slow_case_stubs();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // generate exception adapters
a61af66fc99e Initial load
duke
parents:
diff changeset
215 assembler->emit_exception_entries(exception_info_list());
a61af66fc99e Initial load
duke
parents:
diff changeset
216 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
217
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
218 // Generate code for exception handler.
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
219 code_offsets->set_value(CodeOffsets::Exceptions, assembler->emit_exception_handler());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
220 CHECK_BAILOUT();
1204
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
221
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
222 // Generate code for deopt handler.
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
223 code_offsets->set_value(CodeOffsets::Deopt, assembler->emit_deopt_handler());
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
224 CHECK_BAILOUT();
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
225
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
226 // Generate code for MethodHandle deopt handler. We can use the
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
227 // same code as for the normal deopt handler, we just need a
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
228 // different entry point address.
18a389214829 6921352: JSR 292 needs its own deopt handler
twisti
parents: 1201
diff changeset
229 code_offsets->set_value(CodeOffsets::DeoptMH, assembler->emit_deopt_handler());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
230 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // done
a61af66fc99e Initial load
duke
parents:
diff changeset
233 masm()->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 int Compilation::emit_code_body() {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // emit code
a61af66fc99e Initial load
duke
parents:
diff changeset
239 Runtime1::setup_code_buffer(code(), allocator()->num_calls());
a61af66fc99e Initial load
duke
parents:
diff changeset
240 code()->initialize_oop_recorder(env()->oop_recorder());
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 _masm = new C1_MacroAssembler(code());
a61af66fc99e Initial load
duke
parents:
diff changeset
243 _masm->set_oop_recorder(env()->oop_recorder());
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 LIR_Assembler lir_asm(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 lir_asm.emit_code(hir()->code());
a61af66fc99e Initial load
duke
parents:
diff changeset
248 CHECK_BAILOUT_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 emit_code_epilog(&lir_asm);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 CHECK_BAILOUT_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 generate_exception_handler_table();
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if (PrintExceptionHandlers && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 exception_handler_table()->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 #endif /* PRODUCT */
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 return frame_map()->framesize();
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 int Compilation::compile_java_method() {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 assert(!method()->is_native(), "should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 if (BailoutOnExceptionHandlers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if (method()->has_exception_handlers()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 bailout("linear scan can't handle exception handlers");
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 CHECK_BAILOUT_(no_frame_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 PhaseTraceTime timeit(_t_buildIR);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 build_hir();
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 if (BailoutAfterHIR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 BAILOUT_("Bailing out because of -XX:+BailoutAfterHIR", no_frame_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 PhaseTraceTime timeit(_t_emit_lir);
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 _frame_map = new FrameMap(method(), hir()->number_of_locks(), MAX2(4, hir()->max_stack()));
a61af66fc99e Initial load
duke
parents:
diff changeset
289 emit_lir();
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 CHECK_BAILOUT_(no_frame_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 PhaseTraceTime timeit(_t_codeemit);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 return emit_code_body();
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 void Compilation::install_code(int frame_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // frame_size is in 32-bit words so adjust it intptr_t words
a61af66fc99e Initial load
duke
parents:
diff changeset
301 assert(frame_size == frame_map()->framesize(), "must match");
a61af66fc99e Initial load
duke
parents:
diff changeset
302 assert(in_bytes(frame_map()->framesize_in_bytes()) % sizeof(intptr_t) == 0, "must be at least pointer aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
303 _env->register_method(
a61af66fc99e Initial load
duke
parents:
diff changeset
304 method(),
a61af66fc99e Initial load
duke
parents:
diff changeset
305 osr_bci(),
a61af66fc99e Initial load
duke
parents:
diff changeset
306 &_offsets,
a61af66fc99e Initial load
duke
parents:
diff changeset
307 in_bytes(_frame_map->sp_offset_for_orig_pc()),
a61af66fc99e Initial load
duke
parents:
diff changeset
308 code(),
a61af66fc99e Initial load
duke
parents:
diff changeset
309 in_bytes(frame_map()->framesize_in_bytes()) / sizeof(intptr_t),
a61af66fc99e Initial load
duke
parents:
diff changeset
310 debug_info_recorder()->_oopmaps,
a61af66fc99e Initial load
duke
parents:
diff changeset
311 exception_handler_table(),
a61af66fc99e Initial load
duke
parents:
diff changeset
312 implicit_exception_table(),
a61af66fc99e Initial load
duke
parents:
diff changeset
313 compiler(),
a61af66fc99e Initial load
duke
parents:
diff changeset
314 _env->comp_level(),
a61af66fc99e Initial load
duke
parents:
diff changeset
315 needs_debug_information(),
a61af66fc99e Initial load
duke
parents:
diff changeset
316 has_unsafe_access()
a61af66fc99e Initial load
duke
parents:
diff changeset
317 );
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 void Compilation::compile_method() {
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // setup compilation
a61af66fc99e Initial load
duke
parents:
diff changeset
323 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 if (!method()->can_be_compiled()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // Prevent race condition 6328518.
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // This can happen if the method is obsolete or breakpointed.
a61af66fc99e Initial load
duke
parents:
diff changeset
328 bailout("Bailing out because method is not compilable");
a61af66fc99e Initial load
duke
parents:
diff changeset
329 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331
780
c96bf21b756f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 0
diff changeset
332 if (_env->jvmti_can_hotswap_or_post_breakpoint()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // We can assert evol_method because method->can_be_compiled is true.
a61af66fc99e Initial load
duke
parents:
diff changeset
334 dependency_recorder()->assert_evol_method(method());
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 if (method()->break_at_execute()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 BREAKPOINT;
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
342 if (PrintCFGToFile) {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 CFGPrinter::print_compilation(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
345 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // compile method
a61af66fc99e Initial load
duke
parents:
diff changeset
348 int frame_size = compile_java_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // bailout if method couldn't be compiled
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Note: make sure we mark the method as not compilable!
a61af66fc99e Initial load
duke
parents:
diff changeset
352 CHECK_BAILOUT();
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 if (InstallMethods) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // install code
a61af66fc99e Initial load
duke
parents:
diff changeset
356 PhaseTraceTime timeit(_t_codeinstall);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 install_code(frame_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359 totalInstructionNodes += Instruction::number_of_instructions();
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 void Compilation::generate_exception_handler_table() {
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // Generate an ExceptionHandlerTable from the exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // information accumulated during the compilation.
a61af66fc99e Initial load
duke
parents:
diff changeset
366 ExceptionInfoList* info_list = exception_info_list();
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 if (info_list->length() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // allocate some arrays for use by the collection code.
a61af66fc99e Initial load
duke
parents:
diff changeset
373 const int num_handlers = 5;
a61af66fc99e Initial load
duke
parents:
diff changeset
374 GrowableArray<intptr_t>* bcis = new GrowableArray<intptr_t>(num_handlers);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 GrowableArray<intptr_t>* scope_depths = new GrowableArray<intptr_t>(num_handlers);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 GrowableArray<intptr_t>* pcos = new GrowableArray<intptr_t>(num_handlers);
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 for (int i = 0; i < info_list->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 ExceptionInfo* info = info_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
380 XHandlers* handlers = info->exception_handlers();
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382 // empty the arrays
a61af66fc99e Initial load
duke
parents:
diff changeset
383 bcis->trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 scope_depths->trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
385 pcos->trunc_to(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387 for (int i = 0; i < handlers->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 XHandler* handler = handlers->handler_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
389 assert(handler->entry_pco() != -1, "must have been generated");
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 int e = bcis->find(handler->handler_bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
392 if (e >= 0 && scope_depths->at(e) == handler->scope_count()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // two different handlers are declared to dispatch to the same
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // catch bci. During parsing we created edges for each
a61af66fc99e Initial load
duke
parents:
diff changeset
395 // handler but we really only need one. The exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // table will also get unhappy if we try to declare both since
a61af66fc99e Initial load
duke
parents:
diff changeset
397 // it's nonsensical. Just skip this handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
398 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 bcis->append(handler->handler_bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
402 if (handler->handler_bci() == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // insert a wildcard handler at scope depth 0 so that the
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // exception lookup logic with find it.
a61af66fc99e Initial load
duke
parents:
diff changeset
405 scope_depths->append(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
406 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 scope_depths->append(handler->scope_count());
a61af66fc99e Initial load
duke
parents:
diff changeset
408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
409 pcos->append(handler->entry_pco());
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // stop processing once we hit a catch any
a61af66fc99e Initial load
duke
parents:
diff changeset
412 if (handler->is_catch_all()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 assert(i == handlers->length() - 1, "catch all must be last handler");
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416 exception_handler_table()->add_subtable(info->pco(), bcis, scope_depths, pcos);
a61af66fc99e Initial load
duke
parents:
diff changeset
417 }
a61af66fc99e Initial load
duke
parents:
diff changeset
418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, int osr_bci)
a61af66fc99e Initial load
duke
parents:
diff changeset
422 : _compiler(compiler)
a61af66fc99e Initial load
duke
parents:
diff changeset
423 , _env(env)
a61af66fc99e Initial load
duke
parents:
diff changeset
424 , _method(method)
a61af66fc99e Initial load
duke
parents:
diff changeset
425 , _osr_bci(osr_bci)
a61af66fc99e Initial load
duke
parents:
diff changeset
426 , _hir(NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
427 , _max_spills(-1)
a61af66fc99e Initial load
duke
parents:
diff changeset
428 , _frame_map(NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
429 , _masm(NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
430 , _has_exception_handlers(false)
a61af66fc99e Initial load
duke
parents:
diff changeset
431 , _has_fpu_code(true) // pessimistic assumption
a61af66fc99e Initial load
duke
parents:
diff changeset
432 , _has_unsafe_access(false)
a61af66fc99e Initial load
duke
parents:
diff changeset
433 , _bailout_msg(NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
434 , _exception_info_list(NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
435 , _allocator(NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
436 , _code(Runtime1::get_buffer_blob()->instructions_begin(),
a61af66fc99e Initial load
duke
parents:
diff changeset
437 Runtime1::get_buffer_blob()->instructions_size())
a61af66fc99e Initial load
duke
parents:
diff changeset
438 , _current_instruction(NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
439 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
440 , _last_instruction_printed(NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
441 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
442 {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 PhaseTraceTime timeit(_t_compile);
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 assert(_arena == NULL, "shouldn't only one instance of Compilation in existence at a time");
a61af66fc99e Initial load
duke
parents:
diff changeset
446 _arena = Thread::current()->resource_area();
a61af66fc99e Initial load
duke
parents:
diff changeset
447 _compilation = this;
780
c96bf21b756f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 0
diff changeset
448 _needs_debug_information = _env->jvmti_can_examine_or_deopt_anywhere() ||
0
a61af66fc99e Initial load
duke
parents:
diff changeset
449 JavaMonitorsInStackTrace || AlwaysEmitDebugInfo || DeoptimizeALot;
a61af66fc99e Initial load
duke
parents:
diff changeset
450 _exception_info_list = new ExceptionInfoList();
a61af66fc99e Initial load
duke
parents:
diff changeset
451 _implicit_exception_table.set_size(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 compile_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
453 }
a61af66fc99e Initial load
duke
parents:
diff changeset
454
a61af66fc99e Initial load
duke
parents:
diff changeset
455 Compilation::~Compilation() {
a61af66fc99e Initial load
duke
parents:
diff changeset
456 _arena = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
457 _compilation = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 void Compilation::add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
462 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
463 if (PrintExceptionHandlers && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
464 tty->print_cr(" added exception scope for pco %d", pco);
a61af66fc99e Initial load
duke
parents:
diff changeset
465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
466 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
467 // Note: we do not have program counters for these exception handlers yet
a61af66fc99e Initial load
duke
parents:
diff changeset
468 exception_info_list()->push(new ExceptionInfo(pco, exception_handlers));
a61af66fc99e Initial load
duke
parents:
diff changeset
469 }
a61af66fc99e Initial load
duke
parents:
diff changeset
470
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 void Compilation::notice_inlined_method(ciMethod* method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 _env->notice_inlined_method(method);
a61af66fc99e Initial load
duke
parents:
diff changeset
474 }
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476
a61af66fc99e Initial load
duke
parents:
diff changeset
477 void Compilation::bailout(const char* msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
478 assert(msg != NULL, "bailout message must exist");
a61af66fc99e Initial load
duke
parents:
diff changeset
479 if (!bailed_out()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 // keep first bailout message
a61af66fc99e Initial load
duke
parents:
diff changeset
481 if (PrintBailouts) tty->print_cr("compilation bailout: %s", msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
482 _bailout_msg = msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
484 }
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 void Compilation::print_timers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // tty->print_cr(" Native methods : %6.3f s, Average : %2.3f", CompileBroker::_t_native_compilation.seconds(), CompileBroker::_t_native_compilation.seconds() / CompileBroker::_total_native_compile_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
489 float total = timers[_t_setup].seconds() + timers[_t_buildIR].seconds() + timers[_t_emit_lir].seconds() + timers[_t_lir_schedule].seconds() + timers[_t_codeemit].seconds() + timers[_t_codeinstall].seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
490
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 tty->print_cr(" Detailed C1 Timings");
a61af66fc99e Initial load
duke
parents:
diff changeset
493 tty->print_cr(" Setup time: %6.3f s (%4.1f%%)", timers[_t_setup].seconds(), (timers[_t_setup].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
494 tty->print_cr(" Build IR: %6.3f s (%4.1f%%)", timers[_t_buildIR].seconds(), (timers[_t_buildIR].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
495 tty->print_cr(" Optimize: %6.3f s (%4.1f%%)", timers[_t_optimizeIR].seconds(), (timers[_t_optimizeIR].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
496 tty->print_cr(" Emit LIR: %6.3f s (%4.1f%%)", timers[_t_emit_lir].seconds(), (timers[_t_emit_lir].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
497 tty->print_cr(" LIR Gen: %6.3f s (%4.1f%%)", timers[_t_lirGeneration].seconds(), (timers[_t_lirGeneration].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
498 tty->print_cr(" Linear Scan: %6.3f s (%4.1f%%)", timers[_t_linearScan].seconds(), (timers[_t_linearScan].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
499 NOT_PRODUCT(LinearScan::print_timers(timers[_t_linearScan].seconds()));
a61af66fc99e Initial load
duke
parents:
diff changeset
500 tty->print_cr(" LIR Schedule: %6.3f s (%4.1f%%)", timers[_t_lir_schedule].seconds(), (timers[_t_lir_schedule].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
501 tty->print_cr(" Code Emission: %6.3f s (%4.1f%%)", timers[_t_codeemit].seconds(), (timers[_t_codeemit].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
502 tty->print_cr(" Code Installation: %6.3f s (%4.1f%%)", timers[_t_codeinstall].seconds(), (timers[_t_codeinstall].seconds() / total) * 100.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
503 tty->print_cr(" Instruction Nodes: %6d nodes", totalInstructionNodes);
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 NOT_PRODUCT(LinearScan::print_statistics());
a61af66fc99e Initial load
duke
parents:
diff changeset
506 }
a61af66fc99e Initial load
duke
parents:
diff changeset
507
a61af66fc99e Initial load
duke
parents:
diff changeset
508
a61af66fc99e Initial load
duke
parents:
diff changeset
509 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
510 void Compilation::compile_only_this_method() {
a61af66fc99e Initial load
duke
parents:
diff changeset
511 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
512 fileStream stream(fopen("c1_compile_only", "wt"));
a61af66fc99e Initial load
duke
parents:
diff changeset
513 stream.print_cr("# c1 compile only directives");
a61af66fc99e Initial load
duke
parents:
diff changeset
514 compile_only_this_scope(&stream, hir()->top_scope());
a61af66fc99e Initial load
duke
parents:
diff changeset
515 }
a61af66fc99e Initial load
duke
parents:
diff changeset
516
a61af66fc99e Initial load
duke
parents:
diff changeset
517
a61af66fc99e Initial load
duke
parents:
diff changeset
518 void Compilation::compile_only_this_scope(outputStream* st, IRScope* scope) {
a61af66fc99e Initial load
duke
parents:
diff changeset
519 st->print("CompileOnly=");
a61af66fc99e Initial load
duke
parents:
diff changeset
520 scope->method()->holder()->name()->print_symbol_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
521 st->print(".");
a61af66fc99e Initial load
duke
parents:
diff changeset
522 scope->method()->name()->print_symbol_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
523 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
524 }
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526
a61af66fc99e Initial load
duke
parents:
diff changeset
527 void Compilation::exclude_this_method() {
a61af66fc99e Initial load
duke
parents:
diff changeset
528 fileStream stream(fopen(".hotspot_compiler", "at"));
a61af66fc99e Initial load
duke
parents:
diff changeset
529 stream.print("exclude ");
a61af66fc99e Initial load
duke
parents:
diff changeset
530 method()->holder()->name()->print_symbol_on(&stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
531 stream.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
532 method()->name()->print_symbol_on(&stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
533 stream.cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
534 stream.cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
535 }
a61af66fc99e Initial load
duke
parents:
diff changeset
536 #endif