comparison src/share/vm/opto/compile.cpp @ 14392:b5c8a61d7fa0

Merge
author kvn
date Fri, 21 Jun 2013 15:56:24 -0700
parents d2907f74462e f2110083203d
children e2722a66aba7
comparison
equal deleted inserted replaced
14391:d2907f74462e 14392:b5c8a61d7fa0
1 /* 1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
61 #include "opto/vectornode.hpp" 61 #include "opto/vectornode.hpp"
62 #include "runtime/arguments.hpp" 62 #include "runtime/arguments.hpp"
63 #include "runtime/signature.hpp" 63 #include "runtime/signature.hpp"
64 #include "runtime/stubRoutines.hpp" 64 #include "runtime/stubRoutines.hpp"
65 #include "runtime/timer.hpp" 65 #include "runtime/timer.hpp"
66 #include "trace/tracing.hpp"
66 #include "utilities/copy.hpp" 67 #include "utilities/copy.hpp"
67 #ifdef TARGET_ARCH_MODEL_x86_32 68 #ifdef TARGET_ARCH_MODEL_x86_32
68 # include "adfiles/ad_x86_32.hpp" 69 # include "adfiles/ad_x86_32.hpp"
69 #endif 70 #endif
70 #ifdef TARGET_ARCH_MODEL_x86_64 71 #ifdef TARGET_ARCH_MODEL_x86_64
787 inline_string_calls(true); 788 inline_string_calls(true);
788 } 789 }
789 790
790 if (failing()) return; 791 if (failing()) return;
791 792
792 print_method("Before RemoveUseless", 3); 793 print_method(PHASE_BEFORE_REMOVEUSELESS, 3);
793 794
794 // Remove clutter produced by parsing. 795 // Remove clutter produced by parsing.
795 if (!failing()) { 796 if (!failing()) {
796 ResourceMark rm; 797 ResourceMark rm;
797 PhaseRemoveUseless pru(initial_gvn(), &for_igvn); 798 PhaseRemoveUseless pru(initial_gvn(), &for_igvn);
1802 PhaseRemoveUseless pru(initial_gvn(), for_igvn()); 1803 PhaseRemoveUseless pru(initial_gvn(), for_igvn());
1803 } 1804 }
1804 1805
1805 { 1806 {
1806 ResourceMark rm; 1807 ResourceMark rm;
1807 print_method("Before StringOpts", 3); 1808 print_method(PHASE_BEFORE_STRINGOPTS, 3);
1808 PhaseStringOpts pso(initial_gvn(), for_igvn()); 1809 PhaseStringOpts pso(initial_gvn(), for_igvn());
1809 print_method("After StringOpts", 3); 1810 print_method(PHASE_AFTER_STRINGOPTS, 3);
1810 } 1811 }
1811 1812
1812 // now inline anything that we skipped the first time around 1813 // now inline anything that we skipped the first time around
1813 if (!parse_time) { 1814 if (!parse_time) {
1814 _late_inlines_pos = _late_inlines.length(); 1815 _late_inlines_pos = _late_inlines.length();
1959 ResourceMark rm; 1960 ResourceMark rm;
1960 int loop_opts_cnt; 1961 int loop_opts_cnt;
1961 1962
1962 NOT_PRODUCT( verify_graph_edges(); ) 1963 NOT_PRODUCT( verify_graph_edges(); )
1963 1964
1964 print_method("After Parsing"); 1965 print_method(PHASE_AFTER_PARSING);
1965 1966
1966 { 1967 {
1967 // Iterative Global Value Numbering, including ideal transforms 1968 // Iterative Global Value Numbering, including ideal transforms
1968 // Initialize IterGVN with types and values from parse-time GVN 1969 // Initialize IterGVN with types and values from parse-time GVN
1969 PhaseIterGVN igvn(initial_gvn()); 1970 PhaseIterGVN igvn(initial_gvn());
1970 { 1971 {
1971 NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); ) 1972 NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); )
1972 igvn.optimize(); 1973 igvn.optimize();
1973 } 1974 }
1974 1975
1975 print_method("Iter GVN 1", 2); 1976 print_method(PHASE_ITER_GVN1, 2);
1976 1977
1977 if (failing()) return; 1978 if (failing()) return;
1978 1979
1979 { 1980 {
1980 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) 1981 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); )
1981 inline_incrementally(igvn); 1982 inline_incrementally(igvn);
1982 } 1983 }
1983 1984
1984 print_method("Incremental Inline", 2); 1985 print_method(PHASE_INCREMENTAL_INLINE, 2);
1985 1986
1986 if (failing()) return; 1987 if (failing()) return;
1987 1988
1988 if (eliminate_boxing()) { 1989 if (eliminate_boxing()) {
1989 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) 1990 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); )
1990 // Inline valueOf() methods now. 1991 // Inline valueOf() methods now.
1991 inline_boxing_calls(igvn); 1992 inline_boxing_calls(igvn);
1992 1993
1993 print_method("Incremental Boxing Inline", 2); 1994 print_method(PHASE_INCREMENTAL_BOXING_INLINE, 2);
1994 1995
1995 if (failing()) return; 1996 if (failing()) return;
1996 } 1997 }
1997 1998
1998 // No more new expensive nodes will be added to the list from here 1999 // No more new expensive nodes will be added to the list from here
2003 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) { 2004 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
2004 if (has_loops()) { 2005 if (has_loops()) {
2005 // Cleanup graph (remove dead nodes). 2006 // Cleanup graph (remove dead nodes).
2006 TracePhase t2("idealLoop", &_t_idealLoop, true); 2007 TracePhase t2("idealLoop", &_t_idealLoop, true);
2007 PhaseIdealLoop ideal_loop( igvn, false, true ); 2008 PhaseIdealLoop ideal_loop( igvn, false, true );
2008 if (major_progress()) print_method("PhaseIdealLoop before EA", 2); 2009 if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2);
2009 if (failing()) return; 2010 if (failing()) return;
2010 } 2011 }
2011 ConnectionGraph::do_analysis(this, &igvn); 2012 ConnectionGraph::do_analysis(this, &igvn);
2012 2013
2013 if (failing()) return; 2014 if (failing()) return;
2014 2015
2015 // Optimize out fields loads from scalar replaceable allocations. 2016 // Optimize out fields loads from scalar replaceable allocations.
2016 igvn.optimize(); 2017 igvn.optimize();
2017 print_method("Iter GVN after EA", 2); 2018 print_method(PHASE_ITER_GVN_AFTER_EA, 2);
2018 2019
2019 if (failing()) return; 2020 if (failing()) return;
2020 2021
2021 if (congraph() != NULL && macro_count() > 0) { 2022 if (congraph() != NULL && macro_count() > 0) {
2022 NOT_PRODUCT( TracePhase t2("macroEliminate", &_t_macroEliminate, TimeCompiler); ) 2023 NOT_PRODUCT( TracePhase t2("macroEliminate", &_t_macroEliminate, TimeCompiler); )
2023 PhaseMacroExpand mexp(igvn); 2024 PhaseMacroExpand mexp(igvn);
2024 mexp.eliminate_macro_nodes(); 2025 mexp.eliminate_macro_nodes();
2025 igvn.set_delay_transform(false); 2026 igvn.set_delay_transform(false);
2026 2027
2027 igvn.optimize(); 2028 igvn.optimize();
2028 print_method("Iter GVN after eliminating allocations and locks", 2); 2029 print_method(PHASE_ITER_GVN_AFTER_ELIMINATION, 2);
2029 2030
2030 if (failing()) return; 2031 if (failing()) return;
2031 } 2032 }
2032 } 2033 }
2033 2034
2039 if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { 2040 if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) {
2040 { 2041 {
2041 TracePhase t2("idealLoop", &_t_idealLoop, true); 2042 TracePhase t2("idealLoop", &_t_idealLoop, true);
2042 PhaseIdealLoop ideal_loop( igvn, true ); 2043 PhaseIdealLoop ideal_loop( igvn, true );
2043 loop_opts_cnt--; 2044 loop_opts_cnt--;
2044 if (major_progress()) print_method("PhaseIdealLoop 1", 2); 2045 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2);
2045 if (failing()) return; 2046 if (failing()) return;
2046 } 2047 }
2047 // Loop opts pass if partial peeling occurred in previous pass 2048 // Loop opts pass if partial peeling occurred in previous pass
2048 if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) { 2049 if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) {
2049 TracePhase t3("idealLoop", &_t_idealLoop, true); 2050 TracePhase t3("idealLoop", &_t_idealLoop, true);
2050 PhaseIdealLoop ideal_loop( igvn, false ); 2051 PhaseIdealLoop ideal_loop( igvn, false );
2051 loop_opts_cnt--; 2052 loop_opts_cnt--;
2052 if (major_progress()) print_method("PhaseIdealLoop 2", 2); 2053 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2);
2053 if (failing()) return; 2054 if (failing()) return;
2054 } 2055 }
2055 // Loop opts pass for loop-unrolling before CCP 2056 // Loop opts pass for loop-unrolling before CCP
2056 if(major_progress() && (loop_opts_cnt > 0)) { 2057 if(major_progress() && (loop_opts_cnt > 0)) {
2057 TracePhase t4("idealLoop", &_t_idealLoop, true); 2058 TracePhase t4("idealLoop", &_t_idealLoop, true);
2058 PhaseIdealLoop ideal_loop( igvn, false ); 2059 PhaseIdealLoop ideal_loop( igvn, false );
2059 loop_opts_cnt--; 2060 loop_opts_cnt--;
2060 if (major_progress()) print_method("PhaseIdealLoop 3", 2); 2061 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2);
2061 } 2062 }
2062 if (!failing()) { 2063 if (!failing()) {
2063 // Verify that last round of loop opts produced a valid graph 2064 // Verify that last round of loop opts produced a valid graph
2064 NOT_PRODUCT( TracePhase t2("idealLoopVerify", &_t_idealLoopVerify, TimeCompiler); ) 2065 NOT_PRODUCT( TracePhase t2("idealLoopVerify", &_t_idealLoopVerify, TimeCompiler); )
2065 PhaseIdealLoop::verify(igvn); 2066 PhaseIdealLoop::verify(igvn);
2072 assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)"); 2073 assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)");
2073 { 2074 {
2074 TracePhase t2("ccp", &_t_ccp, true); 2075 TracePhase t2("ccp", &_t_ccp, true);
2075 ccp.do_transform(); 2076 ccp.do_transform();
2076 } 2077 }
2077 print_method("PhaseCPP 1", 2); 2078 print_method(PHASE_CPP1, 2);
2078 2079
2079 assert( true, "Break here to ccp.dump_old2new_map()"); 2080 assert( true, "Break here to ccp.dump_old2new_map()");
2080 2081
2081 // Iterative Global Value Numbering, including ideal transforms 2082 // Iterative Global Value Numbering, including ideal transforms
2082 { 2083 {
2083 NOT_PRODUCT( TracePhase t2("iterGVN2", &_t_iterGVN2, TimeCompiler); ) 2084 NOT_PRODUCT( TracePhase t2("iterGVN2", &_t_iterGVN2, TimeCompiler); )
2084 igvn = ccp; 2085 igvn = ccp;
2085 igvn.optimize(); 2086 igvn.optimize();
2086 } 2087 }
2087 2088
2088 print_method("Iter GVN 2", 2); 2089 print_method(PHASE_ITER_GVN2, 2);
2089 2090
2090 if (failing()) return; 2091 if (failing()) return;
2091 2092
2092 // Loop transforms on the ideal graph. Range Check Elimination, 2093 // Loop transforms on the ideal graph. Range Check Elimination,
2093 // peeling, unrolling, etc. 2094 // peeling, unrolling, etc.
2096 while(major_progress() && (loop_opts_cnt > 0)) { 2097 while(major_progress() && (loop_opts_cnt > 0)) {
2097 TracePhase t2("idealLoop", &_t_idealLoop, true); 2098 TracePhase t2("idealLoop", &_t_idealLoop, true);
2098 assert( cnt++ < 40, "infinite cycle in loop optimization" ); 2099 assert( cnt++ < 40, "infinite cycle in loop optimization" );
2099 PhaseIdealLoop ideal_loop( igvn, true); 2100 PhaseIdealLoop ideal_loop( igvn, true);
2100 loop_opts_cnt--; 2101 loop_opts_cnt--;
2101 if (major_progress()) print_method("PhaseIdealLoop iterations", 2); 2102 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2);
2102 if (failing()) return; 2103 if (failing()) return;
2103 } 2104 }
2104 } 2105 }
2105 2106
2106 { 2107 {
2129 assert(failing(), "must bail out w/ explicit message"); 2130 assert(failing(), "must bail out w/ explicit message");
2130 return; 2131 return;
2131 } 2132 }
2132 } 2133 }
2133 2134
2134 print_method("Optimize finished", 2); 2135 print_method(PHASE_OPTIMIZE_FINISHED, 2);
2135 } 2136 }
2136 2137
2137 2138
2138 //------------------------------Code_Gen--------------------------------------- 2139 //------------------------------Code_Gen---------------------------------------
2139 // Given a graph, generate code for it 2140 // Given a graph, generate code for it
2177 2178
2178 cfg.Estimate_Block_Frequency(); 2179 cfg.Estimate_Block_Frequency();
2179 cfg.GlobalCodeMotion(m,unique(),proj_list); 2180 cfg.GlobalCodeMotion(m,unique(),proj_list);
2180 if (failing()) return; 2181 if (failing()) return;
2181 2182
2182 print_method("Global code motion", 2); 2183 print_method(PHASE_GLOBAL_CODE_MOTION, 2);
2183 2184
2184 NOT_PRODUCT( verify_graph_edges(); ) 2185 NOT_PRODUCT( verify_graph_edges(); )
2185 2186
2186 debug_only( cfg.verify(); ) 2187 debug_only( cfg.verify(); )
2187 } 2188 }
2230 TracePhase t2a("output", &_t_output, true); 2231 TracePhase t2a("output", &_t_output, true);
2231 NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); ) 2232 NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); )
2232 Output(); 2233 Output();
2233 } 2234 }
2234 2235
2235 print_method("Final Code"); 2236 print_method(PHASE_FINAL_CODE);
2236 2237
2237 // He's dead, Jim. 2238 // He's dead, Jim.
2238 _cfg = (PhaseCFG*)0xdeadbeef; 2239 _cfg = (PhaseCFG*)0xdeadbeef;
2239 _regalloc = (PhaseChaitin*)0xdeadbeef; 2240 _regalloc = (PhaseChaitin*)0xdeadbeef;
2240 } 2241 }
3317 } 3318 }
3318 if (_failure_reason == NULL) { 3319 if (_failure_reason == NULL) {
3319 // Record the first failure reason. 3320 // Record the first failure reason.
3320 _failure_reason = reason; 3321 _failure_reason = reason;
3321 } 3322 }
3323
3324 EventCompilerFailure event;
3325 if (event.should_commit()) {
3326 event.set_compileID(Compile::compile_id());
3327 event.set_failure(reason);
3328 event.commit();
3329 }
3330
3322 if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) { 3331 if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) {
3323 C->print_method(_failure_reason); 3332 C->print_method(PHASE_FAILURE);
3324 } 3333 }
3325 _root = NULL; // flush the graph, too 3334 _root = NULL; // flush the graph, too
3326 } 3335 }
3327 3336
3328 Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog) 3337 Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog)