1 /* 2 * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 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_RangeCheckElimination.hpp" 33 #include "c1/c1_ValueMap.hpp" 34 #include "c1/c1_ValueStack.hpp" 35 #include "code/debugInfoRec.hpp" 36 #include "compiler/compilationFailureInfo.hpp" 37 #include "compiler/compilationMemoryStatistic.hpp" 38 #include "compiler/compilerDirectives.hpp" 39 #include "compiler/compileLog.hpp" 40 #include "compiler/compileTask.hpp" 41 #include "compiler/compiler_globals.hpp" 42 #include "compiler/compilerDirectives.hpp" 43 #include "memory/resourceArea.hpp" 44 #include "runtime/sharedRuntime.hpp" 45 #include "runtime/timerTrace.hpp" 46 47 typedef enum { 48 _t_compile, 49 _t_setup, 50 _t_buildIR, 51 _t_hir_parse, 52 _t_gvn, 53 _t_optimize_blocks, 54 _t_optimize_null_checks, 55 _t_rangeCheckElimination, 56 _t_emit_lir, 57 _t_linearScan, 58 _t_lirGeneration, 59 _t_codeemit, 60 _t_codeinstall, 61 max_phase_timers 62 } TimerId; 63 64 static const char * timer_name[] = { 65 "compile", 66 "setup", 67 "buildIR", 68 "parse_hir", 69 "gvn", 70 "optimize_blocks", 71 "optimize_null_checks", 72 "rangeCheckElimination", 73 "emit_lir", 74 "linearScan", 75 "lirGeneration", 76 "codeemit", 77 "codeinstall" 78 }; 79 80 static elapsedTimer timers[max_phase_timers]; 81 82 class PhaseTraceTime: public TraceTime { 83 private: 84 CompileLog* _log; 85 TimerId _timer_id; 86 bool _dolog; 87 88 public: 89 PhaseTraceTime(TimerId timer_id) 90 : TraceTime(timer_name[timer_id], &timers[timer_id], CITime, CITimeVerbose), 91 _log(nullptr), _timer_id(timer_id), _dolog(CITimeVerbose) 92 { 93 if (_dolog) { 94 assert(Compilation::current() != nullptr, "sanity check"); 95 _log = Compilation::current()->log(); 96 } 97 98 if (_log != nullptr) { 99 _log->begin_head("phase name='%s'", timer_name[_timer_id]); 100 _log->stamp(); 101 _log->end_head(); 102 } 103 } 104 105 ~PhaseTraceTime() { 106 if (_log != nullptr) 107 _log->done("phase name='%s'", timer_name[_timer_id]); 108 } 109 }; 110 111 // Implementation of Compilation 112 113 114 #ifndef PRODUCT 115 116 void Compilation::maybe_print_current_instruction() { 117 if (_current_instruction != nullptr && _last_instruction_printed != _current_instruction) { 118 _last_instruction_printed = _current_instruction; 119 _current_instruction->print_line(); 120 } 121 } 122 #endif // PRODUCT 123 124 125 DebugInformationRecorder* Compilation::debug_info_recorder() const { 126 return _env->debug_info(); 127 } 128 129 130 Dependencies* Compilation::dependency_recorder() const { 131 return _env->dependencies(); 132 } 133 134 135 void Compilation::initialize() { 136 // Use an oop recorder bound to the CI environment. 137 // (The default oop recorder is ignorant of the CI.) 138 OopRecorder* ooprec = new OopRecorder(_env->arena()); 139 _env->set_oop_recorder(ooprec); 140 _env->set_debug_info(new DebugInformationRecorder(ooprec)); 141 debug_info_recorder()->set_oopmaps(new OopMapSet()); 142 _env->set_dependencies(new Dependencies(_env)); 143 } 144 145 146 void Compilation::build_hir() { 147 CHECK_BAILOUT(); 148 149 // setup ir 150 CompileLog* log = this->log(); 151 if (log != nullptr) { 152 log->begin_head("parse method='%d' ", 153 log->identify(_method)); 154 log->stamp(); 155 log->end_head(); 156 } 157 { 158 PhaseTraceTime timeit(_t_hir_parse); 159 _hir = new IR(this, method(), osr_bci()); 160 } 161 if (log) log->done("parse"); 162 if (!_hir->is_valid()) { 163 bailout("invalid parsing"); 164 return; 165 } 166 167 #ifndef PRODUCT 168 if (PrintCFGToFile) { 169 CFGPrinter::print_cfg(_hir, "After Generation of HIR", true, false); 170 } 171 #endif 172 173 #ifndef PRODUCT 174 if (PrintCFG || PrintCFG0) { tty->print_cr("CFG after parsing"); _hir->print(true); } 175 if (PrintIR || PrintIR0 ) { tty->print_cr("IR after parsing"); _hir->print(false); } 176 #endif 177 178 _hir->verify(); 179 180 if (UseC1Optimizations) { 181 NEEDS_CLEANUP 182 // optimization 183 PhaseTraceTime timeit(_t_optimize_blocks); 184 185 _hir->optimize_blocks(); 186 } 187 188 _hir->verify(); 189 190 _hir->split_critical_edges(); 191 192 #ifndef PRODUCT 193 if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after optimizations"); _hir->print(true); } 194 if (PrintIR || PrintIR1 ) { tty->print_cr("IR after optimizations"); _hir->print(false); } 195 #endif 196 197 _hir->verify(); 198 199 // compute block ordering for code generation 200 // the control flow must not be changed from here on 201 _hir->compute_code(); 202 203 if (UseGlobalValueNumbering) { 204 // No resource mark here! LoopInvariantCodeMotion can allocate ValueStack objects. 205 PhaseTraceTime timeit(_t_gvn); 206 int instructions = Instruction::number_of_instructions(); 207 GlobalValueNumbering gvn(_hir); 208 assert(instructions == Instruction::number_of_instructions(), 209 "shouldn't have created an instructions"); 210 } 211 212 _hir->verify(); 213 214 #ifndef PRODUCT 215 if (PrintCFGToFile) { 216 CFGPrinter::print_cfg(_hir, "Before RangeCheckElimination", true, false); 217 } 218 #endif 219 220 if (RangeCheckElimination) { 221 if (_hir->osr_entry() == nullptr) { 222 PhaseTraceTime timeit(_t_rangeCheckElimination); 223 RangeCheckElimination::eliminate(_hir); 224 } 225 } 226 227 #ifndef PRODUCT 228 if (PrintCFGToFile) { 229 CFGPrinter::print_cfg(_hir, "After RangeCheckElimination", true, false); 230 } 231 #endif 232 233 if (UseC1Optimizations) { 234 // loop invariant code motion reorders instructions and range 235 // check elimination adds new instructions so do null check 236 // elimination after. 237 NEEDS_CLEANUP 238 // optimization 239 PhaseTraceTime timeit(_t_optimize_null_checks); 240 241 _hir->eliminate_null_checks(); 242 } 243 244 _hir->verify(); 245 246 // compute use counts after global value numbering 247 _hir->compute_use_counts(); 248 249 #ifndef PRODUCT 250 if (PrintCFG || PrintCFG2) { tty->print_cr("CFG before code generation"); _hir->code()->print(true); } 251 if (PrintIR || PrintIR2 ) { tty->print_cr("IR before code generation"); _hir->code()->print(false, true); } 252 #endif 253 254 _hir->verify(); 255 } 256 257 258 void Compilation::emit_lir() { 259 CHECK_BAILOUT(); 260 261 LIRGenerator gen(this, method()); 262 { 263 PhaseTraceTime timeit(_t_lirGeneration); 264 hir()->iterate_linear_scan_order(&gen); 265 } 266 267 CHECK_BAILOUT(); 268 269 { 270 PhaseTraceTime timeit(_t_linearScan); 271 272 LinearScan* allocator = new LinearScan(hir(), &gen, frame_map()); 273 set_allocator(allocator); 274 // Assign physical registers to LIR operands using a linear scan algorithm. 275 allocator->do_linear_scan(); 276 CHECK_BAILOUT(); 277 278 _max_spills = allocator->max_spills(); 279 } 280 281 if (BailoutAfterLIR) { 282 if (PrintLIR && !bailed_out()) { 283 print_LIR(hir()->code()); 284 } 285 bailout("Bailing out because of -XX:+BailoutAfterLIR"); 286 } 287 } 288 289 290 void Compilation::emit_code_epilog(LIR_Assembler* assembler) { 291 CHECK_BAILOUT(); 292 293 CodeOffsets* code_offsets = assembler->offsets(); 294 295 if (!code()->finalize_stubs()) { 296 bailout("CodeCache is full"); 297 return; 298 } 299 300 // generate code or slow cases 301 assembler->emit_slow_case_stubs(); 302 CHECK_BAILOUT(); 303 304 // generate exception adapters 305 assembler->emit_exception_entries(exception_info_list()); 306 CHECK_BAILOUT(); 307 308 // Generate code for exception handler. 309 code_offsets->set_value(CodeOffsets::Exceptions, assembler->emit_exception_handler()); 310 CHECK_BAILOUT(); 311 312 // Generate code for deopt handler. 313 code_offsets->set_value(CodeOffsets::Deopt, assembler->emit_deopt_handler()); 314 CHECK_BAILOUT(); 315 316 // Emit the MethodHandle deopt handler code (if required). 317 if (has_method_handle_invokes()) { 318 // We can use the same code as for the normal deopt handler, we 319 // just need a different entry point address. 320 code_offsets->set_value(CodeOffsets::DeoptMH, assembler->emit_deopt_handler()); 321 CHECK_BAILOUT(); 322 } 323 324 // Emit the handler to remove the activation from the stack and 325 // dispatch to the caller. 326 offsets()->set_value(CodeOffsets::UnwindHandler, assembler->emit_unwind_handler()); 327 } 328 329 330 bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { 331 // Preinitialize the consts section to some large size: 332 int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo)); 333 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); 334 code->insts()->initialize_shared_locs((relocInfo*)locs_buffer, 335 locs_buffer_size / sizeof(relocInfo)); 336 code->initialize_consts_size(Compilation::desired_max_constant_size()); 337 // Call stubs + two deopt handlers (regular and MH) + exception handler 338 int stub_size = (call_stub_estimate * LIR_Assembler::call_stub_size()) + 339 LIR_Assembler::exception_handler_size() + 340 (2 * LIR_Assembler::deopt_handler_size()); 341 if (stub_size >= code->insts_capacity()) return false; 342 code->initialize_stubs_size(stub_size); 343 return true; 344 } 345 346 347 int Compilation::emit_code_body() { 348 // emit code 349 if (!setup_code_buffer(code(), allocator()->num_calls())) { 350 BAILOUT_("size requested greater than avail code buffer size", 0); 351 } 352 code()->initialize_oop_recorder(env()->oop_recorder()); 353 354 _masm = new C1_MacroAssembler(code()); 355 _masm->set_oop_recorder(env()->oop_recorder()); 356 357 LIR_Assembler lir_asm(this); 358 359 lir_asm.emit_code(hir()->code()); 360 CHECK_BAILOUT_(0); 361 362 emit_code_epilog(&lir_asm); 363 CHECK_BAILOUT_(0); 364 365 generate_exception_handler_table(); 366 367 #ifndef PRODUCT 368 if (PrintExceptionHandlers && Verbose) { 369 exception_handler_table()->print(); 370 } 371 #endif /* PRODUCT */ 372 373 _immediate_oops_patched = lir_asm.nr_immediate_oops_patched(); 374 return frame_map()->framesize(); 375 } 376 377 378 int Compilation::compile_java_method() { 379 assert(!method()->is_native(), "should not reach here"); 380 381 if (BailoutOnExceptionHandlers) { 382 if (method()->has_exception_handlers()) { 383 bailout("linear scan can't handle exception handlers"); 384 } 385 } 386 387 CHECK_BAILOUT_(no_frame_size); 388 389 if (is_profiling() && !method()->ensure_method_data()) { 390 BAILOUT_("mdo allocation failed", no_frame_size); 391 } 392 393 { 394 PhaseTraceTime timeit(_t_buildIR); 395 build_hir(); 396 } 397 CHECK_BAILOUT_(no_frame_size); 398 if (BailoutAfterHIR) { 399 BAILOUT_("Bailing out because of -XX:+BailoutAfterHIR", no_frame_size); 400 } 401 402 403 { 404 PhaseTraceTime timeit(_t_emit_lir); 405 406 _frame_map = new FrameMap(method(), hir()->number_of_locks(), hir()->max_stack()); 407 emit_lir(); 408 } 409 CHECK_BAILOUT_(no_frame_size); 410 411 // Dump compilation data to replay it. 412 if (_directive->DumpReplayOption) { 413 env()->dump_replay_data(env()->compile_id()); 414 } 415 416 { 417 PhaseTraceTime timeit(_t_codeemit); 418 return emit_code_body(); 419 } 420 } 421 422 void Compilation::install_code(int frame_size) { 423 // frame_size is in 32-bit words so adjust it intptr_t words 424 assert(frame_size == frame_map()->framesize(), "must match"); 425 assert(in_bytes(frame_map()->framesize_in_bytes()) % sizeof(intptr_t) == 0, "must be at least pointer aligned"); 426 _env->register_method( 427 method(), 428 osr_bci(), 429 &_offsets, 430 in_bytes(_frame_map->sp_offset_for_orig_pc()), 431 code(), 432 in_bytes(frame_map()->framesize_in_bytes()) / sizeof(intptr_t), 433 debug_info_recorder()->_oopmaps, 434 exception_handler_table(), 435 implicit_exception_table(), 436 compiler(), 437 false, // has_clinit_barriers 438 false, // for_preload 439 has_unsafe_access(), 440 SharedRuntime::is_wide_vector(max_vector_size()), 441 has_monitors(), 442 _immediate_oops_patched, 443 should_install_code() 444 ); 445 } 446 447 448 void Compilation::compile_method() { 449 450 { 451 PhaseTraceTime timeit(_t_setup); 452 453 // setup compilation 454 initialize(); 455 CHECK_BAILOUT(); 456 457 } 458 459 if (!method()->can_be_compiled()) { 460 // Prevent race condition 6328518. 461 // This can happen if the method is obsolete or breakpointed. 462 bailout("Bailing out because method is not compilable"); 463 return; 464 } 465 466 if (_env->jvmti_can_hotswap_or_post_breakpoint()) { 467 // We can assert evol_method because method->can_be_compiled is true. 468 dependency_recorder()->assert_evol_method(method()); 469 } 470 471 if (env()->break_at_compile()) { 472 BREAKPOINT; 473 } 474 475 #ifndef PRODUCT 476 if (PrintCFGToFile) { 477 CFGPrinter::print_compilation(this); 478 } 479 #endif 480 481 // compile method 482 int frame_size = compile_java_method(); 483 484 // bailout if method couldn't be compiled 485 // Note: make sure we mark the method as not compilable! 486 CHECK_BAILOUT(); 487 488 { // install code 489 PhaseTraceTime timeit(_t_codeinstall); 490 install_code(frame_size); 491 } 492 493 if (log() != nullptr) // Print code cache state into compiler log 494 log()->code_cache_state(); 495 496 } 497 498 499 void Compilation::generate_exception_handler_table() { 500 // Generate an ExceptionHandlerTable from the exception handler 501 // information accumulated during the compilation. 502 ExceptionInfoList* info_list = exception_info_list(); 503 504 if (info_list->length() == 0) { 505 return; 506 } 507 508 // allocate some arrays for use by the collection code. 509 const int num_handlers = 5; 510 GrowableArray<intptr_t>* bcis = new GrowableArray<intptr_t>(num_handlers); 511 GrowableArray<intptr_t>* scope_depths = new GrowableArray<intptr_t>(num_handlers); 512 GrowableArray<intptr_t>* pcos = new GrowableArray<intptr_t>(num_handlers); 513 514 for (int i = 0; i < info_list->length(); i++) { 515 ExceptionInfo* info = info_list->at(i); 516 XHandlers* handlers = info->exception_handlers(); 517 518 // empty the arrays 519 bcis->trunc_to(0); 520 scope_depths->trunc_to(0); 521 pcos->trunc_to(0); 522 523 int prev_scope = 0; 524 for (int i = 0; i < handlers->length(); i++) { 525 XHandler* handler = handlers->handler_at(i); 526 assert(handler->entry_pco() != -1, "must have been generated"); 527 assert(handler->scope_count() >= prev_scope, "handlers should be sorted by scope"); 528 529 if (handler->scope_count() == prev_scope) { 530 int e = bcis->find_from_end(handler->handler_bci()); 531 if (e >= 0 && scope_depths->at(e) == handler->scope_count()) { 532 // two different handlers are declared to dispatch to the same 533 // catch bci. During parsing we created edges for each 534 // handler but we really only need one. The exception handler 535 // table will also get unhappy if we try to declare both since 536 // it's nonsensical. Just skip this handler. 537 continue; 538 } 539 } 540 541 bcis->append(handler->handler_bci()); 542 if (handler->handler_bci() == -1) { 543 // insert a wildcard handler at scope depth 0 so that the 544 // exception lookup logic with find it. 545 scope_depths->append(0); 546 } else { 547 scope_depths->append(handler->scope_count()); 548 } 549 pcos->append(handler->entry_pco()); 550 551 // stop processing once we hit a catch any 552 if (handler->is_catch_all()) { 553 assert(i == handlers->length() - 1, "catch all must be last handler"); 554 } 555 prev_scope = handler->scope_count(); 556 } 557 exception_handler_table()->add_subtable(info->pco(), bcis, scope_depths, pcos); 558 } 559 } 560 561 Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, 562 int osr_bci, BufferBlob* buffer_blob, bool install_code, DirectiveSet* directive) 563 : _next_id(0) 564 , _next_block_id(0) 565 , _compiler(compiler) 566 , _directive(directive) 567 , _env(env) 568 , _log(env->log()) 569 , _method(method) 570 , _osr_bci(osr_bci) 571 , _hir(nullptr) 572 , _max_spills(-1) 573 , _frame_map(nullptr) 574 , _masm(nullptr) 575 , _has_exception_handlers(false) 576 , _has_fpu_code(true) // pessimistic assumption 577 , _has_unsafe_access(false) 578 , _has_irreducible_loops(false) 579 , _would_profile(false) 580 , _has_method_handle_invokes(false) 581 , _has_reserved_stack_access(method->has_reserved_stack_access()) 582 , _has_monitors(method->is_synchronized() || method->has_monitor_bytecodes()) 583 , _install_code(install_code) 584 , _bailout_msg(nullptr) 585 , _first_failure_details(nullptr) 586 , _exception_info_list(nullptr) 587 , _allocator(nullptr) 588 , _code(buffer_blob) 589 , _has_access_indexed(false) 590 , _interpreter_frame_size(0) 591 , _immediate_oops_patched(0) 592 , _current_instruction(nullptr) 593 #ifndef PRODUCT 594 , _last_instruction_printed(nullptr) 595 , _cfg_printer_output(nullptr) 596 #endif // PRODUCT 597 { 598 _arena = Thread::current()->resource_area(); 599 _env->set_compiler_data(this); 600 _exception_info_list = new ExceptionInfoList(); 601 _implicit_exception_table.set_size(0); 602 PhaseTraceTime timeit(_t_compile); 603 #ifndef PRODUCT 604 if (PrintCFGToFile) { 605 _cfg_printer_output = new CFGPrinterOutput(this); 606 } 607 #endif 608 609 CompilationMemoryStatisticMark cmsm(directive); 610 611 compile_method(); 612 if (bailed_out()) { 613 _env->record_method_not_compilable(bailout_msg()); 614 if (is_profiling()) { 615 // Compilation failed, create MDO, which would signal the interpreter 616 // to start profiling on its own. 617 _method->ensure_method_data(); 618 } 619 } else if (is_profiling()) { 620 ciMethodData *md = method->method_data_or_null(); 621 if (md != nullptr) { 622 md->set_would_profile(_would_profile); 623 } 624 } 625 } 626 627 Compilation::~Compilation() { 628 // simulate crash during compilation 629 assert(CICrashAt < 0 || (uintx)_env->compile_id() != (uintx)CICrashAt, "just as planned"); 630 delete _first_failure_details; 631 _env->set_compiler_data(nullptr); 632 } 633 634 void Compilation::add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers) { 635 #ifndef PRODUCT 636 if (PrintExceptionHandlers && Verbose) { 637 tty->print_cr(" added exception scope for pco %d", pco); 638 } 639 #endif 640 // Note: we do not have program counters for these exception handlers yet 641 exception_info_list()->push(new ExceptionInfo(pco, exception_handlers)); 642 } 643 644 645 void Compilation::notice_inlined_method(ciMethod* method) { 646 _env->notice_inlined_method(method); 647 } 648 649 650 void Compilation::bailout(const char* msg) { 651 assert(msg != nullptr, "bailout message must exist"); 652 if (!bailed_out()) { 653 // keep first bailout message 654 if (PrintCompilation || PrintBailouts) tty->print_cr("compilation bailout: %s", msg); 655 _bailout_msg = msg; 656 if (CaptureBailoutInformation) { 657 _first_failure_details = new CompilationFailureInfo(msg); 658 } 659 } 660 } 661 662 ciKlass* Compilation::cha_exact_type(ciType* type) { 663 if (type != nullptr && type->is_loaded() && type->is_instance_klass()) { 664 ciInstanceKlass* ik = type->as_instance_klass(); 665 assert(ik->exact_klass() == nullptr, "no cha for final klass"); 666 if (DeoptC1 && UseCHA && !(ik->has_subklass() || ik->is_interface())) { 667 dependency_recorder()->assert_leaf_type(ik); 668 return ik; 669 } 670 } 671 return nullptr; 672 } 673 674 void Compilation::print_timers() { 675 tty->print_cr(" C1 Compile Time: %7.3f s", timers[_t_compile].seconds()); 676 tty->print_cr(" Setup time: %7.3f s", timers[_t_setup].seconds()); 677 678 { 679 tty->print_cr(" Build HIR: %7.3f s", timers[_t_buildIR].seconds()); 680 tty->print_cr(" Parse: %7.3f s", timers[_t_hir_parse].seconds()); 681 tty->print_cr(" Optimize blocks: %7.3f s", timers[_t_optimize_blocks].seconds()); 682 tty->print_cr(" GVN: %7.3f s", timers[_t_gvn].seconds()); 683 tty->print_cr(" Null checks elim: %7.3f s", timers[_t_optimize_null_checks].seconds()); 684 tty->print_cr(" Range checks elim: %7.3f s", timers[_t_rangeCheckElimination].seconds()); 685 686 double other = timers[_t_buildIR].seconds() - 687 (timers[_t_hir_parse].seconds() + 688 timers[_t_optimize_blocks].seconds() + 689 timers[_t_gvn].seconds() + 690 timers[_t_optimize_null_checks].seconds() + 691 timers[_t_rangeCheckElimination].seconds()); 692 if (other > 0) { 693 tty->print_cr(" Other: %7.3f s", other); 694 } 695 } 696 697 { 698 tty->print_cr(" Emit LIR: %7.3f s", timers[_t_emit_lir].seconds()); 699 tty->print_cr(" LIR Gen: %7.3f s", timers[_t_lirGeneration].seconds()); 700 tty->print_cr(" Linear Scan: %7.3f s", timers[_t_linearScan].seconds()); 701 NOT_PRODUCT(LinearScan::print_timers(timers[_t_linearScan].seconds())); 702 703 double other = timers[_t_emit_lir].seconds() - 704 (timers[_t_lirGeneration].seconds() + 705 timers[_t_linearScan].seconds()); 706 if (other > 0) { 707 tty->print_cr(" Other: %7.3f s", other); 708 } 709 } 710 711 tty->print_cr(" Code Emission: %7.3f s", timers[_t_codeemit].seconds()); 712 tty->print_cr(" Code Installation: %7.3f s", timers[_t_codeinstall].seconds()); 713 714 double other = timers[_t_compile].seconds() - 715 (timers[_t_setup].seconds() + 716 timers[_t_buildIR].seconds() + 717 timers[_t_emit_lir].seconds() + 718 timers[_t_codeemit].seconds() + 719 timers[_t_codeinstall].seconds()); 720 if (other > 0) { 721 tty->print_cr(" Other: %7.3f s", other); 722 } 723 724 NOT_PRODUCT(LinearScan::print_statistics()); 725 } 726 727 728 #ifndef PRODUCT 729 void CompilationResourceObj::print() const { print_on(tty); } 730 731 void CompilationResourceObj::print_on(outputStream* st) const { 732 st->print_cr("CompilationResourceObj(" INTPTR_FORMAT ")", p2i(this)); 733 } 734 735 // Called from debugger to get the interval with 'reg_num' during register allocation. 736 Interval* find_interval(int reg_num) { 737 return Compilation::current()->allocator()->find_interval_at(reg_num); 738 } 739 740 #endif // NOT PRODUCT