src/share/vm/opto/compile.cpp

Print this page
rev 4773 : 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>

*** 1,7 **** /* ! * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 61,70 **** --- 61,71 ---- #include "opto/vectornode.hpp" #include "runtime/arguments.hpp" #include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/timer.hpp" + #include "trace/tracing.hpp" #include "utilities/copy.hpp" #ifdef TARGET_ARCH_MODEL_x86_32 # include "adfiles/ad_x86_32.hpp" #endif #ifdef TARGET_ARCH_MODEL_x86_64
*** 784,794 **** inline_string_calls(true); } if (failing()) return; ! print_method("Before RemoveUseless", 3); // Remove clutter produced by parsing. if (!failing()) { ResourceMark rm; PhaseRemoveUseless pru(initial_gvn(), &for_igvn); --- 785,795 ---- inline_string_calls(true); } if (failing()) return; ! print_method(PHASE_BEFORE_REMOVEUSELESS, 3); // Remove clutter produced by parsing. if (!failing()) { ResourceMark rm; PhaseRemoveUseless pru(initial_gvn(), &for_igvn);
*** 1799,1811 **** PhaseRemoveUseless pru(initial_gvn(), for_igvn()); } { ResourceMark rm; ! print_method("Before StringOpts", 3); PhaseStringOpts pso(initial_gvn(), for_igvn()); ! print_method("After StringOpts", 3); } // now inline anything that we skipped the first time around if (!parse_time) { _late_inlines_pos = _late_inlines.length(); --- 1800,1812 ---- PhaseRemoveUseless pru(initial_gvn(), for_igvn()); } { ResourceMark rm; ! print_method(PHASE_BEFORE_STRINGOPTS, 3); PhaseStringOpts pso(initial_gvn(), for_igvn()); ! print_method(PHASE_AFTER_STRINGOPTS, 3); } // now inline anything that we skipped the first time around if (!parse_time) { _late_inlines_pos = _late_inlines.length();
*** 1956,1995 **** ResourceMark rm; int loop_opts_cnt; NOT_PRODUCT( verify_graph_edges(); ) ! print_method("After Parsing"); { // Iterative Global Value Numbering, including ideal transforms // Initialize IterGVN with types and values from parse-time GVN PhaseIterGVN igvn(initial_gvn()); { NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); ) igvn.optimize(); } ! print_method("Iter GVN 1", 2); if (failing()) return; { NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) inline_incrementally(igvn); } ! print_method("Incremental Inline", 2); if (failing()) return; if (eliminate_boxing()) { NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) // Inline valueOf() methods now. inline_boxing_calls(igvn); ! print_method("Incremental Boxing Inline", 2); if (failing()) return; } // No more new expensive nodes will be added to the list from here --- 1957,1996 ---- ResourceMark rm; int loop_opts_cnt; NOT_PRODUCT( verify_graph_edges(); ) ! print_method(PHASE_AFTER_PARSING); { // Iterative Global Value Numbering, including ideal transforms // Initialize IterGVN with types and values from parse-time GVN PhaseIterGVN igvn(initial_gvn()); { NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); ) igvn.optimize(); } ! print_method(PHASE_ITER_GVN1, 2); if (failing()) return; { NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) inline_incrementally(igvn); } ! print_method(PHASE_INCREMENTAL_INLINE, 2); if (failing()) return; if (eliminate_boxing()) { NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) // Inline valueOf() methods now. inline_boxing_calls(igvn); ! print_method(PHASE_INCREMENTAL_BOXING_INLINE, 2); if (failing()) return; } // No more new expensive nodes will be added to the list from here
*** 2000,2030 **** if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) { if (has_loops()) { // Cleanup graph (remove dead nodes). TracePhase t2("idealLoop", &_t_idealLoop, true); PhaseIdealLoop ideal_loop( igvn, false, true ); ! if (major_progress()) print_method("PhaseIdealLoop before EA", 2); if (failing()) return; } ConnectionGraph::do_analysis(this, &igvn); if (failing()) return; // Optimize out fields loads from scalar replaceable allocations. igvn.optimize(); ! print_method("Iter GVN after EA", 2); if (failing()) return; if (congraph() != NULL && macro_count() > 0) { NOT_PRODUCT( TracePhase t2("macroEliminate", &_t_macroEliminate, TimeCompiler); ) PhaseMacroExpand mexp(igvn); mexp.eliminate_macro_nodes(); igvn.set_delay_transform(false); igvn.optimize(); ! print_method("Iter GVN after eliminating allocations and locks", 2); if (failing()) return; } } --- 2001,2031 ---- if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) { if (has_loops()) { // Cleanup graph (remove dead nodes). TracePhase t2("idealLoop", &_t_idealLoop, true); PhaseIdealLoop ideal_loop( igvn, false, true ); ! if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2); if (failing()) return; } ConnectionGraph::do_analysis(this, &igvn); if (failing()) return; // Optimize out fields loads from scalar replaceable allocations. igvn.optimize(); ! print_method(PHASE_ITER_GVN_AFTER_EA, 2); if (failing()) return; if (congraph() != NULL && macro_count() > 0) { NOT_PRODUCT( TracePhase t2("macroEliminate", &_t_macroEliminate, TimeCompiler); ) PhaseMacroExpand mexp(igvn); mexp.eliminate_macro_nodes(); igvn.set_delay_transform(false); igvn.optimize(); ! print_method(PHASE_ITER_GVN_AFTER_ELIMINATION, 2); if (failing()) return; } }
*** 2036,2062 **** if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { { TracePhase t2("idealLoop", &_t_idealLoop, true); PhaseIdealLoop ideal_loop( igvn, true ); loop_opts_cnt--; ! if (major_progress()) print_method("PhaseIdealLoop 1", 2); if (failing()) return; } // Loop opts pass if partial peeling occurred in previous pass if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) { TracePhase t3("idealLoop", &_t_idealLoop, true); PhaseIdealLoop ideal_loop( igvn, false ); loop_opts_cnt--; ! if (major_progress()) print_method("PhaseIdealLoop 2", 2); if (failing()) return; } // Loop opts pass for loop-unrolling before CCP if(major_progress() && (loop_opts_cnt > 0)) { TracePhase t4("idealLoop", &_t_idealLoop, true); PhaseIdealLoop ideal_loop( igvn, false ); loop_opts_cnt--; ! if (major_progress()) print_method("PhaseIdealLoop 3", 2); } if (!failing()) { // Verify that last round of loop opts produced a valid graph NOT_PRODUCT( TracePhase t2("idealLoopVerify", &_t_idealLoopVerify, TimeCompiler); ) PhaseIdealLoop::verify(igvn); --- 2037,2063 ---- if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { { TracePhase t2("idealLoop", &_t_idealLoop, true); PhaseIdealLoop ideal_loop( igvn, true ); loop_opts_cnt--; ! if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2); if (failing()) return; } // Loop opts pass if partial peeling occurred in previous pass if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) { TracePhase t3("idealLoop", &_t_idealLoop, true); PhaseIdealLoop ideal_loop( igvn, false ); loop_opts_cnt--; ! if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2); if (failing()) return; } // Loop opts pass for loop-unrolling before CCP if(major_progress() && (loop_opts_cnt > 0)) { TracePhase t4("idealLoop", &_t_idealLoop, true); PhaseIdealLoop ideal_loop( igvn, false ); loop_opts_cnt--; ! if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2); } if (!failing()) { // Verify that last round of loop opts produced a valid graph NOT_PRODUCT( TracePhase t2("idealLoopVerify", &_t_idealLoopVerify, TimeCompiler); ) PhaseIdealLoop::verify(igvn);
*** 2069,2090 **** assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)"); { TracePhase t2("ccp", &_t_ccp, true); ccp.do_transform(); } ! print_method("PhaseCPP 1", 2); assert( true, "Break here to ccp.dump_old2new_map()"); // Iterative Global Value Numbering, including ideal transforms { NOT_PRODUCT( TracePhase t2("iterGVN2", &_t_iterGVN2, TimeCompiler); ) igvn = ccp; igvn.optimize(); } ! print_method("Iter GVN 2", 2); if (failing()) return; // Loop transforms on the ideal graph. Range Check Elimination, // peeling, unrolling, etc. --- 2070,2091 ---- assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)"); { TracePhase t2("ccp", &_t_ccp, true); ccp.do_transform(); } ! print_method(PHASE_CPP1, 2); assert( true, "Break here to ccp.dump_old2new_map()"); // Iterative Global Value Numbering, including ideal transforms { NOT_PRODUCT( TracePhase t2("iterGVN2", &_t_iterGVN2, TimeCompiler); ) igvn = ccp; igvn.optimize(); } ! print_method(PHASE_ITER_GVN2, 2); if (failing()) return; // Loop transforms on the ideal graph. Range Check Elimination, // peeling, unrolling, etc.
*** 2093,2103 **** while(major_progress() && (loop_opts_cnt > 0)) { TracePhase t2("idealLoop", &_t_idealLoop, true); assert( cnt++ < 40, "infinite cycle in loop optimization" ); PhaseIdealLoop ideal_loop( igvn, true); loop_opts_cnt--; ! if (major_progress()) print_method("PhaseIdealLoop iterations", 2); if (failing()) return; } } { --- 2094,2104 ---- while(major_progress() && (loop_opts_cnt > 0)) { TracePhase t2("idealLoop", &_t_idealLoop, true); assert( cnt++ < 40, "infinite cycle in loop optimization" ); PhaseIdealLoop ideal_loop( igvn, true); loop_opts_cnt--; ! if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); if (failing()) return; } } {
*** 2126,2136 **** assert(failing(), "must bail out w/ explicit message"); return; } } ! print_method("Optimize finished", 2); } //------------------------------Code_Gen--------------------------------------- // Given a graph, generate code for it --- 2127,2137 ---- assert(failing(), "must bail out w/ explicit message"); return; } } ! print_method(PHASE_OPTIMIZE_FINISHED, 2); } //------------------------------Code_Gen--------------------------------------- // Given a graph, generate code for it
*** 2174,2184 **** cfg.Estimate_Block_Frequency(); cfg.GlobalCodeMotion(m,unique(),proj_list); if (failing()) return; ! print_method("Global code motion", 2); NOT_PRODUCT( verify_graph_edges(); ) debug_only( cfg.verify(); ) } --- 2175,2185 ---- cfg.Estimate_Block_Frequency(); cfg.GlobalCodeMotion(m,unique(),proj_list); if (failing()) return; ! print_method(PHASE_GLOBAL_CODE_MOTION, 2); NOT_PRODUCT( verify_graph_edges(); ) debug_only( cfg.verify(); ) }
*** 2227,2237 **** TracePhase t2a("output", &_t_output, true); NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); ) Output(); } ! print_method("Final Code"); // He's dead, Jim. _cfg = (PhaseCFG*)0xdeadbeef; _regalloc = (PhaseChaitin*)0xdeadbeef; } --- 2228,2238 ---- TracePhase t2a("output", &_t_output, true); NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); ) Output(); } ! print_method(PHASE_FINAL_CODE); // He's dead, Jim. _cfg = (PhaseCFG*)0xdeadbeef; _regalloc = (PhaseChaitin*)0xdeadbeef; }
*** 3314,3325 **** } if (_failure_reason == NULL) { // Record the first failure reason. _failure_reason = reason; } if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) { ! C->print_method(_failure_reason); } _root = NULL; // flush the graph, too } Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog) --- 3315,3334 ---- } if (_failure_reason == NULL) { // Record the first failure reason. _failure_reason = reason; } + + EventCompilerFailure event; + if (event.should_commit()) { + event.set_compileID(Compile::compile_id()); + event.set_failure(reason); + event.commit(); + } + if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) { ! C->print_method(PHASE_FAILURE); } _root = NULL; // flush the graph, too } Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog)