Mercurial > hg > truffle
comparison src/share/vm/opto/compile.cpp @ 10405:f2110083203d
8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author | sla |
---|---|
date | Mon, 10 Jun 2013 11:30:51 +0200 |
parents | 6f3fd5150b67 |
children | d1034bd8cefc b5c8a61d7fa0 |
comparison
equal
deleted
inserted
replaced
10404:d0add7016434 | 10405:f2110083203d |
---|---|
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 |
784 inline_string_calls(true); | 785 inline_string_calls(true); |
785 } | 786 } |
786 | 787 |
787 if (failing()) return; | 788 if (failing()) return; |
788 | 789 |
789 print_method("Before RemoveUseless", 3); | 790 print_method(PHASE_BEFORE_REMOVEUSELESS, 3); |
790 | 791 |
791 // Remove clutter produced by parsing. | 792 // Remove clutter produced by parsing. |
792 if (!failing()) { | 793 if (!failing()) { |
793 ResourceMark rm; | 794 ResourceMark rm; |
794 PhaseRemoveUseless pru(initial_gvn(), &for_igvn); | 795 PhaseRemoveUseless pru(initial_gvn(), &for_igvn); |
1799 PhaseRemoveUseless pru(initial_gvn(), for_igvn()); | 1800 PhaseRemoveUseless pru(initial_gvn(), for_igvn()); |
1800 } | 1801 } |
1801 | 1802 |
1802 { | 1803 { |
1803 ResourceMark rm; | 1804 ResourceMark rm; |
1804 print_method("Before StringOpts", 3); | 1805 print_method(PHASE_BEFORE_STRINGOPTS, 3); |
1805 PhaseStringOpts pso(initial_gvn(), for_igvn()); | 1806 PhaseStringOpts pso(initial_gvn(), for_igvn()); |
1806 print_method("After StringOpts", 3); | 1807 print_method(PHASE_AFTER_STRINGOPTS, 3); |
1807 } | 1808 } |
1808 | 1809 |
1809 // now inline anything that we skipped the first time around | 1810 // now inline anything that we skipped the first time around |
1810 if (!parse_time) { | 1811 if (!parse_time) { |
1811 _late_inlines_pos = _late_inlines.length(); | 1812 _late_inlines_pos = _late_inlines.length(); |
1956 ResourceMark rm; | 1957 ResourceMark rm; |
1957 int loop_opts_cnt; | 1958 int loop_opts_cnt; |
1958 | 1959 |
1959 NOT_PRODUCT( verify_graph_edges(); ) | 1960 NOT_PRODUCT( verify_graph_edges(); ) |
1960 | 1961 |
1961 print_method("After Parsing"); | 1962 print_method(PHASE_AFTER_PARSING); |
1962 | 1963 |
1963 { | 1964 { |
1964 // Iterative Global Value Numbering, including ideal transforms | 1965 // Iterative Global Value Numbering, including ideal transforms |
1965 // Initialize IterGVN with types and values from parse-time GVN | 1966 // Initialize IterGVN with types and values from parse-time GVN |
1966 PhaseIterGVN igvn(initial_gvn()); | 1967 PhaseIterGVN igvn(initial_gvn()); |
1967 { | 1968 { |
1968 NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); ) | 1969 NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); ) |
1969 igvn.optimize(); | 1970 igvn.optimize(); |
1970 } | 1971 } |
1971 | 1972 |
1972 print_method("Iter GVN 1", 2); | 1973 print_method(PHASE_ITER_GVN1, 2); |
1973 | 1974 |
1974 if (failing()) return; | 1975 if (failing()) return; |
1975 | 1976 |
1976 { | 1977 { |
1977 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) | 1978 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) |
1978 inline_incrementally(igvn); | 1979 inline_incrementally(igvn); |
1979 } | 1980 } |
1980 | 1981 |
1981 print_method("Incremental Inline", 2); | 1982 print_method(PHASE_INCREMENTAL_INLINE, 2); |
1982 | 1983 |
1983 if (failing()) return; | 1984 if (failing()) return; |
1984 | 1985 |
1985 if (eliminate_boxing()) { | 1986 if (eliminate_boxing()) { |
1986 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) | 1987 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) |
1987 // Inline valueOf() methods now. | 1988 // Inline valueOf() methods now. |
1988 inline_boxing_calls(igvn); | 1989 inline_boxing_calls(igvn); |
1989 | 1990 |
1990 print_method("Incremental Boxing Inline", 2); | 1991 print_method(PHASE_INCREMENTAL_BOXING_INLINE, 2); |
1991 | 1992 |
1992 if (failing()) return; | 1993 if (failing()) return; |
1993 } | 1994 } |
1994 | 1995 |
1995 // No more new expensive nodes will be added to the list from here | 1996 // No more new expensive nodes will be added to the list from here |
2000 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) { | 2001 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) { |
2001 if (has_loops()) { | 2002 if (has_loops()) { |
2002 // Cleanup graph (remove dead nodes). | 2003 // Cleanup graph (remove dead nodes). |
2003 TracePhase t2("idealLoop", &_t_idealLoop, true); | 2004 TracePhase t2("idealLoop", &_t_idealLoop, true); |
2004 PhaseIdealLoop ideal_loop( igvn, false, true ); | 2005 PhaseIdealLoop ideal_loop( igvn, false, true ); |
2005 if (major_progress()) print_method("PhaseIdealLoop before EA", 2); | 2006 if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2); |
2006 if (failing()) return; | 2007 if (failing()) return; |
2007 } | 2008 } |
2008 ConnectionGraph::do_analysis(this, &igvn); | 2009 ConnectionGraph::do_analysis(this, &igvn); |
2009 | 2010 |
2010 if (failing()) return; | 2011 if (failing()) return; |
2011 | 2012 |
2012 // Optimize out fields loads from scalar replaceable allocations. | 2013 // Optimize out fields loads from scalar replaceable allocations. |
2013 igvn.optimize(); | 2014 igvn.optimize(); |
2014 print_method("Iter GVN after EA", 2); | 2015 print_method(PHASE_ITER_GVN_AFTER_EA, 2); |
2015 | 2016 |
2016 if (failing()) return; | 2017 if (failing()) return; |
2017 | 2018 |
2018 if (congraph() != NULL && macro_count() > 0) { | 2019 if (congraph() != NULL && macro_count() > 0) { |
2019 NOT_PRODUCT( TracePhase t2("macroEliminate", &_t_macroEliminate, TimeCompiler); ) | 2020 NOT_PRODUCT( TracePhase t2("macroEliminate", &_t_macroEliminate, TimeCompiler); ) |
2020 PhaseMacroExpand mexp(igvn); | 2021 PhaseMacroExpand mexp(igvn); |
2021 mexp.eliminate_macro_nodes(); | 2022 mexp.eliminate_macro_nodes(); |
2022 igvn.set_delay_transform(false); | 2023 igvn.set_delay_transform(false); |
2023 | 2024 |
2024 igvn.optimize(); | 2025 igvn.optimize(); |
2025 print_method("Iter GVN after eliminating allocations and locks", 2); | 2026 print_method(PHASE_ITER_GVN_AFTER_ELIMINATION, 2); |
2026 | 2027 |
2027 if (failing()) return; | 2028 if (failing()) return; |
2028 } | 2029 } |
2029 } | 2030 } |
2030 | 2031 |
2036 if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { | 2037 if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { |
2037 { | 2038 { |
2038 TracePhase t2("idealLoop", &_t_idealLoop, true); | 2039 TracePhase t2("idealLoop", &_t_idealLoop, true); |
2039 PhaseIdealLoop ideal_loop( igvn, true ); | 2040 PhaseIdealLoop ideal_loop( igvn, true ); |
2040 loop_opts_cnt--; | 2041 loop_opts_cnt--; |
2041 if (major_progress()) print_method("PhaseIdealLoop 1", 2); | 2042 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2); |
2042 if (failing()) return; | 2043 if (failing()) return; |
2043 } | 2044 } |
2044 // Loop opts pass if partial peeling occurred in previous pass | 2045 // Loop opts pass if partial peeling occurred in previous pass |
2045 if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) { | 2046 if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) { |
2046 TracePhase t3("idealLoop", &_t_idealLoop, true); | 2047 TracePhase t3("idealLoop", &_t_idealLoop, true); |
2047 PhaseIdealLoop ideal_loop( igvn, false ); | 2048 PhaseIdealLoop ideal_loop( igvn, false ); |
2048 loop_opts_cnt--; | 2049 loop_opts_cnt--; |
2049 if (major_progress()) print_method("PhaseIdealLoop 2", 2); | 2050 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2); |
2050 if (failing()) return; | 2051 if (failing()) return; |
2051 } | 2052 } |
2052 // Loop opts pass for loop-unrolling before CCP | 2053 // Loop opts pass for loop-unrolling before CCP |
2053 if(major_progress() && (loop_opts_cnt > 0)) { | 2054 if(major_progress() && (loop_opts_cnt > 0)) { |
2054 TracePhase t4("idealLoop", &_t_idealLoop, true); | 2055 TracePhase t4("idealLoop", &_t_idealLoop, true); |
2055 PhaseIdealLoop ideal_loop( igvn, false ); | 2056 PhaseIdealLoop ideal_loop( igvn, false ); |
2056 loop_opts_cnt--; | 2057 loop_opts_cnt--; |
2057 if (major_progress()) print_method("PhaseIdealLoop 3", 2); | 2058 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2); |
2058 } | 2059 } |
2059 if (!failing()) { | 2060 if (!failing()) { |
2060 // Verify that last round of loop opts produced a valid graph | 2061 // Verify that last round of loop opts produced a valid graph |
2061 NOT_PRODUCT( TracePhase t2("idealLoopVerify", &_t_idealLoopVerify, TimeCompiler); ) | 2062 NOT_PRODUCT( TracePhase t2("idealLoopVerify", &_t_idealLoopVerify, TimeCompiler); ) |
2062 PhaseIdealLoop::verify(igvn); | 2063 PhaseIdealLoop::verify(igvn); |
2069 assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)"); | 2070 assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)"); |
2070 { | 2071 { |
2071 TracePhase t2("ccp", &_t_ccp, true); | 2072 TracePhase t2("ccp", &_t_ccp, true); |
2072 ccp.do_transform(); | 2073 ccp.do_transform(); |
2073 } | 2074 } |
2074 print_method("PhaseCPP 1", 2); | 2075 print_method(PHASE_CPP1, 2); |
2075 | 2076 |
2076 assert( true, "Break here to ccp.dump_old2new_map()"); | 2077 assert( true, "Break here to ccp.dump_old2new_map()"); |
2077 | 2078 |
2078 // Iterative Global Value Numbering, including ideal transforms | 2079 // Iterative Global Value Numbering, including ideal transforms |
2079 { | 2080 { |
2080 NOT_PRODUCT( TracePhase t2("iterGVN2", &_t_iterGVN2, TimeCompiler); ) | 2081 NOT_PRODUCT( TracePhase t2("iterGVN2", &_t_iterGVN2, TimeCompiler); ) |
2081 igvn = ccp; | 2082 igvn = ccp; |
2082 igvn.optimize(); | 2083 igvn.optimize(); |
2083 } | 2084 } |
2084 | 2085 |
2085 print_method("Iter GVN 2", 2); | 2086 print_method(PHASE_ITER_GVN2, 2); |
2086 | 2087 |
2087 if (failing()) return; | 2088 if (failing()) return; |
2088 | 2089 |
2089 // Loop transforms on the ideal graph. Range Check Elimination, | 2090 // Loop transforms on the ideal graph. Range Check Elimination, |
2090 // peeling, unrolling, etc. | 2091 // peeling, unrolling, etc. |
2093 while(major_progress() && (loop_opts_cnt > 0)) { | 2094 while(major_progress() && (loop_opts_cnt > 0)) { |
2094 TracePhase t2("idealLoop", &_t_idealLoop, true); | 2095 TracePhase t2("idealLoop", &_t_idealLoop, true); |
2095 assert( cnt++ < 40, "infinite cycle in loop optimization" ); | 2096 assert( cnt++ < 40, "infinite cycle in loop optimization" ); |
2096 PhaseIdealLoop ideal_loop( igvn, true); | 2097 PhaseIdealLoop ideal_loop( igvn, true); |
2097 loop_opts_cnt--; | 2098 loop_opts_cnt--; |
2098 if (major_progress()) print_method("PhaseIdealLoop iterations", 2); | 2099 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); |
2099 if (failing()) return; | 2100 if (failing()) return; |
2100 } | 2101 } |
2101 } | 2102 } |
2102 | 2103 |
2103 { | 2104 { |
2126 assert(failing(), "must bail out w/ explicit message"); | 2127 assert(failing(), "must bail out w/ explicit message"); |
2127 return; | 2128 return; |
2128 } | 2129 } |
2129 } | 2130 } |
2130 | 2131 |
2131 print_method("Optimize finished", 2); | 2132 print_method(PHASE_OPTIMIZE_FINISHED, 2); |
2132 } | 2133 } |
2133 | 2134 |
2134 | 2135 |
2135 //------------------------------Code_Gen--------------------------------------- | 2136 //------------------------------Code_Gen--------------------------------------- |
2136 // Given a graph, generate code for it | 2137 // Given a graph, generate code for it |
2174 | 2175 |
2175 cfg.Estimate_Block_Frequency(); | 2176 cfg.Estimate_Block_Frequency(); |
2176 cfg.GlobalCodeMotion(m,unique(),proj_list); | 2177 cfg.GlobalCodeMotion(m,unique(),proj_list); |
2177 if (failing()) return; | 2178 if (failing()) return; |
2178 | 2179 |
2179 print_method("Global code motion", 2); | 2180 print_method(PHASE_GLOBAL_CODE_MOTION, 2); |
2180 | 2181 |
2181 NOT_PRODUCT( verify_graph_edges(); ) | 2182 NOT_PRODUCT( verify_graph_edges(); ) |
2182 | 2183 |
2183 debug_only( cfg.verify(); ) | 2184 debug_only( cfg.verify(); ) |
2184 } | 2185 } |
2227 TracePhase t2a("output", &_t_output, true); | 2228 TracePhase t2a("output", &_t_output, true); |
2228 NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); ) | 2229 NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); ) |
2229 Output(); | 2230 Output(); |
2230 } | 2231 } |
2231 | 2232 |
2232 print_method("Final Code"); | 2233 print_method(PHASE_FINAL_CODE); |
2233 | 2234 |
2234 // He's dead, Jim. | 2235 // He's dead, Jim. |
2235 _cfg = (PhaseCFG*)0xdeadbeef; | 2236 _cfg = (PhaseCFG*)0xdeadbeef; |
2236 _regalloc = (PhaseChaitin*)0xdeadbeef; | 2237 _regalloc = (PhaseChaitin*)0xdeadbeef; |
2237 } | 2238 } |
3314 } | 3315 } |
3315 if (_failure_reason == NULL) { | 3316 if (_failure_reason == NULL) { |
3316 // Record the first failure reason. | 3317 // Record the first failure reason. |
3317 _failure_reason = reason; | 3318 _failure_reason = reason; |
3318 } | 3319 } |
3320 | |
3321 EventCompilerFailure event; | |
3322 if (event.should_commit()) { | |
3323 event.set_compileID(Compile::compile_id()); | |
3324 event.set_failure(reason); | |
3325 event.commit(); | |
3326 } | |
3327 | |
3319 if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) { | 3328 if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) { |
3320 C->print_method(_failure_reason); | 3329 C->print_method(PHASE_FAILURE); |
3321 } | 3330 } |
3322 _root = NULL; // flush the graph, too | 3331 _root = NULL; // flush the graph, too |
3323 } | 3332 } |
3324 | 3333 |
3325 Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog) | 3334 Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog) |