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

src/share/vm/opto/compile.cpp

Print this page
rev 8995 : 8046155: JEP165: Compiler Control
Summary:
Reviewed-by:


 447 CompileWrapper::CompileWrapper(Compile* compile) : _compile(compile) {
 448   // the Compile* pointer is stored in the current ciEnv:
 449   ciEnv* env = compile->env();
 450   assert(env == ciEnv::current(), "must already be a ciEnv active");
 451   assert(env->compiler_data() == NULL, "compile already active?");
 452   env->set_compiler_data(compile);
 453   assert(compile == Compile::current(), "sanity");
 454 
 455   compile->set_type_dict(NULL);
 456   compile->set_clone_map(new Dict(cmpkey, hashkey, _compile->comp_arena()));
 457   compile->clone_map().set_clone_idx(0);
 458   compile->set_type_hwm(NULL);
 459   compile->set_type_last_size(0);
 460   compile->set_last_tf(NULL, NULL);
 461   compile->set_indexSet_arena(NULL);
 462   compile->set_indexSet_free_block_list(NULL);
 463   compile->init_type_arena();
 464   Type::Initialize(compile);
 465   _compile->set_scratch_buffer_blob(NULL);
 466   _compile->begin_method();
 467   _compile->clone_map().set_debug(_compile->has_method() && _compile->method_has_option(_compile->clone_map().debug_option_name));
 468 }
 469 CompileWrapper::~CompileWrapper() {
 470   _compile->end_method();
 471   if (_compile->scratch_buffer_blob() != NULL)
 472     BufferBlob::free(_compile->scratch_buffer_blob());
 473   _compile->env()->set_compiler_data(NULL);
 474 }
 475 
 476 
 477 //----------------------------print_compile_messages---------------------------
 478 void Compile::print_compile_messages() {
 479 #ifndef PRODUCT
 480   // Check if recompiling
 481   if (_subsume_loads == false && PrintOpto) {
 482     // Recompiling without allowing machine instructions to subsume loads
 483     tty->print_cr("*********************************************************");
 484     tty->print_cr("** Bailout: Recompile without subsuming loads          **");
 485     tty->print_cr("*********************************************************");
 486   }
 487   if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) {
 488     // Recompiling without escape analysis
 489     tty->print_cr("*********************************************************");
 490     tty->print_cr("** Bailout: Recompile without escape analysis          **");
 491     tty->print_cr("*********************************************************");
 492   }
 493   if (_eliminate_boxing != EliminateAutoBox && PrintOpto) {
 494     // Recompiling without boxing elimination
 495     tty->print_cr("*********************************************************");
 496     tty->print_cr("** Bailout: Recompile without boxing elimination       **");
 497     tty->print_cr("*********************************************************");
 498   }
 499   if (env()->break_at_compile()) {
 500     // Open the debugger when compiling this method.
 501     tty->print("### Breaking when compiling: ");
 502     method()->print_short_name();
 503     tty->cr();
 504     BREAKPOINT;
 505   }
 506 
 507   if( PrintOpto ) {
 508     if (is_osr_compilation()) {
 509       tty->print("[OSR]%3d", _compile_id);
 510     } else {
 511       tty->print("%3d", _compile_id);
 512     }
 513   }
 514 #endif
 515 }
 516 
 517 
 518 //-----------------------init_scratch_buffer_blob------------------------------
 519 // Construct a temporary BufferBlob and cache it for this compile.


 632                   _for_igvn(NULL),
 633                   _warm_calls(NULL),
 634                   _subsume_loads(subsume_loads),
 635                   _do_escape_analysis(do_escape_analysis),
 636                   _eliminate_boxing(eliminate_boxing),
 637                   _failure_reason(NULL),
 638                   _code_buffer("Compile::Fill_buffer"),
 639                   _orig_pc_slot(0),
 640                   _orig_pc_slot_offset_in_bytes(0),
 641                   _has_method_handle_invokes(false),
 642                   _mach_constant_base_node(NULL),
 643                   _node_bundling_limit(0),
 644                   _node_bundling_base(NULL),
 645                   _java_calls(0),
 646                   _inner_loops(0),
 647                   _scratch_const_size(-1),
 648                   _in_scratch_emit_size(false),
 649                   _dead_node_list(comp_arena()),
 650                   _dead_node_count(0),
 651 #ifndef PRODUCT
 652                   _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
 653                   _in_dump_cnt(0),
 654                   _printer(IdealGraphPrinter::printer()),
 655 #endif
 656                   _congraph(NULL),
 657                   _comp_arena(mtCompiler),
 658                   _node_arena(mtCompiler),
 659                   _old_arena(mtCompiler),
 660                   _Compile_types(mtCompiler),
 661                   _replay_inline_data(NULL),
 662                   _late_inlines(comp_arena(), 2, 0, NULL),
 663                   _string_late_inlines(comp_arena(), 2, 0, NULL),
 664                   _boxing_late_inlines(comp_arena(), 2, 0, NULL),
 665                   _late_inlines_pos(0),
 666                   _number_of_mh_late_inlines(0),
 667                   _inlining_progress(false),
 668                   _inlining_incrementally(false),
 669                   _print_inlining_list(NULL),
 670                   _print_inlining_stream(NULL),
 671                   _print_inlining_idx(0),
 672                   _print_inlining_output(NULL),
 673                   _interpreter_frame_size(0),
 674                   _max_node_limit(MaxNodeLimit) {
 675   C = this;
 676 
 677   CompileWrapper cw(this);
 678 
 679   if (CITimeVerbose) {
 680     tty->print(" ");
 681     target->holder()->name()->print();
 682     tty->print(".");
 683     target->print_short_name();
 684     tty->print("  ");
 685   }
 686   TraceTime t1("Total compilation time", &_t_totalCompilation, CITime, CITimeVerbose);
 687   TraceTime t2(NULL, &_t_methodCompilation, CITime, false);
 688 
 689 #ifndef PRODUCT
 690   bool print_opto_assembly = PrintOptoAssembly || _method->has_option("PrintOptoAssembly");
 691   if (!print_opto_assembly) {
 692     bool print_assembly = (PrintAssembly || _method->should_print_assembly());
 693     if (print_assembly && !Disassembler::can_decode()) {
 694       tty->print_cr("PrintAssembly request changed to PrintOptoAssembly");
 695       print_opto_assembly = true;
 696     }
 697   }
 698   set_print_assembly(print_opto_assembly);
 699   set_parsed_irreducible_loop(false);
 700 
 701   if (method()->has_option("ReplayInline")) {
 702     _replay_inline_data = ciReplay::load_inline_data(method(), entry_bci(), ci_env->comp_level());
 703   }
 704 #endif
 705   set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining));
 706   set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics"));
 707   set_has_irreducible_loop(true); // conservative until build_loop_tree() reset it
 708 
 709   if (ProfileTraps RTM_OPT_ONLY( || UseRTMLocking )) {
 710     // Make sure the method being compiled gets its own MDO,
 711     // so we can at least track the decompile_count().
 712     // Need MDO to record RTM code generation state.
 713     method()->ensure_method_data();
 714   }
 715 
 716   Init(::AliasLevel);
 717 
 718 
 719   print_compile_messages();
 720 
 721   _ilt = InlineTree::build_inline_tree_root();
 722 
 723   // Even if NO memory addresses are used, MergeMem nodes must have at least 1 slice
 724   assert(num_alias_types() >= AliasIdxRaw, "");
 725 
 726 #define MINIMUM_NODE_HASH  1023


 820     }
 821   }
 822 
 823   // Note:  Large methods are capped off in do_one_bytecode().
 824   if (failing())  return;
 825 
 826   // After parsing, node notes are no longer automagic.
 827   // They must be propagated by register_new_node_with_optimizer(),
 828   // clone(), or the like.
 829   set_default_node_notes(NULL);
 830 
 831   for (;;) {
 832     int successes = Inline_Warm();
 833     if (failing())  return;
 834     if (successes == 0)  break;
 835   }
 836 
 837   // Drain the list.
 838   Finish_Warm();
 839 #ifndef PRODUCT
 840   if (_printer && _printer->should_print(_method)) {
 841     _printer->print_inlining(this);
 842   }
 843 #endif
 844 
 845   if (failing())  return;
 846   NOT_PRODUCT( verify_graph_edges(); )
 847 
 848   // Now optimize
 849   Optimize();
 850   if (failing())  return;
 851   NOT_PRODUCT( verify_graph_edges(); )
 852 
 853 #ifndef PRODUCT
 854   if (PrintIdeal) {
 855     ttyLocker ttyl;  // keep the following output all in one block
 856     // This output goes directly to the tty, not the compiler log.
 857     // To enable tools to match it up with the compilation activity,
 858     // be sure to tag this tty output with the compile ID.
 859     if (xtty != NULL) {
 860       xtty->head("ideal compile_id='%d'%s", compile_id(),
 861                  is_osr_compilation()    ? " compile_kind='osr'" :
 862                  "");
 863     }
 864     root()->dump(9999);
 865     if (xtty != NULL) {
 866       xtty->tail("ideal");
 867     }
 868   }
 869 #endif
 870 
 871   NOT_PRODUCT( verify_barriers(); )
 872 
 873   // Dump compilation data to replay it.
 874   if (method()->has_option("DumpReplay")) {
 875     env()->dump_replay_data(_compile_id);
 876   }
 877   if (method()->has_option("DumpInline") && (ilt() != NULL)) {
 878     env()->dump_inline_data(_compile_id);
 879   }
 880 
 881   // Now that we know the size of all the monitors we can add a fixed slot
 882   // for the original deopt pc.
 883 
 884   _orig_pc_slot =  fixed_slots();
 885   int next_slot = _orig_pc_slot + (sizeof(address) / VMRegImpl::stack_slot_size);
 886   set_fixed_slots(next_slot);
 887 
 888   // Compute when to use implicit null checks. Used by matching trap based
 889   // nodes and NullCheck optimization.
 890   set_allowed_deopt_reasons();
 891 
 892   // Now generate code
 893   Code_Gen();
 894   if (failing())  return;
 895 
 896   // Check if we want to skip execution of all compiled code.
 897   {


1073   set_cached_top_node( new ConNode(Type::TOP) );
1074   set_recent_alloc(NULL, NULL);
1075 
1076   // Create Debug Information Recorder to record scopes, oopmaps, etc.
1077   env()->set_oop_recorder(new OopRecorder(env()->arena()));
1078   env()->set_debug_info(new DebugInformationRecorder(env()->oop_recorder()));
1079   env()->set_dependencies(new Dependencies(env()));
1080 
1081   _fixed_slots = 0;
1082   set_has_split_ifs(false);
1083   set_has_loops(has_method() && method()->has_loops()); // first approximation
1084   set_has_stringbuilder(false);
1085   set_has_boxed_value(false);
1086   _trap_can_recompile = false;  // no traps emitted yet
1087   _major_progress = true; // start out assuming good things will happen
1088   set_has_unsafe_access(false);
1089   set_max_vector_size(0);
1090   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
1091   set_decompile_count(0);
1092 
1093   set_do_freq_based_layout(BlockLayoutByFrequency || method_has_option("BlockLayoutByFrequency"));
1094   set_num_loop_opts(LoopOptsCount);
1095   set_do_inlining(Inline);
1096   set_max_inline_size(MaxInlineSize);
1097   set_freq_inline_size(FreqInlineSize);
1098   set_do_scheduling(OptoScheduling);
1099   set_do_count_invocations(false);
1100   set_do_method_data_update(false);
1101 
1102   set_do_vector_loop(false);
1103 
1104   bool do_vector = false;
1105   if (AllowVectorizeOnDemand) {
1106     if (has_method() && (method()->has_option("Vectorize") || method()->has_option("VectorizeDebug"))) {
1107       set_do_vector_loop(true);
1108     } else if (has_method() && method()->name() != 0 &&
1109                method()->intrinsic_id() == vmIntrinsics::_forEachRemaining) {
1110       set_do_vector_loop(true);
1111     }
1112 #ifndef PRODUCT
1113     if (do_vector_loop() && Verbose) {
1114       tty->print("Compile::Init: do vectorized loops (SIMD like) for method %s\n",  method()->name()->as_quoted_ascii());
1115     }
1116 #endif
1117   }
1118 
1119   set_age_code(has_method() && method()->profile_aging());
1120   set_rtm_state(NoRTM); // No RTM lock eliding by default
1121   method_has_option_value("MaxNodeLimit", _max_node_limit);

1122 #if INCLUDE_RTM_OPT
1123   if (UseRTMLocking && has_method() && (method()->method_data_or_null() != NULL)) {
1124     int rtm_state = method()->method_data()->rtm_state();
1125     if (method_has_option("NoRTMLockEliding") || ((rtm_state & NoRTM) != 0)) {
1126       // Don't generate RTM lock eliding code.
1127       set_rtm_state(NoRTM);
1128     } else if (method_has_option("UseRTMLockEliding") || ((rtm_state & UseRTM) != 0) || !UseRTMDeopt) {
1129       // Generate RTM lock eliding code without abort ratio calculation code.
1130       set_rtm_state(UseRTM);
1131     } else if (UseRTMDeopt) {
1132       // Generate RTM lock eliding code and include abort ratio calculation
1133       // code if UseRTMDeopt is on.
1134       set_rtm_state(ProfileRTM);
1135     }
1136   }
1137 #endif
1138   if (debug_info()->recording_non_safepoints()) {
1139     set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1140                         (comp_arena(), 8, 0, NULL));
1141     set_default_node_notes(Node_Notes::make(this));


2074       PhaseRemoveUseless pru(initial_gvn(), for_igvn());
2075     }
2076 
2077     {
2078       TracePhase tp("incrementalInline_igvn", &timers[_t_incrInline_igvn]);
2079       igvn = PhaseIterGVN(gvn);
2080       igvn.optimize();
2081     }
2082   }
2083 
2084   set_inlining_incrementally(false);
2085 }
2086 
2087 
2088 //------------------------------Optimize---------------------------------------
2089 // Given a graph, optimize it.
2090 void Compile::Optimize() {
2091   TracePhase tp("optimizer", &timers[_t_optimizer]);
2092 
2093 #ifndef PRODUCT
2094   if (env()->break_at_compile()) {
2095     BREAKPOINT;
2096   }
2097 
2098 #endif
2099 
2100   ResourceMark rm;
2101   int          loop_opts_cnt;
2102 
2103   print_inlining_reinit();
2104 
2105   NOT_PRODUCT( verify_graph_edges(); )
2106 
2107   print_method(PHASE_AFTER_PARSING);
2108 
2109  {
2110   // Iterative Global Value Numbering, including ideal transforms
2111   // Initialize IterGVN with types and values from parse-time GVN
2112   PhaseIterGVN igvn(initial_gvn());
2113 #ifdef ASSERT
2114   _modified_nodes = new (comp_arena()) Unique_Node_List(comp_arena());


4338 // from uniformly. In this case, we need to adjust the randomicity of the
4339 // selection, or else we will end up biasing the selection towards the latter
4340 // candidates.
4341 //
4342 // Quick back-envelope calculation shows that for the list of n candidates
4343 // the equal probability for the candidate to persist as "best" can be
4344 // achieved by replacing it with "next" k-th candidate with the probability
4345 // of 1/k. It can be easily shown that by the end of the run, the
4346 // probability for any candidate is converged to 1/n, thus giving the
4347 // uniform distribution among all the candidates.
4348 //
4349 // We don't care about the domain size as long as (RANDOMIZED_DOMAIN / count) is large.
4350 #define RANDOMIZED_DOMAIN_POW 29
4351 #define RANDOMIZED_DOMAIN (1 << RANDOMIZED_DOMAIN_POW)
4352 #define RANDOMIZED_DOMAIN_MASK ((1 << (RANDOMIZED_DOMAIN_POW + 1)) - 1)
4353 bool Compile::randomized_select(int count) {
4354   assert(count > 0, "only positive");
4355   return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
4356 }
4357 
4358 const char*   CloneMap::debug_option_name = "CloneMapDebug";
4359 CloneMap&     Compile::clone_map()                 { return _clone_map; }
4360 void          Compile::set_clone_map(Dict* d)      { _clone_map._dict = d; }
4361 
4362 void NodeCloneInfo::dump() const {
4363   tty->print(" {%d:%d} ", idx(), gen());
4364 }
4365 
4366 void CloneMap::clone(Node* old, Node* nnn, int gen) {
4367   uint64_t val = value(old->_idx);
4368   NodeCloneInfo cio(val);
4369   assert(val != 0, "old node should be in the map");
4370   NodeCloneInfo cin(cio.idx(), gen + cio.gen());
4371   insert(nnn->_idx, cin.get());
4372 #ifndef PRODUCT
4373   if (is_debug()) {
4374     tty->print_cr("CloneMap::clone inserted node %d info {%d:%d} into CloneMap", nnn->_idx, cin.idx(), cin.gen());
4375   }
4376 #endif
4377 }
4378 




 447 CompileWrapper::CompileWrapper(Compile* compile) : _compile(compile) {
 448   // the Compile* pointer is stored in the current ciEnv:
 449   ciEnv* env = compile->env();
 450   assert(env == ciEnv::current(), "must already be a ciEnv active");
 451   assert(env->compiler_data() == NULL, "compile already active?");
 452   env->set_compiler_data(compile);
 453   assert(compile == Compile::current(), "sanity");
 454 
 455   compile->set_type_dict(NULL);
 456   compile->set_clone_map(new Dict(cmpkey, hashkey, _compile->comp_arena()));
 457   compile->clone_map().set_clone_idx(0);
 458   compile->set_type_hwm(NULL);
 459   compile->set_type_last_size(0);
 460   compile->set_last_tf(NULL, NULL);
 461   compile->set_indexSet_arena(NULL);
 462   compile->set_indexSet_free_block_list(NULL);
 463   compile->init_type_arena();
 464   Type::Initialize(compile);
 465   _compile->set_scratch_buffer_blob(NULL);
 466   _compile->begin_method();
 467   _compile->clone_map().set_debug(_compile->has_method() && _compile->env()->dirset()->CloneMapDebugOption);
 468 }
 469 CompileWrapper::~CompileWrapper() {
 470   _compile->end_method();
 471   if (_compile->scratch_buffer_blob() != NULL)
 472     BufferBlob::free(_compile->scratch_buffer_blob());
 473   _compile->env()->set_compiler_data(NULL);
 474 }
 475 
 476 
 477 //----------------------------print_compile_messages---------------------------
 478 void Compile::print_compile_messages() {
 479 #ifndef PRODUCT
 480   // Check if recompiling
 481   if (_subsume_loads == false && PrintOpto) {
 482     // Recompiling without allowing machine instructions to subsume loads
 483     tty->print_cr("*********************************************************");
 484     tty->print_cr("** Bailout: Recompile without subsuming loads          **");
 485     tty->print_cr("*********************************************************");
 486   }
 487   if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) {
 488     // Recompiling without escape analysis
 489     tty->print_cr("*********************************************************");
 490     tty->print_cr("** Bailout: Recompile without escape analysis          **");
 491     tty->print_cr("*********************************************************");
 492   }
 493   if (_eliminate_boxing != EliminateAutoBox && PrintOpto) {
 494     // Recompiling without boxing elimination
 495     tty->print_cr("*********************************************************");
 496     tty->print_cr("** Bailout: Recompile without boxing elimination       **");
 497     tty->print_cr("*********************************************************");
 498   }
 499   if (env()->dirset()->BreakAtCompileOption) {
 500     // Open the debugger when compiling this method.
 501     tty->print("### Breaking when compiling: ");
 502     method()->print_short_name();
 503     tty->cr();
 504     BREAKPOINT;
 505   }
 506 
 507   if( PrintOpto ) {
 508     if (is_osr_compilation()) {
 509       tty->print("[OSR]%3d", _compile_id);
 510     } else {
 511       tty->print("%3d", _compile_id);
 512     }
 513   }
 514 #endif
 515 }
 516 
 517 
 518 //-----------------------init_scratch_buffer_blob------------------------------
 519 // Construct a temporary BufferBlob and cache it for this compile.


 632                   _for_igvn(NULL),
 633                   _warm_calls(NULL),
 634                   _subsume_loads(subsume_loads),
 635                   _do_escape_analysis(do_escape_analysis),
 636                   _eliminate_boxing(eliminate_boxing),
 637                   _failure_reason(NULL),
 638                   _code_buffer("Compile::Fill_buffer"),
 639                   _orig_pc_slot(0),
 640                   _orig_pc_slot_offset_in_bytes(0),
 641                   _has_method_handle_invokes(false),
 642                   _mach_constant_base_node(NULL),
 643                   _node_bundling_limit(0),
 644                   _node_bundling_base(NULL),
 645                   _java_calls(0),
 646                   _inner_loops(0),
 647                   _scratch_const_size(-1),
 648                   _in_scratch_emit_size(false),
 649                   _dead_node_list(comp_arena()),
 650                   _dead_node_count(0),
 651 #ifndef PRODUCT
 652                   _trace_opto_output(ci_env->dirset()->TraceOptoOutputOption),
 653                   _in_dump_cnt(0),
 654                   _printer(IdealGraphPrinter::printer()),
 655 #endif
 656                   _congraph(NULL),
 657                   _comp_arena(mtCompiler),
 658                   _node_arena(mtCompiler),
 659                   _old_arena(mtCompiler),
 660                   _Compile_types(mtCompiler),
 661                   _replay_inline_data(NULL),
 662                   _late_inlines(comp_arena(), 2, 0, NULL),
 663                   _string_late_inlines(comp_arena(), 2, 0, NULL),
 664                   _boxing_late_inlines(comp_arena(), 2, 0, NULL),
 665                   _late_inlines_pos(0),
 666                   _number_of_mh_late_inlines(0),
 667                   _inlining_progress(false),
 668                   _inlining_incrementally(false),
 669                   _print_inlining_list(NULL),
 670                   _print_inlining_stream(NULL),
 671                   _print_inlining_idx(0),
 672                   _print_inlining_output(NULL),
 673                   _interpreter_frame_size(0),
 674                   _max_node_limit(MaxNodeLimit) {
 675   C = this;
 676 
 677   CompileWrapper cw(this);
 678 
 679   if (CITimeVerbose) {
 680     tty->print(" ");
 681     target->holder()->name()->print();
 682     tty->print(".");
 683     target->print_short_name();
 684     tty->print("  ");
 685   }
 686   TraceTime t1("Total compilation time", &_t_totalCompilation, CITime, CITimeVerbose);
 687   TraceTime t2(NULL, &_t_methodCompilation, CITime, false);
 688 
 689 #ifndef PRODUCT
 690   bool print_opto_assembly = env()->dirset()->PrintOptoAssemblyOption;
 691   if (!print_opto_assembly) {
 692     bool print_assembly = env()->dirset()->PrintAssemblyOption;
 693     if (print_assembly && !Disassembler::can_decode()) {
 694       tty->print_cr("PrintAssembly request changed to PrintOptoAssembly");
 695       print_opto_assembly = true;
 696     }
 697   }
 698   set_print_assembly(print_opto_assembly);
 699   set_parsed_irreducible_loop(false);
 700 
 701   if (env()->dirset()->ReplayInlineOption) {
 702     _replay_inline_data = ciReplay::load_inline_data(method(), entry_bci(), ci_env->comp_level());
 703   }
 704 #endif
 705   set_print_inlining(env()->dirset()->PrintInliningOption NOT_PRODUCT( || PrintOptoInlining));
 706   set_print_intrinsics(env()->dirset()->PrintIntrinsicsOption);
 707   set_has_irreducible_loop(true); // conservative until build_loop_tree() reset it
 708 
 709   if (ProfileTraps RTM_OPT_ONLY( || UseRTMLocking )) {
 710     // Make sure the method being compiled gets its own MDO,
 711     // so we can at least track the decompile_count().
 712     // Need MDO to record RTM code generation state.
 713     method()->ensure_method_data();
 714   }
 715 
 716   Init(::AliasLevel);
 717 
 718 
 719   print_compile_messages();
 720 
 721   _ilt = InlineTree::build_inline_tree_root();
 722 
 723   // Even if NO memory addresses are used, MergeMem nodes must have at least 1 slice
 724   assert(num_alias_types() >= AliasIdxRaw, "");
 725 
 726 #define MINIMUM_NODE_HASH  1023


 820     }
 821   }
 822 
 823   // Note:  Large methods are capped off in do_one_bytecode().
 824   if (failing())  return;
 825 
 826   // After parsing, node notes are no longer automagic.
 827   // They must be propagated by register_new_node_with_optimizer(),
 828   // clone(), or the like.
 829   set_default_node_notes(NULL);
 830 
 831   for (;;) {
 832     int successes = Inline_Warm();
 833     if (failing())  return;
 834     if (successes == 0)  break;
 835   }
 836 
 837   // Drain the list.
 838   Finish_Warm();
 839 #ifndef PRODUCT
 840   if (_printer && _printer->should_print(1)) {
 841     _printer->print_inlining(this);
 842   }
 843 #endif
 844 
 845   if (failing())  return;
 846   NOT_PRODUCT( verify_graph_edges(); )
 847 
 848   // Now optimize
 849   Optimize();
 850   if (failing())  return;
 851   NOT_PRODUCT( verify_graph_edges(); )
 852 
 853 #ifndef PRODUCT
 854   if (PrintIdeal) {
 855     ttyLocker ttyl;  // keep the following output all in one block
 856     // This output goes directly to the tty, not the compiler log.
 857     // To enable tools to match it up with the compilation activity,
 858     // be sure to tag this tty output with the compile ID.
 859     if (xtty != NULL) {
 860       xtty->head("ideal compile_id='%d'%s", compile_id(),
 861                  is_osr_compilation()    ? " compile_kind='osr'" :
 862                  "");
 863     }
 864     root()->dump(9999);
 865     if (xtty != NULL) {
 866       xtty->tail("ideal");
 867     }
 868   }
 869 #endif
 870 
 871   NOT_PRODUCT( verify_barriers(); )
 872 
 873   // Dump compilation data to replay it.
 874   if (env()->dirset()->DumpReplayOption) {
 875     env()->dump_replay_data(_compile_id);
 876   }
 877   if (env()->dirset()->DumpInlineOption && (ilt() != NULL)) {
 878     env()->dump_inline_data(_compile_id);
 879   }
 880 
 881   // Now that we know the size of all the monitors we can add a fixed slot
 882   // for the original deopt pc.
 883 
 884   _orig_pc_slot =  fixed_slots();
 885   int next_slot = _orig_pc_slot + (sizeof(address) / VMRegImpl::stack_slot_size);
 886   set_fixed_slots(next_slot);
 887 
 888   // Compute when to use implicit null checks. Used by matching trap based
 889   // nodes and NullCheck optimization.
 890   set_allowed_deopt_reasons();
 891 
 892   // Now generate code
 893   Code_Gen();
 894   if (failing())  return;
 895 
 896   // Check if we want to skip execution of all compiled code.
 897   {


1073   set_cached_top_node( new ConNode(Type::TOP) );
1074   set_recent_alloc(NULL, NULL);
1075 
1076   // Create Debug Information Recorder to record scopes, oopmaps, etc.
1077   env()->set_oop_recorder(new OopRecorder(env()->arena()));
1078   env()->set_debug_info(new DebugInformationRecorder(env()->oop_recorder()));
1079   env()->set_dependencies(new Dependencies(env()));
1080 
1081   _fixed_slots = 0;
1082   set_has_split_ifs(false);
1083   set_has_loops(has_method() && method()->has_loops()); // first approximation
1084   set_has_stringbuilder(false);
1085   set_has_boxed_value(false);
1086   _trap_can_recompile = false;  // no traps emitted yet
1087   _major_progress = true; // start out assuming good things will happen
1088   set_has_unsafe_access(false);
1089   set_max_vector_size(0);
1090   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
1091   set_decompile_count(0);
1092 
1093   set_do_freq_based_layout(env()->dirset()->BlockLayoutByFrequencyOption);
1094   set_num_loop_opts(LoopOptsCount);
1095   set_do_inlining(Inline);
1096   set_max_inline_size(MaxInlineSize);
1097   set_freq_inline_size(FreqInlineSize);
1098   set_do_scheduling(OptoScheduling);
1099   set_do_count_invocations(false);
1100   set_do_method_data_update(false);
1101 
1102   set_do_vector_loop(false);
1103 
1104   bool do_vector = false;
1105   if (AllowVectorizeOnDemand) {
1106     if (has_method() && (env()->dirset()->VectorizeOption || env()->dirset()->VectorizeDebugOption)) {
1107       set_do_vector_loop(true);
1108     } else if (has_method() && method()->name() != 0 &&
1109                method()->intrinsic_id() == vmIntrinsics::_forEachRemaining) {
1110       set_do_vector_loop(true);
1111     }
1112 #ifndef PRODUCT
1113     if (do_vector_loop() && Verbose) {
1114       tty->print("Compile::Init: do vectorized loops (SIMD like) for method %s\n",  method()->name()->as_quoted_ascii());
1115     }
1116 #endif
1117   }
1118 
1119   set_age_code(has_method() && method()->profile_aging());
1120   set_rtm_state(NoRTM); // No RTM lock eliding by default
1121   _max_node_limit = env()->dirset()->MaxNodeLimitOption;
1122 
1123 #if INCLUDE_RTM_OPT
1124   if (UseRTMLocking && has_method() && (method()->method_data_or_null() != NULL)) {
1125     int rtm_state = method()->method_data()->rtm_state();
1126     if (method_has_option("NoRTMLockEliding") || ((rtm_state & NoRTM) != 0)) {
1127       // Don't generate RTM lock eliding code.
1128       set_rtm_state(NoRTM);
1129     } else if (method_has_option("UseRTMLockEliding") || ((rtm_state & UseRTM) != 0) || !UseRTMDeopt) {
1130       // Generate RTM lock eliding code without abort ratio calculation code.
1131       set_rtm_state(UseRTM);
1132     } else if (UseRTMDeopt) {
1133       // Generate RTM lock eliding code and include abort ratio calculation
1134       // code if UseRTMDeopt is on.
1135       set_rtm_state(ProfileRTM);
1136     }
1137   }
1138 #endif
1139   if (debug_info()->recording_non_safepoints()) {
1140     set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1141                         (comp_arena(), 8, 0, NULL));
1142     set_default_node_notes(Node_Notes::make(this));


2075       PhaseRemoveUseless pru(initial_gvn(), for_igvn());
2076     }
2077 
2078     {
2079       TracePhase tp("incrementalInline_igvn", &timers[_t_incrInline_igvn]);
2080       igvn = PhaseIterGVN(gvn);
2081       igvn.optimize();
2082     }
2083   }
2084 
2085   set_inlining_incrementally(false);
2086 }
2087 
2088 
2089 //------------------------------Optimize---------------------------------------
2090 // Given a graph, optimize it.
2091 void Compile::Optimize() {
2092   TracePhase tp("optimizer", &timers[_t_optimizer]);
2093 
2094 #ifndef PRODUCT
2095   if (env()->dirset()->BreakAtCompileOption) {
2096     BREAKPOINT;
2097   }
2098 
2099 #endif
2100 
2101   ResourceMark rm;
2102   int          loop_opts_cnt;
2103 
2104   print_inlining_reinit();
2105 
2106   NOT_PRODUCT( verify_graph_edges(); )
2107 
2108   print_method(PHASE_AFTER_PARSING);
2109 
2110  {
2111   // Iterative Global Value Numbering, including ideal transforms
2112   // Initialize IterGVN with types and values from parse-time GVN
2113   PhaseIterGVN igvn(initial_gvn());
2114 #ifdef ASSERT
2115   _modified_nodes = new (comp_arena()) Unique_Node_List(comp_arena());


4339 // from uniformly. In this case, we need to adjust the randomicity of the
4340 // selection, or else we will end up biasing the selection towards the latter
4341 // candidates.
4342 //
4343 // Quick back-envelope calculation shows that for the list of n candidates
4344 // the equal probability for the candidate to persist as "best" can be
4345 // achieved by replacing it with "next" k-th candidate with the probability
4346 // of 1/k. It can be easily shown that by the end of the run, the
4347 // probability for any candidate is converged to 1/n, thus giving the
4348 // uniform distribution among all the candidates.
4349 //
4350 // We don't care about the domain size as long as (RANDOMIZED_DOMAIN / count) is large.
4351 #define RANDOMIZED_DOMAIN_POW 29
4352 #define RANDOMIZED_DOMAIN (1 << RANDOMIZED_DOMAIN_POW)
4353 #define RANDOMIZED_DOMAIN_MASK ((1 << (RANDOMIZED_DOMAIN_POW + 1)) - 1)
4354 bool Compile::randomized_select(int count) {
4355   assert(count > 0, "only positive");
4356   return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
4357 }
4358 

4359 CloneMap&     Compile::clone_map()                 { return _clone_map; }
4360 void          Compile::set_clone_map(Dict* d)      { _clone_map._dict = d; }
4361 
4362 void NodeCloneInfo::dump() const {
4363   tty->print(" {%d:%d} ", idx(), gen());
4364 }
4365 
4366 void CloneMap::clone(Node* old, Node* nnn, int gen) {
4367   uint64_t val = value(old->_idx);
4368   NodeCloneInfo cio(val);
4369   assert(val != 0, "old node should be in the map");
4370   NodeCloneInfo cin(cio.idx(), gen + cio.gen());
4371   insert(nnn->_idx, cin.get());
4372 #ifndef PRODUCT
4373   if (is_debug()) {
4374     tty->print_cr("CloneMap::clone inserted node %d info {%d:%d} into CloneMap", nnn->_idx, cin.idx(), cin.gen());
4375   }
4376 #endif
4377 }
4378 


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