src/share/vm/c1/c1_Compilation.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/c1

src/share/vm/c1/c1_Compilation.cpp

Print this page
rev 9032 : 8137167: JEP165: Compiler Control: Implementation task
Summary: Compiler Control JEP
Reviewed-by: roland, twisti


  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/compileLog.hpp"

  37 #include "runtime/sharedRuntime.hpp"
  38 
  39 typedef enum {
  40   _t_compile,
  41     _t_setup,
  42     _t_buildIR,
  43       _t_hir_parse,
  44       _t_gvn,
  45       _t_optimize_blocks,
  46       _t_optimize_null_checks,
  47       _t_rangeCheckElimination,
  48     _t_emit_lir,
  49       _t_linearScan,
  50       _t_lirGeneration,
  51     _t_codeemit,
  52     _t_codeinstall,
  53   max_phase_timers
  54 } TimerName;
  55 
  56 static const char * timer_name[] = {


 400     PhaseTraceTime timeit(_t_codeemit);
 401     return emit_code_body();
 402   }
 403 }
 404 
 405 void Compilation::install_code(int frame_size) {
 406   // frame_size is in 32-bit words so adjust it intptr_t words
 407   assert(frame_size == frame_map()->framesize(), "must match");
 408   assert(in_bytes(frame_map()->framesize_in_bytes()) % sizeof(intptr_t) == 0, "must be at least pointer aligned");
 409   _env->register_method(
 410     method(),
 411     osr_bci(),
 412     &_offsets,
 413     in_bytes(_frame_map->sp_offset_for_orig_pc()),
 414     code(),
 415     in_bytes(frame_map()->framesize_in_bytes()) / sizeof(intptr_t),
 416     debug_info_recorder()->_oopmaps,
 417     exception_handler_table(),
 418     implicit_exception_table(),
 419     compiler(),
 420     _env->comp_level(),
 421     has_unsafe_access(),
 422     SharedRuntime::is_wide_vector(max_vector_size())

 423   );
 424 }
 425 
 426 
 427 void Compilation::compile_method() {
 428   {
 429     PhaseTraceTime timeit(_t_setup);
 430 
 431     // setup compilation
 432     initialize();
 433   }
 434 
 435   if (!method()->can_be_compiled()) {
 436     // Prevent race condition 6328518.
 437     // This can happen if the method is obsolete or breakpointed.
 438     bailout("Bailing out because method is not compilable");
 439     return;
 440   }
 441 
 442   if (_env->jvmti_can_hotswap_or_post_breakpoint()) {
 443     // We can assert evol_method because method->can_be_compiled is true.
 444     dependency_recorder()->assert_evol_method(method());
 445   }
 446 
 447   if (method()->break_at_execute()) {
 448     BREAKPOINT;
 449   }
 450 
 451 #ifndef PRODUCT
 452   if (PrintCFGToFile) {
 453     CFGPrinter::print_compilation(this);
 454   }
 455 #endif
 456 
 457   // compile method
 458   int frame_size = compile_java_method();
 459 
 460   // bailout if method couldn't be compiled
 461   // Note: make sure we mark the method as not compilable!
 462   CHECK_BAILOUT();
 463 
 464   if (InstallMethods) {
 465     // install code
 466     PhaseTraceTime timeit(_t_codeinstall);
 467     install_code(frame_size);


 516       if (handler->handler_bci() == -1) {
 517         // insert a wildcard handler at scope depth 0 so that the
 518         // exception lookup logic with find it.
 519         scope_depths->append(0);
 520       } else {
 521         scope_depths->append(handler->scope_count());
 522     }
 523       pcos->append(handler->entry_pco());
 524 
 525       // stop processing once we hit a catch any
 526       if (handler->is_catch_all()) {
 527         assert(i == handlers->length() - 1, "catch all must be last handler");
 528   }
 529     }
 530     exception_handler_table()->add_subtable(info->pco(), bcis, scope_depths, pcos);
 531   }
 532 }
 533 
 534 
 535 Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method,
 536                          int osr_bci, BufferBlob* buffer_blob)
 537 : _compiler(compiler)
 538 , _env(env)

 539 , _log(env->log())
 540 , _method(method)
 541 , _osr_bci(osr_bci)
 542 , _hir(NULL)
 543 , _max_spills(-1)
 544 , _frame_map(NULL)
 545 , _masm(NULL)
 546 , _has_exception_handlers(false)
 547 , _has_fpu_code(true)   // pessimistic assumption
 548 , _would_profile(false)
 549 , _has_unsafe_access(false)
 550 , _has_method_handle_invokes(false)
 551 , _bailout_msg(NULL)
 552 , _exception_info_list(NULL)
 553 , _allocator(NULL)
 554 , _next_id(0)
 555 , _next_block_id(0)
 556 , _code(buffer_blob)
 557 , _has_access_indexed(false)
 558 , _current_instruction(NULL)


 568   _implicit_exception_table.set_size(0);
 569   compile_method();
 570   if (bailed_out()) {
 571     _env->record_method_not_compilable(bailout_msg(), !TieredCompilation);
 572     if (is_profiling()) {
 573       // Compilation failed, create MDO, which would signal the interpreter
 574       // to start profiling on its own.
 575       _method->ensure_method_data();
 576     }
 577   } else if (is_profiling()) {
 578     ciMethodData *md = method->method_data_or_null();
 579     if (md != NULL) {
 580       md->set_would_profile(_would_profile);
 581     }
 582   }
 583 }
 584 
 585 Compilation::~Compilation() {
 586   _env->set_compiler_data(NULL);
 587 }
 588 
 589 
 590 void Compilation::add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers) {
 591 #ifndef PRODUCT
 592   if (PrintExceptionHandlers && Verbose) {
 593     tty->print_cr("  added exception scope for pco %d", pco);
 594   }
 595 #endif
 596   // Note: we do not have program counters for these exception handlers yet
 597   exception_info_list()->push(new ExceptionInfo(pco, exception_handlers));
 598 }
 599 
 600 
 601 void Compilation::notice_inlined_method(ciMethod* method) {
 602   _env->notice_inlined_method(method);
 603 }
 604 
 605 
 606 void Compilation::bailout(const char* msg) {
 607   assert(msg != NULL, "bailout message must exist");
 608   if (!bailed_out()) {




  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/compileLog.hpp"
  37 #include "compiler/compilerDirectives.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 
  40 typedef enum {
  41   _t_compile,
  42     _t_setup,
  43     _t_buildIR,
  44       _t_hir_parse,
  45       _t_gvn,
  46       _t_optimize_blocks,
  47       _t_optimize_null_checks,
  48       _t_rangeCheckElimination,
  49     _t_emit_lir,
  50       _t_linearScan,
  51       _t_lirGeneration,
  52     _t_codeemit,
  53     _t_codeinstall,
  54   max_phase_timers
  55 } TimerName;
  56 
  57 static const char * timer_name[] = {


 401     PhaseTraceTime timeit(_t_codeemit);
 402     return emit_code_body();
 403   }
 404 }
 405 
 406 void Compilation::install_code(int frame_size) {
 407   // frame_size is in 32-bit words so adjust it intptr_t words
 408   assert(frame_size == frame_map()->framesize(), "must match");
 409   assert(in_bytes(frame_map()->framesize_in_bytes()) % sizeof(intptr_t) == 0, "must be at least pointer aligned");
 410   _env->register_method(
 411     method(),
 412     osr_bci(),
 413     &_offsets,
 414     in_bytes(_frame_map->sp_offset_for_orig_pc()),
 415     code(),
 416     in_bytes(frame_map()->framesize_in_bytes()) / sizeof(intptr_t),
 417     debug_info_recorder()->_oopmaps,
 418     exception_handler_table(),
 419     implicit_exception_table(),
 420     compiler(),

 421     has_unsafe_access(),
 422     SharedRuntime::is_wide_vector(max_vector_size()),
 423     directive()
 424   );
 425 }
 426 
 427 
 428 void Compilation::compile_method() {
 429   {
 430     PhaseTraceTime timeit(_t_setup);
 431 
 432     // setup compilation
 433     initialize();
 434   }
 435 
 436   if (!method()->can_be_compiled()) {
 437     // Prevent race condition 6328518.
 438     // This can happen if the method is obsolete or breakpointed.
 439     bailout("Bailing out because method is not compilable");
 440     return;
 441   }
 442 
 443   if (_env->jvmti_can_hotswap_or_post_breakpoint()) {
 444     // We can assert evol_method because method->can_be_compiled is true.
 445     dependency_recorder()->assert_evol_method(method());
 446   }
 447 
 448   if (directive()->BreakAtCompileOption) {
 449     BREAKPOINT;
 450   }
 451 
 452 #ifndef PRODUCT
 453   if (PrintCFGToFile) {
 454     CFGPrinter::print_compilation(this);
 455   }
 456 #endif
 457 
 458   // compile method
 459   int frame_size = compile_java_method();
 460 
 461   // bailout if method couldn't be compiled
 462   // Note: make sure we mark the method as not compilable!
 463   CHECK_BAILOUT();
 464 
 465   if (InstallMethods) {
 466     // install code
 467     PhaseTraceTime timeit(_t_codeinstall);
 468     install_code(frame_size);


 517       if (handler->handler_bci() == -1) {
 518         // insert a wildcard handler at scope depth 0 so that the
 519         // exception lookup logic with find it.
 520         scope_depths->append(0);
 521       } else {
 522         scope_depths->append(handler->scope_count());
 523     }
 524       pcos->append(handler->entry_pco());
 525 
 526       // stop processing once we hit a catch any
 527       if (handler->is_catch_all()) {
 528         assert(i == handlers->length() - 1, "catch all must be last handler");
 529   }
 530     }
 531     exception_handler_table()->add_subtable(info->pco(), bcis, scope_depths, pcos);
 532   }
 533 }
 534 
 535 
 536 Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method,
 537                          int osr_bci, BufferBlob* buffer_blob, DirectiveSet* directive)
 538 : _compiler(compiler)
 539 , _env(env)
 540 , _directive(directive)
 541 , _log(env->log())
 542 , _method(method)
 543 , _osr_bci(osr_bci)
 544 , _hir(NULL)
 545 , _max_spills(-1)
 546 , _frame_map(NULL)
 547 , _masm(NULL)
 548 , _has_exception_handlers(false)
 549 , _has_fpu_code(true)   // pessimistic assumption
 550 , _would_profile(false)
 551 , _has_unsafe_access(false)
 552 , _has_method_handle_invokes(false)
 553 , _bailout_msg(NULL)
 554 , _exception_info_list(NULL)
 555 , _allocator(NULL)
 556 , _next_id(0)
 557 , _next_block_id(0)
 558 , _code(buffer_blob)
 559 , _has_access_indexed(false)
 560 , _current_instruction(NULL)


 570   _implicit_exception_table.set_size(0);
 571   compile_method();
 572   if (bailed_out()) {
 573     _env->record_method_not_compilable(bailout_msg(), !TieredCompilation);
 574     if (is_profiling()) {
 575       // Compilation failed, create MDO, which would signal the interpreter
 576       // to start profiling on its own.
 577       _method->ensure_method_data();
 578     }
 579   } else if (is_profiling()) {
 580     ciMethodData *md = method->method_data_or_null();
 581     if (md != NULL) {
 582       md->set_would_profile(_would_profile);
 583     }
 584   }
 585 }
 586 
 587 Compilation::~Compilation() {
 588   _env->set_compiler_data(NULL);
 589 }

 590 
 591 void Compilation::add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers) {
 592 #ifndef PRODUCT
 593   if (PrintExceptionHandlers && Verbose) {
 594     tty->print_cr("  added exception scope for pco %d", pco);
 595   }
 596 #endif
 597   // Note: we do not have program counters for these exception handlers yet
 598   exception_info_list()->push(new ExceptionInfo(pco, exception_handlers));
 599 }
 600 
 601 
 602 void Compilation::notice_inlined_method(ciMethod* method) {
 603   _env->notice_inlined_method(method);
 604 }
 605 
 606 
 607 void Compilation::bailout(const char* msg) {
 608   assert(msg != NULL, "bailout message must exist");
 609   if (!bailed_out()) {


src/share/vm/c1/c1_Compilation.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File