Mercurial > hg > graal-jvmci-8
annotate src/share/vm/c1/c1_Compilation.cpp @ 6973:bb33c6fdcf0d
8001077: remove ciMethod::will_link
Summary: Removed will_link and changed all calls to is_loaded().
Reviewed-by: kvn
author | bharadwaj |
---|---|
date | Thu, 15 Nov 2012 10:42:06 -0800 |
parents | d804e148cff8 |
children | c5d414e98fd4 |
rev | line source |
---|---|
0 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6792
diff
changeset
|
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "c1/c1_CFGPrinter.hpp" | |
27 #include "c1/c1_Compilation.hpp" | |
28 #include "c1/c1_IR.hpp" | |
29 #include "c1/c1_LIRAssembler.hpp" | |
30 #include "c1/c1_LinearScan.hpp" | |
31 #include "c1/c1_MacroAssembler.hpp" | |
32 #include "c1/c1_ValueMap.hpp" | |
33 #include "c1/c1_ValueStack.hpp" | |
34 #include "code/debugInfoRec.hpp" | |
6843 | 35 #include "compiler/compileLog.hpp" |
0 | 36 |
37 | |
38 typedef enum { | |
39 _t_compile, | |
40 _t_setup, | |
41 _t_optimizeIR, | |
42 _t_buildIR, | |
43 _t_emit_lir, | |
44 _t_linearScan, | |
45 _t_lirGeneration, | |
46 _t_lir_schedule, | |
47 _t_codeemit, | |
48 _t_codeinstall, | |
49 max_phase_timers | |
50 } TimerName; | |
51 | |
52 static const char * timer_name[] = { | |
53 "compile", | |
54 "setup", | |
55 "optimizeIR", | |
56 "buildIR", | |
57 "emit_lir", | |
58 "linearScan", | |
59 "lirGeneration", | |
60 "lir_schedule", | |
61 "codeemit", | |
62 "codeinstall" | |
63 }; | |
64 | |
65 static elapsedTimer timers[max_phase_timers]; | |
66 static int totalInstructionNodes = 0; | |
67 | |
68 class PhaseTraceTime: public TraceTime { | |
69 private: | |
70 JavaThread* _thread; | |
6843 | 71 CompileLog* _log; |
0 | 72 |
73 public: | |
6843 | 74 PhaseTraceTime(TimerName timer) |
75 : TraceTime("", &timers[timer], CITime || CITimeEach, Verbose), _log(NULL) { | |
76 if (Compilation::current() != NULL) { | |
77 _log = Compilation::current()->log(); | |
78 } | |
79 | |
80 if (_log != NULL) { | |
81 _log->begin_head("phase name='%s'", timer_name[timer]); | |
82 _log->stamp(); | |
83 _log->end_head(); | |
84 } | |
85 } | |
86 | |
87 ~PhaseTraceTime() { | |
88 if (_log != NULL) | |
89 _log->done("phase"); | |
0 | 90 } |
91 }; | |
92 | |
93 // Implementation of Compilation | |
94 | |
95 | |
96 #ifndef PRODUCT | |
97 | |
98 void Compilation::maybe_print_current_instruction() { | |
99 if (_current_instruction != NULL && _last_instruction_printed != _current_instruction) { | |
100 _last_instruction_printed = _current_instruction; | |
101 _current_instruction->print_line(); | |
102 } | |
103 } | |
104 #endif // PRODUCT | |
105 | |
106 | |
107 DebugInformationRecorder* Compilation::debug_info_recorder() const { | |
108 return _env->debug_info(); | |
109 } | |
110 | |
111 | |
112 Dependencies* Compilation::dependency_recorder() const { | |
113 return _env->dependencies(); | |
114 } | |
115 | |
116 | |
117 void Compilation::initialize() { | |
118 // Use an oop recorder bound to the CI environment. | |
119 // (The default oop recorder is ignorant of the CI.) | |
120 OopRecorder* ooprec = new OopRecorder(_env->arena()); | |
121 _env->set_oop_recorder(ooprec); | |
122 _env->set_debug_info(new DebugInformationRecorder(ooprec)); | |
123 debug_info_recorder()->set_oopmaps(new OopMapSet()); | |
124 _env->set_dependencies(new Dependencies(_env)); | |
125 } | |
126 | |
127 | |
128 void Compilation::build_hir() { | |
129 CHECK_BAILOUT(); | |
130 | |
131 // setup ir | |
132 _hir = new IR(this, method(), osr_bci()); | |
133 if (!_hir->is_valid()) { | |
134 bailout("invalid parsing"); | |
135 return; | |
136 } | |
137 | |
138 #ifndef PRODUCT | |
139 if (PrintCFGToFile) { | |
140 CFGPrinter::print_cfg(_hir, "After Generation of HIR", true, false); | |
141 } | |
142 #endif | |
143 | |
144 #ifndef PRODUCT | |
145 if (PrintCFG || PrintCFG0) { tty->print_cr("CFG after parsing"); _hir->print(true); } | |
146 if (PrintIR || PrintIR0 ) { tty->print_cr("IR after parsing"); _hir->print(false); } | |
147 #endif | |
148 | |
149 _hir->verify(); | |
150 | |
151 if (UseC1Optimizations) { | |
152 NEEDS_CLEANUP | |
153 // optimization | |
154 PhaseTraceTime timeit(_t_optimizeIR); | |
155 | |
156 _hir->optimize(); | |
157 } | |
158 | |
159 _hir->verify(); | |
160 | |
161 _hir->split_critical_edges(); | |
162 | |
163 #ifndef PRODUCT | |
164 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after optimizations"); _hir->print(true); } | |
165 if (PrintIR || PrintIR1 ) { tty->print_cr("IR after optimizations"); _hir->print(false); } | |
166 #endif | |
167 | |
168 _hir->verify(); | |
169 | |
170 // compute block ordering for code generation | |
171 // the control flow must not be changed from here on | |
172 _hir->compute_code(); | |
173 | |
174 if (UseGlobalValueNumbering) { | |
175 ResourceMark rm; | |
176 int instructions = Instruction::number_of_instructions(); | |
177 GlobalValueNumbering gvn(_hir); | |
178 assert(instructions == Instruction::number_of_instructions(), | |
179 "shouldn't have created an instructions"); | |
180 } | |
181 | |
182 // compute use counts after global value numbering | |
183 _hir->compute_use_counts(); | |
184 | |
185 #ifndef PRODUCT | |
186 if (PrintCFG || PrintCFG2) { tty->print_cr("CFG before code generation"); _hir->code()->print(true); } | |
187 if (PrintIR || PrintIR2 ) { tty->print_cr("IR before code generation"); _hir->code()->print(false, true); } | |
188 #endif | |
189 | |
190 _hir->verify(); | |
191 } | |
192 | |
193 | |
194 void Compilation::emit_lir() { | |
195 CHECK_BAILOUT(); | |
196 | |
197 LIRGenerator gen(this, method()); | |
198 { | |
199 PhaseTraceTime timeit(_t_lirGeneration); | |
200 hir()->iterate_linear_scan_order(&gen); | |
201 } | |
202 | |
203 CHECK_BAILOUT(); | |
204 | |
205 { | |
206 PhaseTraceTime timeit(_t_linearScan); | |
207 | |
208 LinearScan* allocator = new LinearScan(hir(), &gen, frame_map()); | |
209 set_allocator(allocator); | |
210 // Assign physical registers to LIR operands using a linear scan algorithm. | |
211 allocator->do_linear_scan(); | |
212 CHECK_BAILOUT(); | |
213 | |
214 _max_spills = allocator->max_spills(); | |
215 } | |
216 | |
217 if (BailoutAfterLIR) { | |
218 if (PrintLIR && !bailed_out()) { | |
219 print_LIR(hir()->code()); | |
220 } | |
221 bailout("Bailing out because of -XX:+BailoutAfterLIR"); | |
222 } | |
223 } | |
224 | |
225 | |
226 void Compilation::emit_code_epilog(LIR_Assembler* assembler) { | |
227 CHECK_BAILOUT(); | |
228 | |
1204 | 229 CodeOffsets* code_offsets = assembler->offsets(); |
230 | |
0 | 231 // generate code or slow cases |
232 assembler->emit_slow_case_stubs(); | |
233 CHECK_BAILOUT(); | |
234 | |
235 // generate exception adapters | |
236 assembler->emit_exception_entries(exception_info_list()); | |
237 CHECK_BAILOUT(); | |
238 | |
1204 | 239 // Generate code for exception handler. |
240 code_offsets->set_value(CodeOffsets::Exceptions, assembler->emit_exception_handler()); | |
0 | 241 CHECK_BAILOUT(); |
1204 | 242 |
243 // Generate code for deopt handler. | |
244 code_offsets->set_value(CodeOffsets::Deopt, assembler->emit_deopt_handler()); | |
245 CHECK_BAILOUT(); | |
246 | |
1691
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1617
diff
changeset
|
247 // Emit the MethodHandle deopt handler code (if required). |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1617
diff
changeset
|
248 if (has_method_handle_invokes()) { |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1617
diff
changeset
|
249 // We can use the same code as for the normal deopt handler, we |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1617
diff
changeset
|
250 // just need a different entry point address. |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1617
diff
changeset
|
251 code_offsets->set_value(CodeOffsets::DeoptMH, assembler->emit_deopt_handler()); |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1617
diff
changeset
|
252 CHECK_BAILOUT(); |
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1617
diff
changeset
|
253 } |
0 | 254 |
1378
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1204
diff
changeset
|
255 // Emit the handler to remove the activation from the stack and |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1204
diff
changeset
|
256 // dispatch to the caller. |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1204
diff
changeset
|
257 offsets()->set_value(CodeOffsets::UnwindHandler, assembler->emit_unwind_handler()); |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1204
diff
changeset
|
258 |
0 | 259 // done |
260 masm()->flush(); | |
261 } | |
262 | |
263 | |
2098
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
264 bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { |
1584 | 265 // Preinitialize the consts section to some large size: |
266 int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo)); | |
267 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); | |
268 code->insts()->initialize_shared_locs((relocInfo*)locs_buffer, | |
269 locs_buffer_size / sizeof(relocInfo)); | |
270 code->initialize_consts_size(Compilation::desired_max_constant_size()); | |
1617
9887b5e57f9e
6962980: C1: stub area should take into account method handle deopt stub
iveresov
parents:
1584
diff
changeset
|
271 // Call stubs + two deopt handlers (regular and MH) + exception handler |
2098
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
272 int stub_size = (call_stub_estimate * LIR_Assembler::call_stub_size) + |
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
273 LIR_Assembler::exception_handler_size + |
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
274 (2 * LIR_Assembler::deopt_handler_size); |
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
275 if (stub_size >= code->insts_capacity()) return false; |
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
276 code->initialize_stubs_size(stub_size); |
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
277 return true; |
1584 | 278 } |
279 | |
280 | |
0 | 281 int Compilation::emit_code_body() { |
282 // emit code | |
2098
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
283 if (!setup_code_buffer(code(), allocator()->num_calls())) { |
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
284 BAILOUT_("size requested greater than avail code buffer size", 0); |
2f9d59b0fa5c
7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents:
2007
diff
changeset
|
285 } |
0 | 286 code()->initialize_oop_recorder(env()->oop_recorder()); |
287 | |
288 _masm = new C1_MacroAssembler(code()); | |
289 _masm->set_oop_recorder(env()->oop_recorder()); | |
290 | |
291 LIR_Assembler lir_asm(this); | |
292 | |
293 lir_asm.emit_code(hir()->code()); | |
294 CHECK_BAILOUT_(0); | |
295 | |
296 emit_code_epilog(&lir_asm); | |
297 CHECK_BAILOUT_(0); | |
298 | |
299 generate_exception_handler_table(); | |
300 | |
301 #ifndef PRODUCT | |
302 if (PrintExceptionHandlers && Verbose) { | |
303 exception_handler_table()->print(); | |
304 } | |
305 #endif /* PRODUCT */ | |
306 | |
307 return frame_map()->framesize(); | |
308 } | |
309 | |
310 | |
311 int Compilation::compile_java_method() { | |
312 assert(!method()->is_native(), "should not reach here"); | |
313 | |
314 if (BailoutOnExceptionHandlers) { | |
315 if (method()->has_exception_handlers()) { | |
316 bailout("linear scan can't handle exception handlers"); | |
317 } | |
318 } | |
319 | |
320 CHECK_BAILOUT_(no_frame_size); | |
321 | |
2007
5ddfcf4b079e
7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents:
1972
diff
changeset
|
322 if (is_profiling() && !method()->ensure_method_data()) { |
5ddfcf4b079e
7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents:
1972
diff
changeset
|
323 BAILOUT_("mdo allocation failed", no_frame_size); |
1783 | 324 } |
325 | |
0 | 326 { |
327 PhaseTraceTime timeit(_t_buildIR); | |
1783 | 328 build_hir(); |
0 | 329 } |
330 if (BailoutAfterHIR) { | |
331 BAILOUT_("Bailing out because of -XX:+BailoutAfterHIR", no_frame_size); | |
332 } | |
333 | |
334 | |
335 { | |
336 PhaseTraceTime timeit(_t_emit_lir); | |
337 | |
338 _frame_map = new FrameMap(method(), hir()->number_of_locks(), MAX2(4, hir()->max_stack())); | |
339 emit_lir(); | |
340 } | |
341 CHECK_BAILOUT_(no_frame_size); | |
342 | |
343 { | |
344 PhaseTraceTime timeit(_t_codeemit); | |
345 return emit_code_body(); | |
346 } | |
347 } | |
348 | |
349 void Compilation::install_code(int frame_size) { | |
350 // frame_size is in 32-bit words so adjust it intptr_t words | |
351 assert(frame_size == frame_map()->framesize(), "must match"); | |
352 assert(in_bytes(frame_map()->framesize_in_bytes()) % sizeof(intptr_t) == 0, "must be at least pointer aligned"); | |
353 _env->register_method( | |
354 method(), | |
355 osr_bci(), | |
356 &_offsets, | |
357 in_bytes(_frame_map->sp_offset_for_orig_pc()), | |
358 code(), | |
359 in_bytes(frame_map()->framesize_in_bytes()) / sizeof(intptr_t), | |
360 debug_info_recorder()->_oopmaps, | |
361 exception_handler_table(), | |
362 implicit_exception_table(), | |
363 compiler(), | |
364 _env->comp_level(), | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6266
diff
changeset
|
365 has_unsafe_access(), |
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6266
diff
changeset
|
366 SharedRuntime::is_wide_vector(max_vector_size()) |
0 | 367 ); |
368 } | |
369 | |
370 | |
371 void Compilation::compile_method() { | |
372 // setup compilation | |
373 initialize(); | |
374 | |
375 if (!method()->can_be_compiled()) { | |
376 // Prevent race condition 6328518. | |
377 // This can happen if the method is obsolete or breakpointed. | |
378 bailout("Bailing out because method is not compilable"); | |
379 return; | |
380 } | |
381 | |
780
c96bf21b756f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
0
diff
changeset
|
382 if (_env->jvmti_can_hotswap_or_post_breakpoint()) { |
0 | 383 // We can assert evol_method because method->can_be_compiled is true. |
384 dependency_recorder()->assert_evol_method(method()); | |
385 } | |
386 | |
387 if (method()->break_at_execute()) { | |
388 BREAKPOINT; | |
389 } | |
390 | |
391 #ifndef PRODUCT | |
392 if (PrintCFGToFile) { | |
393 CFGPrinter::print_compilation(this); | |
394 } | |
395 #endif | |
396 | |
397 // compile method | |
398 int frame_size = compile_java_method(); | |
399 | |
400 // bailout if method couldn't be compiled | |
401 // Note: make sure we mark the method as not compilable! | |
402 CHECK_BAILOUT(); | |
403 | |
404 if (InstallMethods) { | |
405 // install code | |
406 PhaseTraceTime timeit(_t_codeinstall); | |
407 install_code(frame_size); | |
408 } | |
6843 | 409 |
410 if (log() != NULL) // Print code cache state into compiler log | |
411 log()->code_cache_state(); | |
412 | |
0 | 413 totalInstructionNodes += Instruction::number_of_instructions(); |
414 } | |
415 | |
416 | |
417 void Compilation::generate_exception_handler_table() { | |
418 // Generate an ExceptionHandlerTable from the exception handler | |
419 // information accumulated during the compilation. | |
420 ExceptionInfoList* info_list = exception_info_list(); | |
421 | |
422 if (info_list->length() == 0) { | |
423 return; | |
424 } | |
425 | |
426 // allocate some arrays for use by the collection code. | |
427 const int num_handlers = 5; | |
428 GrowableArray<intptr_t>* bcis = new GrowableArray<intptr_t>(num_handlers); | |
429 GrowableArray<intptr_t>* scope_depths = new GrowableArray<intptr_t>(num_handlers); | |
430 GrowableArray<intptr_t>* pcos = new GrowableArray<intptr_t>(num_handlers); | |
431 | |
432 for (int i = 0; i < info_list->length(); i++) { | |
433 ExceptionInfo* info = info_list->at(i); | |
434 XHandlers* handlers = info->exception_handlers(); | |
435 | |
436 // empty the arrays | |
437 bcis->trunc_to(0); | |
438 scope_depths->trunc_to(0); | |
439 pcos->trunc_to(0); | |
440 | |
441 for (int i = 0; i < handlers->length(); i++) { | |
442 XHandler* handler = handlers->handler_at(i); | |
443 assert(handler->entry_pco() != -1, "must have been generated"); | |
444 | |
445 int e = bcis->find(handler->handler_bci()); | |
446 if (e >= 0 && scope_depths->at(e) == handler->scope_count()) { | |
447 // two different handlers are declared to dispatch to the same | |
448 // catch bci. During parsing we created edges for each | |
449 // handler but we really only need one. The exception handler | |
450 // table will also get unhappy if we try to declare both since | |
451 // it's nonsensical. Just skip this handler. | |
452 continue; | |
453 } | |
454 | |
455 bcis->append(handler->handler_bci()); | |
456 if (handler->handler_bci() == -1) { | |
457 // insert a wildcard handler at scope depth 0 so that the | |
458 // exception lookup logic with find it. | |
459 scope_depths->append(0); | |
460 } else { | |
461 scope_depths->append(handler->scope_count()); | |
462 } | |
463 pcos->append(handler->entry_pco()); | |
464 | |
465 // stop processing once we hit a catch any | |
466 if (handler->is_catch_all()) { | |
467 assert(i == handlers->length() - 1, "catch all must be last handler"); | |
468 } | |
469 } | |
470 exception_handler_table()->add_subtable(info->pco(), bcis, scope_depths, pcos); | |
471 } | |
472 } | |
473 | |
474 | |
1584 | 475 Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, |
476 int osr_bci, BufferBlob* buffer_blob) | |
0 | 477 : _compiler(compiler) |
478 , _env(env) | |
6843 | 479 , _log(env->log()) |
0 | 480 , _method(method) |
481 , _osr_bci(osr_bci) | |
482 , _hir(NULL) | |
483 , _max_spills(-1) | |
484 , _frame_map(NULL) | |
485 , _masm(NULL) | |
486 , _has_exception_handlers(false) | |
487 , _has_fpu_code(true) // pessimistic assumption | |
1783 | 488 , _would_profile(false) |
0 | 489 , _has_unsafe_access(false) |
1691
4a665be40fd3
6975855: don't emit deopt MH handler in C1 if not required
twisti
parents:
1617
diff
changeset
|
490 , _has_method_handle_invokes(false) |
0 | 491 , _bailout_msg(NULL) |
492 , _exception_info_list(NULL) | |
493 , _allocator(NULL) | |
1584 | 494 , _next_id(0) |
495 , _next_block_id(0) | |
1748 | 496 , _code(buffer_blob) |
0 | 497 , _current_instruction(NULL) |
498 #ifndef PRODUCT | |
499 , _last_instruction_printed(NULL) | |
500 #endif // PRODUCT | |
501 { | |
502 PhaseTraceTime timeit(_t_compile); | |
503 _arena = Thread::current()->resource_area(); | |
1584 | 504 _env->set_compiler_data(this); |
0 | 505 _exception_info_list = new ExceptionInfoList(); |
506 _implicit_exception_table.set_size(0); | |
507 compile_method(); | |
1964
22ef3370343b
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
1783
diff
changeset
|
508 if (bailed_out()) { |
22ef3370343b
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
1783
diff
changeset
|
509 _env->record_method_not_compilable(bailout_msg(), !TieredCompilation); |
22ef3370343b
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
1783
diff
changeset
|
510 if (is_profiling()) { |
22ef3370343b
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
1783
diff
changeset
|
511 // Compilation failed, create MDO, which would signal the interpreter |
22ef3370343b
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
1783
diff
changeset
|
512 // to start profiling on its own. |
2007
5ddfcf4b079e
7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents:
1972
diff
changeset
|
513 _method->ensure_method_data(); |
1964
22ef3370343b
7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents:
1783
diff
changeset
|
514 } |
2252 | 515 } else if (is_profiling()) { |
2007
5ddfcf4b079e
7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents:
1972
diff
changeset
|
516 ciMethodData *md = method->method_data_or_null(); |
2252 | 517 if (md != NULL) { |
518 md->set_would_profile(_would_profile); | |
519 } | |
1783 | 520 } |
0 | 521 } |
522 | |
523 Compilation::~Compilation() { | |
1584 | 524 _env->set_compiler_data(NULL); |
0 | 525 } |
526 | |
527 | |
528 void Compilation::add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers) { | |
529 #ifndef PRODUCT | |
530 if (PrintExceptionHandlers && Verbose) { | |
531 tty->print_cr(" added exception scope for pco %d", pco); | |
532 } | |
533 #endif | |
534 // Note: we do not have program counters for these exception handlers yet | |
535 exception_info_list()->push(new ExceptionInfo(pco, exception_handlers)); | |
536 } | |
537 | |
538 | |
539 void Compilation::notice_inlined_method(ciMethod* method) { | |
540 _env->notice_inlined_method(method); | |
541 } | |
542 | |
543 | |
544 void Compilation::bailout(const char* msg) { | |
545 assert(msg != NULL, "bailout message must exist"); | |
546 if (!bailed_out()) { | |
547 // keep first bailout message | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3899
diff
changeset
|
548 if (PrintCompilation || PrintBailouts) tty->print_cr("compilation bailout: %s", msg); |
0 | 549 _bailout_msg = msg; |
550 } | |
551 } | |
552 | |
553 | |
554 void Compilation::print_timers() { | |
555 // 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); | |
556 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(); | |
557 | |
558 | |
559 tty->print_cr(" Detailed C1 Timings"); | |
560 tty->print_cr(" Setup time: %6.3f s (%4.1f%%)", timers[_t_setup].seconds(), (timers[_t_setup].seconds() / total) * 100.0); | |
561 tty->print_cr(" Build IR: %6.3f s (%4.1f%%)", timers[_t_buildIR].seconds(), (timers[_t_buildIR].seconds() / total) * 100.0); | |
562 tty->print_cr(" Optimize: %6.3f s (%4.1f%%)", timers[_t_optimizeIR].seconds(), (timers[_t_optimizeIR].seconds() / total) * 100.0); | |
563 tty->print_cr(" Emit LIR: %6.3f s (%4.1f%%)", timers[_t_emit_lir].seconds(), (timers[_t_emit_lir].seconds() / total) * 100.0); | |
564 tty->print_cr(" LIR Gen: %6.3f s (%4.1f%%)", timers[_t_lirGeneration].seconds(), (timers[_t_lirGeneration].seconds() / total) * 100.0); | |
565 tty->print_cr(" Linear Scan: %6.3f s (%4.1f%%)", timers[_t_linearScan].seconds(), (timers[_t_linearScan].seconds() / total) * 100.0); | |
566 NOT_PRODUCT(LinearScan::print_timers(timers[_t_linearScan].seconds())); | |
567 tty->print_cr(" LIR Schedule: %6.3f s (%4.1f%%)", timers[_t_lir_schedule].seconds(), (timers[_t_lir_schedule].seconds() / total) * 100.0); | |
568 tty->print_cr(" Code Emission: %6.3f s (%4.1f%%)", timers[_t_codeemit].seconds(), (timers[_t_codeemit].seconds() / total) * 100.0); | |
569 tty->print_cr(" Code Installation: %6.3f s (%4.1f%%)", timers[_t_codeinstall].seconds(), (timers[_t_codeinstall].seconds() / total) * 100.0); | |
570 tty->print_cr(" Instruction Nodes: %6d nodes", totalInstructionNodes); | |
571 | |
572 NOT_PRODUCT(LinearScan::print_statistics()); | |
573 } | |
574 | |
575 | |
576 #ifndef PRODUCT | |
577 void Compilation::compile_only_this_method() { | |
578 ResourceMark rm; | |
579 fileStream stream(fopen("c1_compile_only", "wt")); | |
580 stream.print_cr("# c1 compile only directives"); | |
581 compile_only_this_scope(&stream, hir()->top_scope()); | |
582 } | |
583 | |
584 | |
585 void Compilation::compile_only_this_scope(outputStream* st, IRScope* scope) { | |
586 st->print("CompileOnly="); | |
587 scope->method()->holder()->name()->print_symbol_on(st); | |
588 st->print("."); | |
589 scope->method()->name()->print_symbol_on(st); | |
590 st->cr(); | |
591 } | |
592 | |
593 | |
594 void Compilation::exclude_this_method() { | |
595 fileStream stream(fopen(".hotspot_compiler", "at")); | |
596 stream.print("exclude "); | |
597 method()->holder()->name()->print_symbol_on(&stream); | |
598 stream.print(" "); | |
599 method()->name()->print_symbol_on(&stream); | |
600 stream.cr(); | |
601 stream.cr(); | |
602 } | |
603 #endif |