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

src/share/vm/opto/compile.cpp

Print this page




 401     if (n->outcnt() == 1 && n->has_special_unique_user()) {
 402       record_for_igvn(n->unique_out());
 403     }
 404   }
 405   // Remove useless macro and predicate opaq nodes
 406   for (int i = C->macro_count()-1; i >= 0; i--) {
 407     Node* n = C->macro_node(i);
 408     if (!useful.member(n)) {
 409       remove_macro_node(n);
 410     }
 411   }
 412   // Remove useless expensive node
 413   for (int i = C->expensive_count()-1; i >= 0; i--) {
 414     Node* n = C->expensive_node(i);
 415     if (!useful.member(n)) {
 416       remove_expensive_node(n);
 417     }
 418   }
 419   // clean up the late inline lists
 420   remove_useless_late_inlines(&_string_late_inlines, useful);

 421   remove_useless_late_inlines(&_late_inlines, useful);
 422   debug_only(verify_graph_edges(true/*check for no_dead_code*/);)
 423 }
 424 
 425 //------------------------------frame_size_in_words-----------------------------
 426 // frame_slots in units of words
 427 int Compile::frame_size_in_words() const {
 428   // shift is 0 in LP32 and 1 in LP64
 429   const int shift = (LogBytesPerWord - LogBytesPerInt);
 430   int words = _frame_slots >> shift;
 431   assert( words << shift == _frame_slots, "frame size must be properly aligned in LP64" );
 432   return words;
 433 }
 434 
 435 // ============================================================================
 436 //------------------------------CompileWrapper---------------------------------
 437 class CompileWrapper : public StackObj {
 438   Compile *const _compile;
 439  public:
 440   CompileWrapper(Compile* compile);


 468   _compile->env()->set_compiler_data(NULL);
 469 }
 470 
 471 
 472 //----------------------------print_compile_messages---------------------------
 473 void Compile::print_compile_messages() {
 474 #ifndef PRODUCT
 475   // Check if recompiling
 476   if (_subsume_loads == false && PrintOpto) {
 477     // Recompiling without allowing machine instructions to subsume loads
 478     tty->print_cr("*********************************************************");
 479     tty->print_cr("** Bailout: Recompile without subsuming loads          **");
 480     tty->print_cr("*********************************************************");
 481   }
 482   if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) {
 483     // Recompiling without escape analysis
 484     tty->print_cr("*********************************************************");
 485     tty->print_cr("** Bailout: Recompile without escape analysis          **");
 486     tty->print_cr("*********************************************************");
 487   }






 488   if (env()->break_at_compile()) {
 489     // Open the debugger when compiling this method.
 490     tty->print("### Breaking when compiling: ");
 491     method()->print_short_name();
 492     tty->cr();
 493     BREAKPOINT;
 494   }
 495 
 496   if( PrintOpto ) {
 497     if (is_osr_compilation()) {
 498       tty->print("[OSR]%3d", _compile_id);
 499     } else {
 500       tty->print("%3d", _compile_id);
 501     }
 502   }
 503 #endif
 504 }
 505 
 506 
 507 //-----------------------init_scratch_buffer_blob------------------------------


 584   }
 585   n->emit(buf, this->regalloc());
 586   if (is_branch) // Restore label.
 587     n->as_MachBranch()->label_set(saveL, save_bnum);
 588 
 589   // End scratch_emit_size section.
 590   set_in_scratch_emit_size(false);
 591 
 592   return buf.insts_size();
 593 }
 594 
 595 
 596 // ============================================================================
 597 //------------------------------Compile standard-------------------------------
 598 debug_only( int Compile::_debug_idx = 100000; )
 599 
 600 // Compile a method.  entry_bci is -1 for normal compilations and indicates
 601 // the continuation bci for on stack replacement.
 602 
 603 
 604 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci, bool subsume_loads, bool do_escape_analysis )

 605                 : Phase(Compiler),
 606                   _env(ci_env),
 607                   _log(ci_env->log()),
 608                   _compile_id(ci_env->compile_id()),
 609                   _save_argument_registers(false),
 610                   _stub_name(NULL),
 611                   _stub_function(NULL),
 612                   _stub_entry_point(NULL),
 613                   _method(target),
 614                   _entry_bci(osr_bci),
 615                   _initial_gvn(NULL),
 616                   _for_igvn(NULL),
 617                   _warm_calls(NULL),
 618                   _subsume_loads(subsume_loads),
 619                   _do_escape_analysis(do_escape_analysis),

 620                   _failure_reason(NULL),
 621                   _code_buffer("Compile::Fill_buffer"),
 622                   _orig_pc_slot(0),
 623                   _orig_pc_slot_offset_in_bytes(0),
 624                   _has_method_handle_invokes(false),
 625                   _mach_constant_base_node(NULL),
 626                   _node_bundling_limit(0),
 627                   _node_bundling_base(NULL),
 628                   _java_calls(0),
 629                   _inner_loops(0),
 630                   _scratch_const_size(-1),
 631                   _in_scratch_emit_size(false),
 632                   _dead_node_list(comp_arena()),
 633                   _dead_node_count(0),
 634 #ifndef PRODUCT
 635                   _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
 636                   _printer(IdealGraphPrinter::printer()),
 637 #endif
 638                   _congraph(NULL),
 639                   _late_inlines(comp_arena(), 2, 0, NULL),
 640                   _string_late_inlines(comp_arena(), 2, 0, NULL),

 641                   _late_inlines_pos(0),
 642                   _number_of_mh_late_inlines(0),
 643                   _inlining_progress(false),
 644                   _inlining_incrementally(false),
 645                   _print_inlining_list(NULL),
 646                   _print_inlining(0) {
 647   C = this;
 648 
 649   CompileWrapper cw(this);
 650 #ifndef PRODUCT
 651   if (TimeCompiler2) {
 652     tty->print(" ");
 653     target->holder()->name()->print();
 654     tty->print(".");
 655     target->print_short_name();
 656     tty->print("  ");
 657   }
 658   TraceTime t1("Total compilation time", &_t_totalCompilation, TimeCompiler, TimeCompiler2);
 659   TraceTime t2(NULL, &_t_methodCompilation, TimeCompiler, false);
 660   bool print_opto_assembly = PrintOptoAssembly || _method->has_option("PrintOptoAssembly");


 889                   bool pass_tls,
 890                   bool save_arg_registers,
 891                   bool return_pc )
 892   : Phase(Compiler),
 893     _env(ci_env),
 894     _log(ci_env->log()),
 895     _compile_id(0),
 896     _save_argument_registers(save_arg_registers),
 897     _method(NULL),
 898     _stub_name(stub_name),
 899     _stub_function(stub_function),
 900     _stub_entry_point(NULL),
 901     _entry_bci(InvocationEntryBci),
 902     _initial_gvn(NULL),
 903     _for_igvn(NULL),
 904     _warm_calls(NULL),
 905     _orig_pc_slot(0),
 906     _orig_pc_slot_offset_in_bytes(0),
 907     _subsume_loads(true),
 908     _do_escape_analysis(false),

 909     _failure_reason(NULL),
 910     _code_buffer("Compile::Fill_buffer"),
 911     _has_method_handle_invokes(false),
 912     _mach_constant_base_node(NULL),
 913     _node_bundling_limit(0),
 914     _node_bundling_base(NULL),
 915     _java_calls(0),
 916     _inner_loops(0),
 917 #ifndef PRODUCT
 918     _trace_opto_output(TraceOptoOutput),
 919     _printer(NULL),
 920 #endif
 921     _dead_node_list(comp_arena()),
 922     _dead_node_count(0),
 923     _congraph(NULL),
 924     _number_of_mh_late_inlines(0),
 925     _inlining_progress(false),
 926     _inlining_incrementally(false),
 927     _print_inlining_list(NULL),
 928     _print_inlining(0) {


 999 
1000   _immutable_memory = NULL; // filled in at first inquiry
1001 
1002   // Globally visible Nodes
1003   // First set TOP to NULL to give safe behavior during creation of RootNode
1004   set_cached_top_node(NULL);
1005   set_root(new (this) RootNode());
1006   // Now that you have a Root to point to, create the real TOP
1007   set_cached_top_node( new (this) ConNode(Type::TOP) );
1008   set_recent_alloc(NULL, NULL);
1009 
1010   // Create Debug Information Recorder to record scopes, oopmaps, etc.
1011   env()->set_oop_recorder(new OopRecorder(env()->arena()));
1012   env()->set_debug_info(new DebugInformationRecorder(env()->oop_recorder()));
1013   env()->set_dependencies(new Dependencies(env()));
1014 
1015   _fixed_slots = 0;
1016   set_has_split_ifs(false);
1017   set_has_loops(has_method() && method()->has_loops()); // first approximation
1018   set_has_stringbuilder(false);

1019   _trap_can_recompile = false;  // no traps emitted yet
1020   _major_progress = true; // start out assuming good things will happen
1021   set_has_unsafe_access(false);
1022   set_max_vector_size(0);
1023   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
1024   set_decompile_count(0);
1025 
1026   set_do_freq_based_layout(BlockLayoutByFrequency || method_has_option("BlockLayoutByFrequency"));
1027   set_num_loop_opts(LoopOptsCount);
1028   set_do_inlining(Inline);
1029   set_max_inline_size(MaxInlineSize);
1030   set_freq_inline_size(FreqInlineSize);
1031   set_do_scheduling(OptoScheduling);
1032   set_do_count_invocations(false);
1033   set_do_method_data_update(false);
1034 
1035   if (debug_info()->recording_non_safepoints()) {
1036     set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1037                         (comp_arena(), 8, 0, NULL));
1038     set_default_node_notes(Node_Notes::make(this));


1790   {
1791     ResourceMark rm;
1792     print_method("Before StringOpts", 3);
1793     PhaseStringOpts pso(initial_gvn(), for_igvn());
1794     print_method("After StringOpts", 3);
1795   }
1796 
1797   // now inline anything that we skipped the first time around
1798   if (!parse_time) {
1799     _late_inlines_pos = _late_inlines.length();
1800   }
1801 
1802   while (_string_late_inlines.length() > 0) {
1803     CallGenerator* cg = _string_late_inlines.pop();
1804     cg->do_late_inline();
1805     if (failing())  return;
1806   }
1807   _string_late_inlines.trunc_to(0);
1808 }
1809 
































1810 void Compile::inline_incrementally_one(PhaseIterGVN& igvn) {
1811   assert(IncrementalInline, "incremental inlining should be on");
1812   PhaseGVN* gvn = initial_gvn();
1813 
1814   set_inlining_progress(false);
1815   for_igvn()->clear();
1816   gvn->replace_with(&igvn);
1817 
1818   int i = 0;
1819 
1820   for (; i <_late_inlines.length() && !inlining_progress(); i++) {
1821     CallGenerator* cg = _late_inlines.at(i);
1822     _late_inlines_pos = i+1;
1823     cg->do_late_inline();
1824     if (failing())  return;
1825   }
1826   int j = 0;
1827   for (; i < _late_inlines.length(); i++, j++) {
1828     _late_inlines.at_put(j, _late_inlines.at(i));
1829   }
1830   _late_inlines.trunc_to(j);
1831 
1832   {
1833     ResourceMark rm;
1834     PhaseRemoveUseless pru(C->initial_gvn(), C->for_igvn());
1835   }
1836 
1837   igvn = PhaseIterGVN(gvn);
1838 }
1839 
1840 // Perform incremental inlining until bound on number of live nodes is reached
1841 void Compile::inline_incrementally(PhaseIterGVN& igvn) {
1842   PhaseGVN* gvn = initial_gvn();
1843 
1844   set_inlining_incrementally(true);
1845   set_inlining_progress(true);
1846   uint low_live_nodes = 0;
1847 
1848   while(inlining_progress() && _late_inlines.length() > 0) {
1849 
1850     if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
1851       if (low_live_nodes < (uint)LiveNodeCountInliningCutoff * 8 / 10) {
1852         // PhaseIdealLoop is expensive so we only try it once we are
1853         // out of loop and we only try it again if the previous helped
1854         // got the number of nodes down significantly


1912   ResourceMark rm;
1913   int          loop_opts_cnt;
1914 
1915   NOT_PRODUCT( verify_graph_edges(); )
1916 
1917   print_method("After Parsing");
1918 
1919  {
1920   // Iterative Global Value Numbering, including ideal transforms
1921   // Initialize IterGVN with types and values from parse-time GVN
1922   PhaseIterGVN igvn(initial_gvn());
1923   {
1924     NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); )
1925     igvn.optimize();
1926   }
1927 
1928   print_method("Iter GVN 1", 2);
1929 
1930   if (failing())  return;
1931 


1932   inline_incrementally(igvn);

1933 
1934   print_method("Incremental Inline", 2);
1935 
1936   if (failing())  return;
1937 










1938   // No more new expensive nodes will be added to the list from here
1939   // so keep only the actual candidates for optimizations.
1940   cleanup_expensive_nodes(igvn);
1941 
1942   // Perform escape analysis
1943   if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
1944     if (has_loops()) {
1945       // Cleanup graph (remove dead nodes).
1946       TracePhase t2("idealLoop", &_t_idealLoop, true);
1947       PhaseIdealLoop ideal_loop( igvn, false, true );
1948       if (major_progress()) print_method("PhaseIdealLoop before EA", 2);
1949       if (failing())  return;
1950     }
1951     ConnectionGraph::do_analysis(this, &igvn);
1952 
1953     if (failing())  return;
1954 
1955     // Optimize out fields loads from scalar replaceable allocations.
1956     igvn.optimize();
1957     print_method("Iter GVN after EA", 2);


2879       Node* in2 = n->in(2);
2880       juint mask = (n->bottom_type() == TypeInt::INT) ? (BitsPerInt - 1) : (BitsPerLong - 1);
2881       const TypeInt* t = in2->find_int_type();
2882       if (t != NULL && t->is_con()) {
2883         juint shift = t->get_con();
2884         if (shift > mask) { // Unsigned cmp
2885           n->set_req(2, ConNode::make(this, TypeInt::make(shift & mask)));
2886         }
2887       } else {
2888         if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) {
2889           Node* shift = new (this) AndINode(in2, ConNode::make(this, TypeInt::make(mask)));
2890           n->set_req(2, shift);
2891         }
2892       }
2893       if (in2->outcnt() == 0) { // Remove dead node
2894         in2->disconnect_inputs(NULL, this);
2895       }
2896     }
2897     break;
2898   case Op_MemBarStoreStore:

2899     // Break the link with AllocateNode: it is no longer useful and
2900     // confuses register allocation.
2901     if (n->req() > MemBarNode::Precedent) {
2902       n->set_req(MemBarNode::Precedent, top());
2903     }
2904     break;
2905   default:
2906     assert( !n->is_Call(), "" );
2907     assert( !n->is_Mem(), "" );
2908     break;
2909   }
2910 
2911   // Collect CFG split points
2912   if (n->is_MultiBranch())
2913     frc._tests.push(n);
2914 }
2915 
2916 //------------------------------final_graph_reshaping_walk---------------------
2917 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(),
2918 // requires that the walk visits a node's inputs before visiting the node.




 401     if (n->outcnt() == 1 && n->has_special_unique_user()) {
 402       record_for_igvn(n->unique_out());
 403     }
 404   }
 405   // Remove useless macro and predicate opaq nodes
 406   for (int i = C->macro_count()-1; i >= 0; i--) {
 407     Node* n = C->macro_node(i);
 408     if (!useful.member(n)) {
 409       remove_macro_node(n);
 410     }
 411   }
 412   // Remove useless expensive node
 413   for (int i = C->expensive_count()-1; i >= 0; i--) {
 414     Node* n = C->expensive_node(i);
 415     if (!useful.member(n)) {
 416       remove_expensive_node(n);
 417     }
 418   }
 419   // clean up the late inline lists
 420   remove_useless_late_inlines(&_string_late_inlines, useful);
 421   remove_useless_late_inlines(&_boxing_late_inlines, useful);
 422   remove_useless_late_inlines(&_late_inlines, useful);
 423   debug_only(verify_graph_edges(true/*check for no_dead_code*/);)
 424 }
 425 
 426 //------------------------------frame_size_in_words-----------------------------
 427 // frame_slots in units of words
 428 int Compile::frame_size_in_words() const {
 429   // shift is 0 in LP32 and 1 in LP64
 430   const int shift = (LogBytesPerWord - LogBytesPerInt);
 431   int words = _frame_slots >> shift;
 432   assert( words << shift == _frame_slots, "frame size must be properly aligned in LP64" );
 433   return words;
 434 }
 435 
 436 // ============================================================================
 437 //------------------------------CompileWrapper---------------------------------
 438 class CompileWrapper : public StackObj {
 439   Compile *const _compile;
 440  public:
 441   CompileWrapper(Compile* compile);


 469   _compile->env()->set_compiler_data(NULL);
 470 }
 471 
 472 
 473 //----------------------------print_compile_messages---------------------------
 474 void Compile::print_compile_messages() {
 475 #ifndef PRODUCT
 476   // Check if recompiling
 477   if (_subsume_loads == false && PrintOpto) {
 478     // Recompiling without allowing machine instructions to subsume loads
 479     tty->print_cr("*********************************************************");
 480     tty->print_cr("** Bailout: Recompile without subsuming loads          **");
 481     tty->print_cr("*********************************************************");
 482   }
 483   if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) {
 484     // Recompiling without escape analysis
 485     tty->print_cr("*********************************************************");
 486     tty->print_cr("** Bailout: Recompile without escape analysis          **");
 487     tty->print_cr("*********************************************************");
 488   }
 489   if (_eliminate_autobox != EliminateAutoBox && PrintOpto) {
 490     // Recompiling without boxing elimination
 491     tty->print_cr("*********************************************************");
 492     tty->print_cr("** Bailout: Recompile without boxing elimination       **");
 493     tty->print_cr("*********************************************************");
 494   }
 495   if (env()->break_at_compile()) {
 496     // Open the debugger when compiling this method.
 497     tty->print("### Breaking when compiling: ");
 498     method()->print_short_name();
 499     tty->cr();
 500     BREAKPOINT;
 501   }
 502 
 503   if( PrintOpto ) {
 504     if (is_osr_compilation()) {
 505       tty->print("[OSR]%3d", _compile_id);
 506     } else {
 507       tty->print("%3d", _compile_id);
 508     }
 509   }
 510 #endif
 511 }
 512 
 513 
 514 //-----------------------init_scratch_buffer_blob------------------------------


 591   }
 592   n->emit(buf, this->regalloc());
 593   if (is_branch) // Restore label.
 594     n->as_MachBranch()->label_set(saveL, save_bnum);
 595 
 596   // End scratch_emit_size section.
 597   set_in_scratch_emit_size(false);
 598 
 599   return buf.insts_size();
 600 }
 601 
 602 
 603 // ============================================================================
 604 //------------------------------Compile standard-------------------------------
 605 debug_only( int Compile::_debug_idx = 100000; )
 606 
 607 // Compile a method.  entry_bci is -1 for normal compilations and indicates
 608 // the continuation bci for on stack replacement.
 609 
 610 
 611 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci,
 612                   bool subsume_loads, bool do_escape_analysis, bool eliminate_boxing )
 613                 : Phase(Compiler),
 614                   _env(ci_env),
 615                   _log(ci_env->log()),
 616                   _compile_id(ci_env->compile_id()),
 617                   _save_argument_registers(false),
 618                   _stub_name(NULL),
 619                   _stub_function(NULL),
 620                   _stub_entry_point(NULL),
 621                   _method(target),
 622                   _entry_bci(osr_bci),
 623                   _initial_gvn(NULL),
 624                   _for_igvn(NULL),
 625                   _warm_calls(NULL),
 626                   _subsume_loads(subsume_loads),
 627                   _do_escape_analysis(do_escape_analysis),
 628                   _eliminate_autobox(eliminate_boxing),
 629                   _failure_reason(NULL),
 630                   _code_buffer("Compile::Fill_buffer"),
 631                   _orig_pc_slot(0),
 632                   _orig_pc_slot_offset_in_bytes(0),
 633                   _has_method_handle_invokes(false),
 634                   _mach_constant_base_node(NULL),
 635                   _node_bundling_limit(0),
 636                   _node_bundling_base(NULL),
 637                   _java_calls(0),
 638                   _inner_loops(0),
 639                   _scratch_const_size(-1),
 640                   _in_scratch_emit_size(false),
 641                   _dead_node_list(comp_arena()),
 642                   _dead_node_count(0),
 643 #ifndef PRODUCT
 644                   _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
 645                   _printer(IdealGraphPrinter::printer()),
 646 #endif
 647                   _congraph(NULL),
 648                   _late_inlines(comp_arena(), 2, 0, NULL),
 649                   _string_late_inlines(comp_arena(), 2, 0, NULL),
 650                   _boxing_late_inlines(comp_arena(), 2, 0, NULL),
 651                   _late_inlines_pos(0),
 652                   _number_of_mh_late_inlines(0),
 653                   _inlining_progress(false),
 654                   _inlining_incrementally(false),
 655                   _print_inlining_list(NULL),
 656                   _print_inlining(0) {
 657   C = this;
 658 
 659   CompileWrapper cw(this);
 660 #ifndef PRODUCT
 661   if (TimeCompiler2) {
 662     tty->print(" ");
 663     target->holder()->name()->print();
 664     tty->print(".");
 665     target->print_short_name();
 666     tty->print("  ");
 667   }
 668   TraceTime t1("Total compilation time", &_t_totalCompilation, TimeCompiler, TimeCompiler2);
 669   TraceTime t2(NULL, &_t_methodCompilation, TimeCompiler, false);
 670   bool print_opto_assembly = PrintOptoAssembly || _method->has_option("PrintOptoAssembly");


 899                   bool pass_tls,
 900                   bool save_arg_registers,
 901                   bool return_pc )
 902   : Phase(Compiler),
 903     _env(ci_env),
 904     _log(ci_env->log()),
 905     _compile_id(0),
 906     _save_argument_registers(save_arg_registers),
 907     _method(NULL),
 908     _stub_name(stub_name),
 909     _stub_function(stub_function),
 910     _stub_entry_point(NULL),
 911     _entry_bci(InvocationEntryBci),
 912     _initial_gvn(NULL),
 913     _for_igvn(NULL),
 914     _warm_calls(NULL),
 915     _orig_pc_slot(0),
 916     _orig_pc_slot_offset_in_bytes(0),
 917     _subsume_loads(true),
 918     _do_escape_analysis(false),
 919     _eliminate_autobox(false),
 920     _failure_reason(NULL),
 921     _code_buffer("Compile::Fill_buffer"),
 922     _has_method_handle_invokes(false),
 923     _mach_constant_base_node(NULL),
 924     _node_bundling_limit(0),
 925     _node_bundling_base(NULL),
 926     _java_calls(0),
 927     _inner_loops(0),
 928 #ifndef PRODUCT
 929     _trace_opto_output(TraceOptoOutput),
 930     _printer(NULL),
 931 #endif
 932     _dead_node_list(comp_arena()),
 933     _dead_node_count(0),
 934     _congraph(NULL),
 935     _number_of_mh_late_inlines(0),
 936     _inlining_progress(false),
 937     _inlining_incrementally(false),
 938     _print_inlining_list(NULL),
 939     _print_inlining(0) {


1010 
1011   _immutable_memory = NULL; // filled in at first inquiry
1012 
1013   // Globally visible Nodes
1014   // First set TOP to NULL to give safe behavior during creation of RootNode
1015   set_cached_top_node(NULL);
1016   set_root(new (this) RootNode());
1017   // Now that you have a Root to point to, create the real TOP
1018   set_cached_top_node( new (this) ConNode(Type::TOP) );
1019   set_recent_alloc(NULL, NULL);
1020 
1021   // Create Debug Information Recorder to record scopes, oopmaps, etc.
1022   env()->set_oop_recorder(new OopRecorder(env()->arena()));
1023   env()->set_debug_info(new DebugInformationRecorder(env()->oop_recorder()));
1024   env()->set_dependencies(new Dependencies(env()));
1025 
1026   _fixed_slots = 0;
1027   set_has_split_ifs(false);
1028   set_has_loops(has_method() && method()->has_loops()); // first approximation
1029   set_has_stringbuilder(false);
1030   set_has_boxed_value(false);
1031   _trap_can_recompile = false;  // no traps emitted yet
1032   _major_progress = true; // start out assuming good things will happen
1033   set_has_unsafe_access(false);
1034   set_max_vector_size(0);
1035   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
1036   set_decompile_count(0);
1037 
1038   set_do_freq_based_layout(BlockLayoutByFrequency || method_has_option("BlockLayoutByFrequency"));
1039   set_num_loop_opts(LoopOptsCount);
1040   set_do_inlining(Inline);
1041   set_max_inline_size(MaxInlineSize);
1042   set_freq_inline_size(FreqInlineSize);
1043   set_do_scheduling(OptoScheduling);
1044   set_do_count_invocations(false);
1045   set_do_method_data_update(false);
1046 
1047   if (debug_info()->recording_non_safepoints()) {
1048     set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*>
1049                         (comp_arena(), 8, 0, NULL));
1050     set_default_node_notes(Node_Notes::make(this));


1802   {
1803     ResourceMark rm;
1804     print_method("Before StringOpts", 3);
1805     PhaseStringOpts pso(initial_gvn(), for_igvn());
1806     print_method("After StringOpts", 3);
1807   }
1808 
1809   // now inline anything that we skipped the first time around
1810   if (!parse_time) {
1811     _late_inlines_pos = _late_inlines.length();
1812   }
1813 
1814   while (_string_late_inlines.length() > 0) {
1815     CallGenerator* cg = _string_late_inlines.pop();
1816     cg->do_late_inline();
1817     if (failing())  return;
1818   }
1819   _string_late_inlines.trunc_to(0);
1820 }
1821 
1822 // Late inlining of boxing methods
1823 void Compile::inline_boxing_calls(PhaseIterGVN& igvn) {
1824   if (_boxing_late_inlines.length() > 0) {
1825     assert(has_boxed_value(), "inconsistent");
1826 
1827     PhaseGVN* gvn = initial_gvn();
1828     set_inlining_incrementally(true);
1829 
1830     assert( igvn._worklist.size() == 0, "should be done with igvn" );
1831     for_igvn()->clear();
1832     gvn->replace_with(&igvn);
1833 
1834     while (_boxing_late_inlines.length() > 0) {
1835       CallGenerator* cg = _boxing_late_inlines.pop();
1836       cg->do_late_inline();
1837       if (failing())  return;
1838     }
1839     _boxing_late_inlines.trunc_to(0);
1840 
1841     {
1842       ResourceMark rm;
1843       PhaseRemoveUseless pru(gvn, for_igvn());
1844     }
1845 
1846     igvn = PhaseIterGVN(gvn);
1847     igvn.optimize();
1848 
1849     set_inlining_progress(false);
1850     set_inlining_incrementally(false);
1851   }
1852 }
1853 
1854 void Compile::inline_incrementally_one(PhaseIterGVN& igvn) {
1855   assert(IncrementalInline, "incremental inlining should be on");
1856   PhaseGVN* gvn = initial_gvn();
1857 
1858   set_inlining_progress(false);
1859   for_igvn()->clear();
1860   gvn->replace_with(&igvn);
1861 
1862   int i = 0;
1863 
1864   for (; i <_late_inlines.length() && !inlining_progress(); i++) {
1865     CallGenerator* cg = _late_inlines.at(i);
1866     _late_inlines_pos = i+1;
1867     cg->do_late_inline();
1868     if (failing())  return;
1869   }
1870   int j = 0;
1871   for (; i < _late_inlines.length(); i++, j++) {
1872     _late_inlines.at_put(j, _late_inlines.at(i));
1873   }
1874   _late_inlines.trunc_to(j);
1875 
1876   {
1877     ResourceMark rm;
1878     PhaseRemoveUseless pru(gvn, for_igvn());
1879   }
1880 
1881   igvn = PhaseIterGVN(gvn);
1882 }
1883 
1884 // Perform incremental inlining until bound on number of live nodes is reached
1885 void Compile::inline_incrementally(PhaseIterGVN& igvn) {
1886   PhaseGVN* gvn = initial_gvn();
1887 
1888   set_inlining_incrementally(true);
1889   set_inlining_progress(true);
1890   uint low_live_nodes = 0;
1891 
1892   while(inlining_progress() && _late_inlines.length() > 0) {
1893 
1894     if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
1895       if (low_live_nodes < (uint)LiveNodeCountInliningCutoff * 8 / 10) {
1896         // PhaseIdealLoop is expensive so we only try it once we are
1897         // out of loop and we only try it again if the previous helped
1898         // got the number of nodes down significantly


1956   ResourceMark rm;
1957   int          loop_opts_cnt;
1958 
1959   NOT_PRODUCT( verify_graph_edges(); )
1960 
1961   print_method("After Parsing");
1962 
1963  {
1964   // Iterative Global Value Numbering, including ideal transforms
1965   // Initialize IterGVN with types and values from parse-time GVN
1966   PhaseIterGVN igvn(initial_gvn());
1967   {
1968     NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); )
1969     igvn.optimize();
1970   }
1971 
1972   print_method("Iter GVN 1", 2);
1973 
1974   if (failing())  return;
1975 
1976   {
1977     NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); )
1978     inline_incrementally(igvn);
1979   }
1980 
1981   print_method("Incremental Inline", 2);
1982 
1983   if (failing())  return;
1984 
1985   if (eliminate_autobox()) {
1986     NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); )
1987     // Inline valueOf() methods now.
1988     inline_boxing_calls(igvn);
1989 
1990     print_method("Incremental Boxing Inline", 2);
1991 
1992     if (failing())  return;
1993   }
1994 
1995   // No more new expensive nodes will be added to the list from here
1996   // so keep only the actual candidates for optimizations.
1997   cleanup_expensive_nodes(igvn);
1998 
1999   // Perform escape analysis
2000   if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
2001     if (has_loops()) {
2002       // Cleanup graph (remove dead nodes).
2003       TracePhase t2("idealLoop", &_t_idealLoop, true);
2004       PhaseIdealLoop ideal_loop( igvn, false, true );
2005       if (major_progress()) print_method("PhaseIdealLoop before EA", 2);
2006       if (failing())  return;
2007     }
2008     ConnectionGraph::do_analysis(this, &igvn);
2009 
2010     if (failing())  return;
2011 
2012     // Optimize out fields loads from scalar replaceable allocations.
2013     igvn.optimize();
2014     print_method("Iter GVN after EA", 2);


2936       Node* in2 = n->in(2);
2937       juint mask = (n->bottom_type() == TypeInt::INT) ? (BitsPerInt - 1) : (BitsPerLong - 1);
2938       const TypeInt* t = in2->find_int_type();
2939       if (t != NULL && t->is_con()) {
2940         juint shift = t->get_con();
2941         if (shift > mask) { // Unsigned cmp
2942           n->set_req(2, ConNode::make(this, TypeInt::make(shift & mask)));
2943         }
2944       } else {
2945         if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) {
2946           Node* shift = new (this) AndINode(in2, ConNode::make(this, TypeInt::make(mask)));
2947           n->set_req(2, shift);
2948         }
2949       }
2950       if (in2->outcnt() == 0) { // Remove dead node
2951         in2->disconnect_inputs(NULL, this);
2952       }
2953     }
2954     break;
2955   case Op_MemBarStoreStore:
2956   case Op_MemBarRelease:
2957     // Break the link with AllocateNode: it is no longer useful and
2958     // confuses register allocation.
2959     if (n->req() > MemBarNode::Precedent) {
2960       n->set_req(MemBarNode::Precedent, top());
2961     }
2962     break;
2963   default:
2964     assert( !n->is_Call(), "" );
2965     assert( !n->is_Mem(), "" );
2966     break;
2967   }
2968 
2969   // Collect CFG split points
2970   if (n->is_MultiBranch())
2971     frc._tests.push(n);
2972 }
2973 
2974 //------------------------------final_graph_reshaping_walk---------------------
2975 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(),
2976 // requires that the walk visits a node's inputs before visiting the node.


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