416 remove_expensive_node(n); |
416 remove_expensive_node(n); |
417 } |
417 } |
418 } |
418 } |
419 // clean up the late inline lists |
419 // clean up the late inline lists |
420 remove_useless_late_inlines(&_string_late_inlines, useful); |
420 remove_useless_late_inlines(&_string_late_inlines, useful); |
|
421 remove_useless_late_inlines(&_boxing_late_inlines, useful); |
421 remove_useless_late_inlines(&_late_inlines, useful); |
422 remove_useless_late_inlines(&_late_inlines, useful); |
422 debug_only(verify_graph_edges(true/*check for no_dead_code*/);) |
423 debug_only(verify_graph_edges(true/*check for no_dead_code*/);) |
423 } |
424 } |
424 |
425 |
425 //------------------------------frame_size_in_words----------------------------- |
426 //------------------------------frame_size_in_words----------------------------- |
481 } |
482 } |
482 if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) { |
483 if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) { |
483 // Recompiling without escape analysis |
484 // Recompiling without escape analysis |
484 tty->print_cr("*********************************************************"); |
485 tty->print_cr("*********************************************************"); |
485 tty->print_cr("** Bailout: Recompile without escape analysis **"); |
486 tty->print_cr("** Bailout: Recompile without escape analysis **"); |
|
487 tty->print_cr("*********************************************************"); |
|
488 } |
|
489 if (_eliminate_boxing != EliminateAutoBox && PrintOpto) { |
|
490 // Recompiling without boxing elimination |
|
491 tty->print_cr("*********************************************************"); |
|
492 tty->print_cr("** Bailout: Recompile without boxing elimination **"); |
486 tty->print_cr("*********************************************************"); |
493 tty->print_cr("*********************************************************"); |
487 } |
494 } |
488 if (env()->break_at_compile()) { |
495 if (env()->break_at_compile()) { |
489 // Open the debugger when compiling this method. |
496 // Open the debugger when compiling this method. |
490 tty->print("### Breaking when compiling: "); |
497 tty->print("### Breaking when compiling: "); |
599 |
606 |
600 // Compile a method. entry_bci is -1 for normal compilations and indicates |
607 // Compile a method. entry_bci is -1 for normal compilations and indicates |
601 // the continuation bci for on stack replacement. |
608 // the continuation bci for on stack replacement. |
602 |
609 |
603 |
610 |
604 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci, bool subsume_loads, bool do_escape_analysis ) |
611 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci, |
|
612 bool subsume_loads, bool do_escape_analysis, bool eliminate_boxing ) |
605 : Phase(Compiler), |
613 : Phase(Compiler), |
606 _env(ci_env), |
614 _env(ci_env), |
607 _log(ci_env->log()), |
615 _log(ci_env->log()), |
608 _compile_id(ci_env->compile_id()), |
616 _compile_id(ci_env->compile_id()), |
609 _save_argument_registers(false), |
617 _save_argument_registers(false), |
615 _initial_gvn(NULL), |
623 _initial_gvn(NULL), |
616 _for_igvn(NULL), |
624 _for_igvn(NULL), |
617 _warm_calls(NULL), |
625 _warm_calls(NULL), |
618 _subsume_loads(subsume_loads), |
626 _subsume_loads(subsume_loads), |
619 _do_escape_analysis(do_escape_analysis), |
627 _do_escape_analysis(do_escape_analysis), |
|
628 _eliminate_boxing(eliminate_boxing), |
620 _failure_reason(NULL), |
629 _failure_reason(NULL), |
621 _code_buffer("Compile::Fill_buffer"), |
630 _code_buffer("Compile::Fill_buffer"), |
622 _orig_pc_slot(0), |
631 _orig_pc_slot(0), |
623 _orig_pc_slot_offset_in_bytes(0), |
632 _orig_pc_slot_offset_in_bytes(0), |
624 _has_method_handle_invokes(false), |
633 _has_method_handle_invokes(false), |
636 _printer(IdealGraphPrinter::printer()), |
645 _printer(IdealGraphPrinter::printer()), |
637 #endif |
646 #endif |
638 _congraph(NULL), |
647 _congraph(NULL), |
639 _late_inlines(comp_arena(), 2, 0, NULL), |
648 _late_inlines(comp_arena(), 2, 0, NULL), |
640 _string_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), |
641 _late_inlines_pos(0), |
651 _late_inlines_pos(0), |
642 _number_of_mh_late_inlines(0), |
652 _number_of_mh_late_inlines(0), |
643 _inlining_progress(false), |
653 _inlining_progress(false), |
644 _inlining_incrementally(false), |
654 _inlining_incrementally(false), |
645 _print_inlining_list(NULL), |
655 _print_inlining_list(NULL), |
904 _warm_calls(NULL), |
914 _warm_calls(NULL), |
905 _orig_pc_slot(0), |
915 _orig_pc_slot(0), |
906 _orig_pc_slot_offset_in_bytes(0), |
916 _orig_pc_slot_offset_in_bytes(0), |
907 _subsume_loads(true), |
917 _subsume_loads(true), |
908 _do_escape_analysis(false), |
918 _do_escape_analysis(false), |
|
919 _eliminate_boxing(false), |
909 _failure_reason(NULL), |
920 _failure_reason(NULL), |
910 _code_buffer("Compile::Fill_buffer"), |
921 _code_buffer("Compile::Fill_buffer"), |
911 _has_method_handle_invokes(false), |
922 _has_method_handle_invokes(false), |
912 _mach_constant_base_node(NULL), |
923 _mach_constant_base_node(NULL), |
913 _node_bundling_limit(0), |
924 _node_bundling_limit(0), |
1014 |
1025 |
1015 _fixed_slots = 0; |
1026 _fixed_slots = 0; |
1016 set_has_split_ifs(false); |
1027 set_has_split_ifs(false); |
1017 set_has_loops(has_method() && method()->has_loops()); // first approximation |
1028 set_has_loops(has_method() && method()->has_loops()); // first approximation |
1018 set_has_stringbuilder(false); |
1029 set_has_stringbuilder(false); |
|
1030 set_has_boxed_value(false); |
1019 _trap_can_recompile = false; // no traps emitted yet |
1031 _trap_can_recompile = false; // no traps emitted yet |
1020 _major_progress = true; // start out assuming good things will happen |
1032 _major_progress = true; // start out assuming good things will happen |
1021 set_has_unsafe_access(false); |
1033 set_has_unsafe_access(false); |
1022 set_max_vector_size(0); |
1034 set_max_vector_size(0); |
1023 Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist)); |
1035 Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist)); |
1805 if (failing()) return; |
1817 if (failing()) return; |
1806 } |
1818 } |
1807 _string_late_inlines.trunc_to(0); |
1819 _string_late_inlines.trunc_to(0); |
1808 } |
1820 } |
1809 |
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 |
1810 void Compile::inline_incrementally_one(PhaseIterGVN& igvn) { |
1854 void Compile::inline_incrementally_one(PhaseIterGVN& igvn) { |
1811 assert(IncrementalInline, "incremental inlining should be on"); |
1855 assert(IncrementalInline, "incremental inlining should be on"); |
1812 PhaseGVN* gvn = initial_gvn(); |
1856 PhaseGVN* gvn = initial_gvn(); |
1813 |
1857 |
1814 set_inlining_progress(false); |
1858 set_inlining_progress(false); |
1927 |
1971 |
1928 print_method("Iter GVN 1", 2); |
1972 print_method("Iter GVN 1", 2); |
1929 |
1973 |
1930 if (failing()) return; |
1974 if (failing()) return; |
1931 |
1975 |
1932 inline_incrementally(igvn); |
1976 { |
|
1977 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) |
|
1978 inline_incrementally(igvn); |
|
1979 } |
1933 |
1980 |
1934 print_method("Incremental Inline", 2); |
1981 print_method("Incremental Inline", 2); |
1935 |
1982 |
1936 if (failing()) return; |
1983 if (failing()) return; |
|
1984 |
|
1985 if (eliminate_boxing()) { |
|
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 } |
1937 |
1994 |
1938 // No more new expensive nodes will be added to the list from here |
1995 // No more new expensive nodes will be added to the list from here |
1939 // so keep only the actual candidates for optimizations. |
1996 // so keep only the actual candidates for optimizations. |
1940 cleanup_expensive_nodes(igvn); |
1997 cleanup_expensive_nodes(igvn); |
1941 |
1998 |
2894 in2->disconnect_inputs(NULL, this); |
2951 in2->disconnect_inputs(NULL, this); |
2895 } |
2952 } |
2896 } |
2953 } |
2897 break; |
2954 break; |
2898 case Op_MemBarStoreStore: |
2955 case Op_MemBarStoreStore: |
|
2956 case Op_MemBarRelease: |
2899 // Break the link with AllocateNode: it is no longer useful and |
2957 // Break the link with AllocateNode: it is no longer useful and |
2900 // confuses register allocation. |
2958 // confuses register allocation. |
2901 if (n->req() > MemBarNode::Precedent) { |
2959 if (n->req() > MemBarNode::Precedent) { |
2902 n->set_req(MemBarNode::Precedent, top()); |
2960 n->set_req(MemBarNode::Precedent, top()); |
2903 } |
2961 } |