annotate src/share/vm/c1/c1_Compilation.cpp @ 2733:c124e2e7463e

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