1876 bool Compile::inline_incrementally_one() {
1877 assert(IncrementalInline, "incremental inlining should be on");
1878
1879 TracePhase tp("incrementalInline_inline", &timers[_t_incrInline_inline]);
1880 set_inlining_progress(false);
1881 set_do_cleanup(false);
1882 int i = 0;
1883 for (; i <_late_inlines.length() && !inlining_progress(); i++) {
1884 CallGenerator* cg = _late_inlines.at(i);
1885 _late_inlines_pos = i+1;
1886 cg->do_late_inline();
1887 if (failing()) return false;
1888 }
1889 int j = 0;
1890 for (; i < _late_inlines.length(); i++, j++) {
1891 _late_inlines.at_put(j, _late_inlines.at(i));
1892 }
1893 _late_inlines.trunc_to(j);
1894 assert(inlining_progress() || _late_inlines.length() == 0, "");
1895
1896 bool needs_cleanup = true;
1897
1898 set_inlining_progress(false);
1899 set_do_cleanup(false);
1900 return (_late_inlines.length() > 0) && !needs_cleanup;
1901 }
1902
1903 void Compile::inline_incrementally_cleanup(PhaseIterGVN& igvn) {
1904 {
1905 TracePhase tp("incrementalInline_pru", &timers[_t_incrInline_pru]);
1906 ResourceMark rm;
1907 PhaseRemoveUseless pru(initial_gvn(), for_igvn());
1908 }
1909 {
1910 TracePhase tp("incrementalInline_igvn", &timers[_t_incrInline_igvn]);
1911 igvn = PhaseIterGVN(initial_gvn());
1912 igvn.optimize();
1913 }
1914 }
1915
1916 // Perform incremental inlining until bound on number of live nodes is reached
1934 }
1935
1936 if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
1937 break; // finish
1938 }
1939 }
1940
1941 for_igvn()->clear();
1942 initial_gvn()->replace_with(&igvn);
1943
1944 while (inline_incrementally_one()) {
1945 assert(!failing(), "inconsistent");
1946 }
1947
1948 if (failing()) return;
1949
1950 inline_incrementally_cleanup(igvn);
1951
1952 print_method(PHASE_INCREMENTAL_INLINE_STEP, 3);
1953
1954
1955 if (failing()) return;
1956 }
1957 assert( igvn._worklist.size() == 0, "should be done with igvn" );
1958
1959 if (_string_late_inlines.length() > 0) {
1960 assert(has_stringbuilder(), "inconsistent");
1961 for_igvn()->clear();
1962 initial_gvn()->replace_with(&igvn);
1963
1964 inline_string_calls(false);
1965
1966 if (failing()) return;
1967
1968 inline_incrementally_cleanup(igvn);
1969 }
1970
1971 set_inlining_incrementally(false);
1972 }
1973
1974
2049 igvn.optimize();
2050 }
2051
2052 if (failing()) return;
2053
2054 print_method(PHASE_ITER_GVN1, 2);
2055
2056 inline_incrementally(igvn);
2057
2058 print_method(PHASE_INCREMENTAL_INLINE, 2);
2059
2060 if (failing()) return;
2061
2062 if (eliminate_boxing()) {
2063 // Inline valueOf() methods now.
2064 inline_boxing_calls(igvn);
2065
2066 if (AlwaysIncrementalInline) {
2067 inline_incrementally(igvn);
2068 }
2069 if (failing()) return;
2070
2071 print_method(PHASE_INCREMENTAL_BOXING_INLINE, 2);
2072 }
2073
2074 // Now that all inlining is over, cut edge from root to loop
2075 // safepoints
2076 remove_root_to_sfpts_edges(igvn);
2077
2078 // Remove the speculative part of types and clean up the graph from
2079 // the extra CastPP nodes whose only purpose is to carry them. Do
2080 // that early so that optimizations are not disrupted by the extra
2081 // CastPP nodes.
2082 remove_speculative_types(igvn);
2083
2084 // No more new expensive nodes will be added to the list from here
2085 // so keep only the actual candidates for optimizations.
2086 cleanup_expensive_nodes(igvn);
2087
2088 assert(EnableVectorSupport || !has_vbox_nodes(), "sanity");
2089 if (EnableVectorSupport && has_vbox_nodes()) {
2090 TracePhase tp("", &timers[_t_vector]);
2091 PhaseVector pv(igvn);
2092 pv.optimize_vector_boxes();
2093
2094 print_method(PHASE_ITER_GVN_AFTER_VECTOR, 2);
2095 }
2096 assert(!has_vbox_nodes(), "sanity");
2097
2098 if (!failing() && RenumberLiveNodes && live_nodes() + NodeLimitFudgeFactor < unique()) {
2099 Compile::TracePhase tp("", &timers[_t_renumberLive]);
2100 initial_gvn()->replace_with(&igvn);
2101 for_igvn()->clear();
2102 Unique_Node_List new_worklist(C->comp_arena());
2103 {
2104 ResourceMark rm;
2105 PhaseRenumberLive prl = PhaseRenumberLive(initial_gvn(), for_igvn(), &new_worklist);
2106 }
2107 set_for_igvn(&new_worklist);
2108 igvn = PhaseIterGVN(initial_gvn());
2109 igvn.optimize();
2110 }
2111
2112 // FIXME for_igvn() is corrupted from here: new_worklist which is set_for_ignv() was allocated on stack.
2113
2114 // Perform escape analysis
2115 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
2116 if (has_loops()) {
2117 // Cleanup graph (remove dead nodes).
2118 TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2119 PhaseIdealLoop::optimize(igvn, LoopOptsMaxUnroll);
2120 if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2);
2121 if (failing()) return;
2122 }
2123 ConnectionGraph::do_analysis(this, &igvn);
2124
2125 if (failing()) return;
2126
2127 // Optimize out fields loads from scalar replaceable allocations.
2128 igvn.optimize();
2129 print_method(PHASE_ITER_GVN_AFTER_EA, 2);
2130
2131 if (failing()) return;
2132
2133 if (congraph() != NULL && macro_count() > 0) {
4616 }
4617 allocates++;
4618 }
4619 }
4620 }
4621
4622 void Compile::print_method(CompilerPhaseType cpt, const char *name, int level, int idx) {
4623 EventCompilerPhase event;
4624 if (event.should_commit()) {
4625 CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, cpt, C->_compile_id, level);
4626 }
4627 #ifndef PRODUCT
4628 if (should_print(level)) {
4629 _printer->print_method(name, level);
4630 }
4631 #endif
4632 C->_latest_stage_start_counter.stamp();
4633 }
4634
4635 void Compile::print_method(CompilerPhaseType cpt, int level, int idx) {
4636 if (should_print(level)) {
4637 #ifndef PRODUCT
4638 char output[1024];
4639 if (idx != 0) {
4640 jio_snprintf(output, sizeof(output), "%s:%d", CompilerPhaseTypeHelper::to_string(cpt), idx);
4641 } else {
4642 jio_snprintf(output, sizeof(output), "%s", CompilerPhaseTypeHelper::to_string(cpt));
4643 }
4644 }
4645 #endif
4646 print_method(cpt, output, level, idx);
4647 }
4648
4649 void Compile::print_method(CompilerPhaseType cpt, Node* n, int level) {
4650 ResourceMark rm;
4651 stringStream ss;
4652 ss.print_raw(CompilerPhaseTypeHelper::to_string(cpt));
4653 if (n != NULL) {
4654 #ifndef PRODUCT
4655 ss.print(": %s %d", n->Name(), n->_idx);
4656 #else
4657 ss.print(": %d %d", n->Opcode(), n->_idx);
4658 #endif // !PRODUCT
4659 } else {
4660 ss.print_raw(": NULL");
4661 }
4662 C->print_method(cpt, ss.as_string(), level);
4663 }
4664
4665 void Compile::end_method(int level) {
4666 EventCompilerPhase event;
4667 if (event.should_commit()) {
4668 CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, PHASE_END, C->_compile_id, level);
4669 }
4670
4671 #ifndef PRODUCT
4672 if (_method != NULL && should_print(level)) {
4673 _printer->end_method();
4674 }
4675 #endif
4676 }
4677
4678
|
1876 bool Compile::inline_incrementally_one() {
1877 assert(IncrementalInline, "incremental inlining should be on");
1878
1879 TracePhase tp("incrementalInline_inline", &timers[_t_incrInline_inline]);
1880 set_inlining_progress(false);
1881 set_do_cleanup(false);
1882 int i = 0;
1883 for (; i <_late_inlines.length() && !inlining_progress(); i++) {
1884 CallGenerator* cg = _late_inlines.at(i);
1885 _late_inlines_pos = i+1;
1886 cg->do_late_inline();
1887 if (failing()) return false;
1888 }
1889 int j = 0;
1890 for (; i < _late_inlines.length(); i++, j++) {
1891 _late_inlines.at_put(j, _late_inlines.at(i));
1892 }
1893 _late_inlines.trunc_to(j);
1894 assert(inlining_progress() || _late_inlines.length() == 0, "");
1895
1896 bool needs_cleanup = do_cleanup() || over_inlining_cutoff();
1897
1898 set_inlining_progress(false);
1899 set_do_cleanup(false);
1900 return (_late_inlines.length() > 0) && !needs_cleanup;
1901 }
1902
1903 void Compile::inline_incrementally_cleanup(PhaseIterGVN& igvn) {
1904 {
1905 TracePhase tp("incrementalInline_pru", &timers[_t_incrInline_pru]);
1906 ResourceMark rm;
1907 PhaseRemoveUseless pru(initial_gvn(), for_igvn());
1908 }
1909 {
1910 TracePhase tp("incrementalInline_igvn", &timers[_t_incrInline_igvn]);
1911 igvn = PhaseIterGVN(initial_gvn());
1912 igvn.optimize();
1913 }
1914 }
1915
1916 // Perform incremental inlining until bound on number of live nodes is reached
1934 }
1935
1936 if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
1937 break; // finish
1938 }
1939 }
1940
1941 for_igvn()->clear();
1942 initial_gvn()->replace_with(&igvn);
1943
1944 while (inline_incrementally_one()) {
1945 assert(!failing(), "inconsistent");
1946 }
1947
1948 if (failing()) return;
1949
1950 inline_incrementally_cleanup(igvn);
1951
1952 print_method(PHASE_INCREMENTAL_INLINE_STEP, 3);
1953
1954 if (failing()) return;
1955 }
1956 assert( igvn._worklist.size() == 0, "should be done with igvn" );
1957
1958 if (_string_late_inlines.length() > 0) {
1959 assert(has_stringbuilder(), "inconsistent");
1960 for_igvn()->clear();
1961 initial_gvn()->replace_with(&igvn);
1962
1963 inline_string_calls(false);
1964
1965 if (failing()) return;
1966
1967 inline_incrementally_cleanup(igvn);
1968 }
1969
1970 set_inlining_incrementally(false);
1971 }
1972
1973
2048 igvn.optimize();
2049 }
2050
2051 if (failing()) return;
2052
2053 print_method(PHASE_ITER_GVN1, 2);
2054
2055 inline_incrementally(igvn);
2056
2057 print_method(PHASE_INCREMENTAL_INLINE, 2);
2058
2059 if (failing()) return;
2060
2061 if (eliminate_boxing()) {
2062 // Inline valueOf() methods now.
2063 inline_boxing_calls(igvn);
2064
2065 if (AlwaysIncrementalInline) {
2066 inline_incrementally(igvn);
2067 }
2068
2069 print_method(PHASE_INCREMENTAL_BOXING_INLINE, 2);
2070
2071 if (failing()) return;
2072 }
2073
2074 // Now that all inlining is over, cut edge from root to loop
2075 // safepoints
2076 remove_root_to_sfpts_edges(igvn);
2077
2078 // Remove the speculative part of types and clean up the graph from
2079 // the extra CastPP nodes whose only purpose is to carry them. Do
2080 // that early so that optimizations are not disrupted by the extra
2081 // CastPP nodes.
2082 remove_speculative_types(igvn);
2083
2084 // No more new expensive nodes will be added to the list from here
2085 // so keep only the actual candidates for optimizations.
2086 cleanup_expensive_nodes(igvn);
2087
2088 assert(EnableVectorSupport || !has_vbox_nodes(), "sanity");
2089 if (EnableVectorSupport && has_vbox_nodes()) {
2090 TracePhase tp("", &timers[_t_vector]);
2091 PhaseVector pv(igvn);
2092 pv.optimize_vector_boxes();
2093
2094 print_method(PHASE_ITER_GVN_AFTER_VECTOR, 2);
2095 }
2096 assert(!has_vbox_nodes(), "sanity");
2097
2098 if (!failing() && RenumberLiveNodes && live_nodes() + NodeLimitFudgeFactor < unique()) {
2099 Compile::TracePhase tp("", &timers[_t_renumberLive]);
2100 initial_gvn()->replace_with(&igvn);
2101 for_igvn()->clear();
2102 Unique_Node_List new_worklist(C->comp_arena());
2103 {
2104 ResourceMark rm;
2105 PhaseRenumberLive prl = PhaseRenumberLive(initial_gvn(), for_igvn(), &new_worklist);
2106 }
2107 set_for_igvn(&new_worklist);
2108 igvn = PhaseIterGVN(initial_gvn());
2109 igvn.optimize();
2110 }
2111
2112 // Perform escape analysis
2113 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
2114 if (has_loops()) {
2115 // Cleanup graph (remove dead nodes).
2116 TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2117 PhaseIdealLoop::optimize(igvn, LoopOptsMaxUnroll);
2118 if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2);
2119 if (failing()) return;
2120 }
2121 ConnectionGraph::do_analysis(this, &igvn);
2122
2123 if (failing()) return;
2124
2125 // Optimize out fields loads from scalar replaceable allocations.
2126 igvn.optimize();
2127 print_method(PHASE_ITER_GVN_AFTER_EA, 2);
2128
2129 if (failing()) return;
2130
2131 if (congraph() != NULL && macro_count() > 0) {
4614 }
4615 allocates++;
4616 }
4617 }
4618 }
4619
4620 void Compile::print_method(CompilerPhaseType cpt, const char *name, int level, int idx) {
4621 EventCompilerPhase event;
4622 if (event.should_commit()) {
4623 CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, cpt, C->_compile_id, level);
4624 }
4625 #ifndef PRODUCT
4626 if (should_print(level)) {
4627 _printer->print_method(name, level);
4628 }
4629 #endif
4630 C->_latest_stage_start_counter.stamp();
4631 }
4632
4633 void Compile::print_method(CompilerPhaseType cpt, int level, int idx) {
4634 char output[1024];
4635 #ifndef PRODUCT
4636 if (idx != 0) {
4637 jio_snprintf(output, sizeof(output), "%s:%d", CompilerPhaseTypeHelper::to_string(cpt), idx);
4638 } else {
4639 jio_snprintf(output, sizeof(output), "%s", CompilerPhaseTypeHelper::to_string(cpt));
4640 }
4641 #endif
4642 print_method(cpt, output, level, idx);
4643 }
4644
4645 void Compile::print_method(CompilerPhaseType cpt, Node* n, int level) {
4646 ResourceMark rm;
4647 stringStream ss;
4648 ss.print_raw(CompilerPhaseTypeHelper::to_string(cpt));
4649 if (n != NULL) {
4650 ss.print(": %d %s ", n->_idx, NodeClassNames[n->Opcode()]);
4651 } else {
4652 ss.print_raw(": NULL");
4653 }
4654 C->print_method(cpt, ss.as_string(), level);
4655 }
4656
4657 void Compile::end_method(int level) {
4658 EventCompilerPhase event;
4659 if (event.should_commit()) {
4660 CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, PHASE_END, C->_compile_id, level);
4661 }
4662
4663 #ifndef PRODUCT
4664 if (_method != NULL && should_print(level)) {
4665 _printer->end_method();
4666 }
4667 #endif
4668 }
4669
4670
|