hotspot/src/share/vm/opto/compile.cpp
changeset 33626 3c94db05e903
parent 33589 7cbd1b2c139b
parent 33469 30f4811eded0
child 34185 ee71c590a456
child 34148 6efbc7ffd767
equal deleted inserted replaced
33625:18e7896ca9fe 33626:3c94db05e903
   462   compile->set_indexSet_free_block_list(NULL);
   462   compile->set_indexSet_free_block_list(NULL);
   463   compile->init_type_arena();
   463   compile->init_type_arena();
   464   Type::Initialize(compile);
   464   Type::Initialize(compile);
   465   _compile->set_scratch_buffer_blob(NULL);
   465   _compile->set_scratch_buffer_blob(NULL);
   466   _compile->begin_method();
   466   _compile->begin_method();
   467   _compile->clone_map().set_debug(_compile->has_method() && _compile->method_has_option(_compile->clone_map().debug_option_name));
   467   _compile->clone_map().set_debug(_compile->has_method() && _compile->directive()->CloneMapDebugOption);
   468 }
   468 }
   469 CompileWrapper::~CompileWrapper() {
   469 CompileWrapper::~CompileWrapper() {
   470   _compile->end_method();
   470   _compile->end_method();
   471   if (_compile->scratch_buffer_blob() != NULL)
   471   if (_compile->scratch_buffer_blob() != NULL)
   472     BufferBlob::free(_compile->scratch_buffer_blob());
   472     BufferBlob::free(_compile->scratch_buffer_blob());
   494     // Recompiling without boxing elimination
   494     // Recompiling without boxing elimination
   495     tty->print_cr("*********************************************************");
   495     tty->print_cr("*********************************************************");
   496     tty->print_cr("** Bailout: Recompile without boxing elimination       **");
   496     tty->print_cr("** Bailout: Recompile without boxing elimination       **");
   497     tty->print_cr("*********************************************************");
   497     tty->print_cr("*********************************************************");
   498   }
   498   }
   499   if (env()->break_at_compile()) {
   499   if (C->directive()->BreakAtCompileOption) {
   500     // Open the debugger when compiling this method.
   500     // Open the debugger when compiling this method.
   501     tty->print("### Breaking when compiling: ");
   501     tty->print("### Breaking when compiling: ");
   502     method()->print_short_name();
   502     method()->print_short_name();
   503     tty->cr();
   503     tty->cr();
   504     BREAKPOINT;
   504     BREAKPOINT;
   615 // Compile a method.  entry_bci is -1 for normal compilations and indicates
   615 // Compile a method.  entry_bci is -1 for normal compilations and indicates
   616 // the continuation bci for on stack replacement.
   616 // the continuation bci for on stack replacement.
   617 
   617 
   618 
   618 
   619 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci,
   619 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci,
   620                   bool subsume_loads, bool do_escape_analysis, bool eliminate_boxing )
   620                   bool subsume_loads, bool do_escape_analysis, bool eliminate_boxing, DirectiveSet* directive)
   621                 : Phase(Compiler),
   621                 : Phase(Compiler),
   622                   _env(ci_env),
   622                   _env(ci_env),
       
   623                   _directive(directive),
   623                   _log(ci_env->log()),
   624                   _log(ci_env->log()),
   624                   _compile_id(ci_env->compile_id()),
   625                   _compile_id(ci_env->compile_id()),
   625                   _save_argument_registers(false),
   626                   _save_argument_registers(false),
   626                   _stub_name(NULL),
   627                   _stub_name(NULL),
   627                   _stub_function(NULL),
   628                   _stub_function(NULL),
   647                   _scratch_const_size(-1),
   648                   _scratch_const_size(-1),
   648                   _in_scratch_emit_size(false),
   649                   _in_scratch_emit_size(false),
   649                   _dead_node_list(comp_arena()),
   650                   _dead_node_list(comp_arena()),
   650                   _dead_node_count(0),
   651                   _dead_node_count(0),
   651 #ifndef PRODUCT
   652 #ifndef PRODUCT
   652                   _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
   653                   _trace_opto_output(directive->TraceOptoOutputOption),
   653                   _in_dump_cnt(0),
   654                   _in_dump_cnt(0),
   654                   _printer(IdealGraphPrinter::printer()),
   655                   _printer(IdealGraphPrinter::printer()),
   655 #endif
   656 #endif
   656                   _congraph(NULL),
   657                   _congraph(NULL),
   657                   _comp_arena(mtCompiler),
   658                   _comp_arena(mtCompiler),
   671                   _print_inlining_idx(0),
   672                   _print_inlining_idx(0),
   672                   _print_inlining_output(NULL),
   673                   _print_inlining_output(NULL),
   673                   _interpreter_frame_size(0),
   674                   _interpreter_frame_size(0),
   674                   _max_node_limit(MaxNodeLimit) {
   675                   _max_node_limit(MaxNodeLimit) {
   675   C = this;
   676   C = this;
   676 
   677 #ifndef PRODUCT
       
   678   if (_printer != NULL) {
       
   679     _printer->set_compile(this);
       
   680   }
       
   681 #endif
   677   CompileWrapper cw(this);
   682   CompileWrapper cw(this);
   678 
   683 
   679   if (CITimeVerbose) {
   684   if (CITimeVerbose) {
   680     tty->print(" ");
   685     tty->print(" ");
   681     target->holder()->name()->print();
   686     target->holder()->name()->print();
   685   }
   690   }
   686   TraceTime t1("Total compilation time", &_t_totalCompilation, CITime, CITimeVerbose);
   691   TraceTime t1("Total compilation time", &_t_totalCompilation, CITime, CITimeVerbose);
   687   TraceTime t2(NULL, &_t_methodCompilation, CITime, false);
   692   TraceTime t2(NULL, &_t_methodCompilation, CITime, false);
   688 
   693 
   689 #ifndef PRODUCT
   694 #ifndef PRODUCT
   690   bool print_opto_assembly = PrintOptoAssembly || _method->has_option("PrintOptoAssembly");
   695   bool print_opto_assembly = directive->PrintOptoAssemblyOption;
   691   if (!print_opto_assembly) {
   696   if (!print_opto_assembly) {
   692     bool print_assembly = (PrintAssembly || _method->should_print_assembly());
   697     bool print_assembly = directive->PrintAssemblyOption;
   693     if (print_assembly && !Disassembler::can_decode()) {
   698     if (print_assembly && !Disassembler::can_decode()) {
   694       tty->print_cr("PrintAssembly request changed to PrintOptoAssembly");
   699       tty->print_cr("PrintAssembly request changed to PrintOptoAssembly");
   695       print_opto_assembly = true;
   700       print_opto_assembly = true;
   696     }
   701     }
   697   }
   702   }
   698   set_print_assembly(print_opto_assembly);
   703   set_print_assembly(print_opto_assembly);
   699   set_parsed_irreducible_loop(false);
   704   set_parsed_irreducible_loop(false);
   700 
   705 
   701   if (method()->has_option("ReplayInline")) {
   706   if (directive->ReplayInlineOption) {
   702     _replay_inline_data = ciReplay::load_inline_data(method(), entry_bci(), ci_env->comp_level());
   707     _replay_inline_data = ciReplay::load_inline_data(method(), entry_bci(), ci_env->comp_level());
   703   }
   708   }
   704 #endif
   709 #endif
   705   set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining));
   710   set_print_inlining(directive->PrintInliningOption NOT_PRODUCT( || PrintOptoInlining));
   706   set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics"));
   711   set_print_intrinsics(directive->PrintIntrinsicsOption);
   707   set_has_irreducible_loop(true); // conservative until build_loop_tree() reset it
   712   set_has_irreducible_loop(true); // conservative until build_loop_tree() reset it
   708 
   713 
   709   if (ProfileTraps RTM_OPT_ONLY( || UseRTMLocking )) {
   714   if (ProfileTraps RTM_OPT_ONLY( || UseRTMLocking )) {
   710     // Make sure the method being compiled gets its own MDO,
   715     // Make sure the method being compiled gets its own MDO,
   711     // so we can at least track the decompile_count().
   716     // so we can at least track the decompile_count().
   835   }
   840   }
   836 
   841 
   837   // Drain the list.
   842   // Drain the list.
   838   Finish_Warm();
   843   Finish_Warm();
   839 #ifndef PRODUCT
   844 #ifndef PRODUCT
   840   if (_printer && _printer->should_print(_method)) {
   845   if (_printer && _printer->should_print(1)) {
   841     _printer->print_inlining(this);
   846     _printer->print_inlining();
   842   }
   847   }
   843 #endif
   848 #endif
   844 
   849 
   845   if (failing())  return;
   850   if (failing())  return;
   846   NOT_PRODUCT( verify_graph_edges(); )
   851   NOT_PRODUCT( verify_graph_edges(); )
   869 #endif
   874 #endif
   870 
   875 
   871   NOT_PRODUCT( verify_barriers(); )
   876   NOT_PRODUCT( verify_barriers(); )
   872 
   877 
   873   // Dump compilation data to replay it.
   878   // Dump compilation data to replay it.
   874   if (method()->has_option("DumpReplay")) {
   879   if (directive->DumpReplayOption) {
   875     env()->dump_replay_data(_compile_id);
   880     env()->dump_replay_data(_compile_id);
   876   }
   881   }
   877   if (method()->has_option("DumpInline") && (ilt() != NULL)) {
   882   if (directive->DumpInlineOption && (ilt() != NULL)) {
   878     env()->dump_inline_data(_compile_id);
   883     env()->dump_inline_data(_compile_id);
   879   }
   884   }
   880 
   885 
   881   // Now that we know the size of all the monitors we can add a fixed slot
   886   // Now that we know the size of all the monitors we can add a fixed slot
   882   // for the original deopt pc.
   887   // for the original deopt pc.
   916                            _orig_pc_slot_offset_in_bytes,
   921                            _orig_pc_slot_offset_in_bytes,
   917                            code_buffer(),
   922                            code_buffer(),
   918                            frame_size_in_words(), _oop_map_set,
   923                            frame_size_in_words(), _oop_map_set,
   919                            &_handler_table, &_inc_table,
   924                            &_handler_table, &_inc_table,
   920                            compiler,
   925                            compiler,
   921                            env()->comp_level(),
       
   922                            has_unsafe_access(),
   926                            has_unsafe_access(),
   923                            SharedRuntime::is_wide_vector(max_vector_size()),
   927                            SharedRuntime::is_wide_vector(max_vector_size()),
       
   928                            _directive,
   924                            rtm_state()
   929                            rtm_state()
   925                            );
   930                            );
   926 
   931 
   927     if (log() != NULL) // Print code cache state into compiler log
   932     if (log() != NULL) // Print code cache state into compiler log
   928       log()->code_cache_state();
   933       log()->code_cache_state();
   936                   address stub_function,
   941                   address stub_function,
   937                   const char *stub_name,
   942                   const char *stub_name,
   938                   int is_fancy_jump,
   943                   int is_fancy_jump,
   939                   bool pass_tls,
   944                   bool pass_tls,
   940                   bool save_arg_registers,
   945                   bool save_arg_registers,
   941                   bool return_pc )
   946                   bool return_pc,
       
   947                   DirectiveSet* directive)
   942   : Phase(Compiler),
   948   : Phase(Compiler),
   943     _env(ci_env),
   949     _env(ci_env),
       
   950     _directive(directive),
   944     _log(ci_env->log()),
   951     _log(ci_env->log()),
   945     _compile_id(0),
   952     _compile_id(0),
   946     _save_argument_registers(save_arg_registers),
   953     _save_argument_registers(save_arg_registers),
   947     _method(NULL),
   954     _method(NULL),
   948     _stub_name(stub_name),
   955     _stub_name(stub_name),
  1088   set_has_unsafe_access(false);
  1095   set_has_unsafe_access(false);
  1089   set_max_vector_size(0);
  1096   set_max_vector_size(0);
  1090   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
  1097   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
  1091   set_decompile_count(0);
  1098   set_decompile_count(0);
  1092 
  1099 
  1093   set_do_freq_based_layout(BlockLayoutByFrequency || method_has_option("BlockLayoutByFrequency"));
  1100   set_do_freq_based_layout(_directive->BlockLayoutByFrequencyOption);
  1094   set_num_loop_opts(LoopOptsCount);
  1101   set_num_loop_opts(LoopOptsCount);
  1095   set_do_inlining(Inline);
  1102   set_do_inlining(Inline);
  1096   set_max_inline_size(MaxInlineSize);
  1103   set_max_inline_size(MaxInlineSize);
  1097   set_freq_inline_size(FreqInlineSize);
  1104   set_freq_inline_size(FreqInlineSize);
  1098   set_do_scheduling(OptoScheduling);
  1105   set_do_scheduling(OptoScheduling);
  1099   set_do_count_invocations(false);
  1106   set_do_count_invocations(false);
  1100   set_do_method_data_update(false);
  1107   set_do_method_data_update(false);
  1101 
  1108 
  1102   set_do_vector_loop(false);
  1109   set_do_vector_loop(false);
  1103 
  1110 
  1104   bool do_vector = false;
       
  1105   if (AllowVectorizeOnDemand) {
  1111   if (AllowVectorizeOnDemand) {
  1106     if (has_method() && (method()->has_option("Vectorize") || method()->has_option("VectorizeDebug"))) {
  1112     if (has_method() && (_directive->VectorizeOption || _directive->VectorizeDebugOption)) {
  1107       set_do_vector_loop(true);
  1113       set_do_vector_loop(true);
       
  1114       NOT_PRODUCT(if (do_vector_loop() && Verbose) {tty->print("Compile::Init: do vectorized loops (SIMD like) for method %s\n",  method()->name()->as_quoted_ascii());})
  1108     } else if (has_method() && method()->name() != 0 &&
  1115     } else if (has_method() && method()->name() != 0 &&
  1109                method()->intrinsic_id() == vmIntrinsics::_forEachRemaining) {
  1116                method()->intrinsic_id() == vmIntrinsics::_forEachRemaining) {
  1110       set_do_vector_loop(true);
  1117       set_do_vector_loop(true);
  1111     }
  1118     }
  1112 #ifndef PRODUCT
  1119   }
  1113     if (do_vector_loop() && Verbose) {
  1120   set_use_cmove(UseCMoveUnconditionally /* || do_vector_loop()*/); //TODO: consider do_vector_loop() mandate use_cmove unconditionally
  1114       tty->print("Compile::Init: do vectorized loops (SIMD like) for method %s\n",  method()->name()->as_quoted_ascii());
  1121   NOT_PRODUCT(if (use_cmove() && Verbose && has_method()) {tty->print("Compile::Init: use CMove without profitability tests for method %s\n",  method()->name()->as_quoted_ascii());})
  1115     }
       
  1116 #endif
       
  1117   }
       
  1118 
  1122 
  1119   set_age_code(has_method() && method()->profile_aging());
  1123   set_age_code(has_method() && method()->profile_aging());
  1120   set_rtm_state(NoRTM); // No RTM lock eliding by default
  1124   set_rtm_state(NoRTM); // No RTM lock eliding by default
  1121   method_has_option_value("MaxNodeLimit", _max_node_limit);
  1125   _max_node_limit = _directive->MaxNodeLimitOption;
       
  1126 
  1122 #if INCLUDE_RTM_OPT
  1127 #if INCLUDE_RTM_OPT
  1123   if (UseRTMLocking && has_method() && (method()->method_data_or_null() != NULL)) {
  1128   if (UseRTMLocking && has_method() && (method()->method_data_or_null() != NULL)) {
  1124     int rtm_state = method()->method_data()->rtm_state();
  1129     int rtm_state = method()->method_data()->rtm_state();
  1125     if (method_has_option("NoRTMLockEliding") || ((rtm_state & NoRTM) != 0)) {
  1130     if (method_has_option("NoRTMLockEliding") || ((rtm_state & NoRTM) != 0)) {
  1126       // Don't generate RTM lock eliding code.
  1131       // Don't generate RTM lock eliding code.
  2089 // Given a graph, optimize it.
  2094 // Given a graph, optimize it.
  2090 void Compile::Optimize() {
  2095 void Compile::Optimize() {
  2091   TracePhase tp("optimizer", &timers[_t_optimizer]);
  2096   TracePhase tp("optimizer", &timers[_t_optimizer]);
  2092 
  2097 
  2093 #ifndef PRODUCT
  2098 #ifndef PRODUCT
  2094   if (env()->break_at_compile()) {
  2099   if (_directive->BreakAtCompileOption) {
  2095     BREAKPOINT;
  2100     BREAKPOINT;
  2096   }
  2101   }
  2097 
  2102 
  2098 #endif
  2103 #endif
  2099 
  2104 
  4355 bool Compile::randomized_select(int count) {
  4360 bool Compile::randomized_select(int count) {
  4356   assert(count > 0, "only positive");
  4361   assert(count > 0, "only positive");
  4357   return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
  4362   return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
  4358 }
  4363 }
  4359 
  4364 
  4360 const char*   CloneMap::debug_option_name = "CloneMapDebug";
       
  4361 CloneMap&     Compile::clone_map()                 { return _clone_map; }
  4365 CloneMap&     Compile::clone_map()                 { return _clone_map; }
  4362 void          Compile::set_clone_map(Dict* d)      { _clone_map._dict = d; }
  4366 void          Compile::set_clone_map(Dict* d)      { _clone_map._dict = d; }
  4363 
  4367 
  4364 void NodeCloneInfo::dump() const {
  4368 void NodeCloneInfo::dump() const {
  4365   tty->print(" {%d:%d} ", idx(), gen());
  4369   tty->print(" {%d:%d} ", idx(), gen());