annotate src/share/vm/opto/phase.cpp @ 418:72c5366e5d86

6743900: frequency based block layout Summary: post-register allocation pass that drives block layout by edge frequencies Reviewed-by: never, kvn
author rasbold
date Thu, 06 Nov 2008 14:59:10 -0800
parents a61af66fc99e
children ad8c8ca4ab0f
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 #include "incls/_precompiled.incl"
duke@0 26 #include "incls/_phase.cpp.incl"
duke@0 27
duke@0 28 #ifndef PRODUCT
duke@0 29 int Phase::_total_bytes_compiled = 0;
duke@0 30
duke@0 31 elapsedTimer Phase::_t_totalCompilation;
duke@0 32 elapsedTimer Phase::_t_methodCompilation;
duke@0 33 elapsedTimer Phase::_t_stubCompilation;
duke@0 34 #endif
duke@0 35
duke@0 36 // The next timers used for LogCompilation
duke@0 37 elapsedTimer Phase::_t_parser;
duke@0 38 elapsedTimer Phase::_t_escapeAnalysis;
duke@0 39 elapsedTimer Phase::_t_optimizer;
duke@0 40 elapsedTimer Phase::_t_idealLoop;
duke@0 41 elapsedTimer Phase::_t_ccp;
duke@0 42 elapsedTimer Phase::_t_matcher;
duke@0 43 elapsedTimer Phase::_t_registerAllocation;
duke@0 44 elapsedTimer Phase::_t_output;
duke@0 45
duke@0 46 #ifndef PRODUCT
duke@0 47 elapsedTimer Phase::_t_graphReshaping;
duke@0 48 elapsedTimer Phase::_t_scheduler;
rasbold@418 49 elapsedTimer Phase::_t_blockOrdering;
duke@0 50 elapsedTimer Phase::_t_macroExpand;
duke@0 51 elapsedTimer Phase::_t_peephole;
duke@0 52 elapsedTimer Phase::_t_codeGeneration;
duke@0 53 elapsedTimer Phase::_t_registerMethod;
duke@0 54 elapsedTimer Phase::_t_temporaryTimer1;
duke@0 55 elapsedTimer Phase::_t_temporaryTimer2;
duke@0 56
duke@0 57 // Subtimers for _t_optimizer
duke@0 58 elapsedTimer Phase::_t_iterGVN;
duke@0 59 elapsedTimer Phase::_t_iterGVN2;
duke@0 60
duke@0 61 // Subtimers for _t_registerAllocation
duke@0 62 elapsedTimer Phase::_t_ctorChaitin;
duke@0 63 elapsedTimer Phase::_t_buildIFGphysical;
duke@0 64 elapsedTimer Phase::_t_computeLive;
duke@0 65 elapsedTimer Phase::_t_regAllocSplit;
duke@0 66 elapsedTimer Phase::_t_postAllocCopyRemoval;
duke@0 67 elapsedTimer Phase::_t_fixupSpills;
duke@0 68
duke@0 69 // Subtimers for _t_output
duke@0 70 elapsedTimer Phase::_t_instrSched;
duke@0 71 elapsedTimer Phase::_t_buildOopMaps;
duke@0 72 #endif
duke@0 73
duke@0 74 //------------------------------Phase------------------------------------------
duke@0 75 Phase::Phase( PhaseNumber pnum ) : _pnum(pnum), C( pnum == Compiler ? NULL : Compile::current()) {
duke@0 76 // Poll for requests from shutdown mechanism to quiesce comiler (4448539, 4448544).
duke@0 77 // This is an effective place to poll, since the compiler is full of phases.
duke@0 78 // In particular, every inlining site uses a recursively created Parse phase.
duke@0 79 CompileBroker::maybe_block();
duke@0 80 }
duke@0 81
duke@0 82 #ifndef PRODUCT
duke@0 83 static const double minimum_reported_time = 0.0001; // seconds
duke@0 84 static const double expected_method_compile_coverage = 0.97; // %
duke@0 85 static const double minimum_meaningful_method_compile = 2.00; // seconds
duke@0 86
duke@0 87 void Phase::print_timers() {
duke@0 88 tty->print_cr ("Accumulated compiler times:");
duke@0 89 tty->print_cr ("---------------------------");
duke@0 90 tty->print_cr (" Total compilation: %3.3f sec.", Phase::_t_totalCompilation.seconds());
duke@0 91 tty->print (" method compilation : %3.3f sec", Phase::_t_methodCompilation.seconds());
duke@0 92 tty->print ("/%d bytes",_total_bytes_compiled);
duke@0 93 tty->print_cr (" (%3.0f bytes per sec) ", Phase::_total_bytes_compiled / Phase::_t_methodCompilation.seconds());
duke@0 94 tty->print_cr (" stub compilation : %3.3f sec.", Phase::_t_stubCompilation.seconds());
duke@0 95 tty->print_cr (" Phases:");
duke@0 96 tty->print_cr (" parse : %3.3f sec", Phase::_t_parser.seconds());
duke@0 97 if (DoEscapeAnalysis) {
duke@0 98 tty->print_cr (" escape analysis : %3.3f sec", Phase::_t_escapeAnalysis.seconds());
duke@0 99 }
duke@0 100 tty->print_cr (" optimizer : %3.3f sec", Phase::_t_optimizer.seconds());
duke@0 101 if( Verbose || WizardMode ) {
duke@0 102 tty->print_cr (" iterGVN : %3.3f sec", Phase::_t_iterGVN.seconds());
duke@0 103 tty->print_cr (" idealLoop : %3.3f sec", Phase::_t_idealLoop.seconds());
duke@0 104 tty->print_cr (" ccp : %3.3f sec", Phase::_t_ccp.seconds());
duke@0 105 tty->print_cr (" iterGVN2 : %3.3f sec", Phase::_t_iterGVN2.seconds());
duke@0 106 tty->print_cr (" graphReshape : %3.3f sec", Phase::_t_graphReshaping.seconds());
duke@0 107 double optimizer_subtotal = Phase::_t_iterGVN.seconds() +
duke@0 108 Phase::_t_idealLoop.seconds() + Phase::_t_ccp.seconds() +
duke@0 109 Phase::_t_graphReshaping.seconds();
duke@0 110 double percent_of_optimizer = ((optimizer_subtotal == 0.0) ? 0.0 : (optimizer_subtotal / Phase::_t_optimizer.seconds() * 100.0));
duke@0 111 tty->print_cr (" subtotal : %3.3f sec, %3.2f %%", optimizer_subtotal, percent_of_optimizer);
duke@0 112 }
duke@0 113 tty->print_cr (" matcher : %3.3f sec", Phase::_t_matcher.seconds());
duke@0 114 tty->print_cr (" scheduler : %3.3f sec", Phase::_t_scheduler.seconds());
duke@0 115 tty->print_cr (" regalloc : %3.3f sec", Phase::_t_registerAllocation.seconds());
duke@0 116 if( Verbose || WizardMode ) {
duke@0 117 tty->print_cr (" ctorChaitin : %3.3f sec", Phase::_t_ctorChaitin.seconds());
duke@0 118 tty->print_cr (" buildIFG : %3.3f sec", Phase::_t_buildIFGphysical.seconds());
duke@0 119 tty->print_cr (" computeLive : %3.3f sec", Phase::_t_computeLive.seconds());
duke@0 120 tty->print_cr (" regAllocSplit: %3.3f sec", Phase::_t_regAllocSplit.seconds());
duke@0 121 tty->print_cr (" postAllocCopyRemoval: %3.3f sec", Phase::_t_postAllocCopyRemoval.seconds());
duke@0 122 tty->print_cr (" fixupSpills : %3.3f sec", Phase::_t_fixupSpills.seconds());
duke@0 123 double regalloc_subtotal = Phase::_t_ctorChaitin.seconds() +
duke@0 124 Phase::_t_buildIFGphysical.seconds() + Phase::_t_computeLive.seconds() +
duke@0 125 Phase::_t_regAllocSplit.seconds() + Phase::_t_fixupSpills.seconds() +
duke@0 126 Phase::_t_postAllocCopyRemoval.seconds();
duke@0 127 double percent_of_regalloc = ((regalloc_subtotal == 0.0) ? 0.0 : (regalloc_subtotal / Phase::_t_registerAllocation.seconds() * 100.0));
duke@0 128 tty->print_cr (" subtotal : %3.3f sec, %3.2f %%", regalloc_subtotal, percent_of_regalloc);
duke@0 129 }
duke@0 130 tty->print_cr (" macroExpand : %3.3f sec", Phase::_t_macroExpand.seconds());
rasbold@418 131 tty->print_cr (" blockOrdering: %3.3f sec", Phase::_t_blockOrdering.seconds());
duke@0 132 tty->print_cr (" peephole : %3.3f sec", Phase::_t_peephole.seconds());
duke@0 133 tty->print_cr (" codeGen : %3.3f sec", Phase::_t_codeGeneration.seconds());
duke@0 134 tty->print_cr (" install_code : %3.3f sec", Phase::_t_registerMethod.seconds());
duke@0 135 tty->print_cr (" ------------ : ----------");
duke@0 136 double phase_subtotal = Phase::_t_parser.seconds() +
duke@0 137 (DoEscapeAnalysis ? Phase::_t_escapeAnalysis.seconds() : 0.0) +
duke@0 138 Phase::_t_optimizer.seconds() + Phase::_t_graphReshaping.seconds() +
duke@0 139 Phase::_t_matcher.seconds() + Phase::_t_scheduler.seconds() +
rasbold@418 140 Phase::_t_registerAllocation.seconds() + Phase::_t_blockOrdering.seconds() +
duke@0 141 Phase::_t_macroExpand.seconds() + Phase::_t_peephole.seconds() +
duke@0 142 Phase::_t_codeGeneration.seconds() + Phase::_t_registerMethod.seconds();
duke@0 143 double percent_of_method_compile = ((phase_subtotal == 0.0) ? 0.0 : phase_subtotal / Phase::_t_methodCompilation.seconds()) * 100.0;
duke@0 144 // counters inside Compile::CodeGen include time for adapters and stubs
duke@0 145 // so phase-total can be greater than 100%
duke@0 146 tty->print_cr (" total : %3.3f sec, %3.2f %%", phase_subtotal, percent_of_method_compile);
duke@0 147
duke@0 148 assert( percent_of_method_compile > expected_method_compile_coverage ||
duke@0 149 phase_subtotal < minimum_meaningful_method_compile,
duke@0 150 "Must account for method compilation");
duke@0 151
duke@0 152 if( Phase::_t_temporaryTimer1.seconds() > minimum_reported_time ) {
duke@0 153 tty->cr();
duke@0 154 tty->print_cr (" temporaryTimer1: %3.3f sec", Phase::_t_temporaryTimer1.seconds());
duke@0 155 }
duke@0 156 if( Phase::_t_temporaryTimer2.seconds() > minimum_reported_time ) {
duke@0 157 tty->cr();
duke@0 158 tty->print_cr (" temporaryTimer2: %3.3f sec", Phase::_t_temporaryTimer2.seconds());
duke@0 159 }
duke@0 160 tty->print_cr (" output : %3.3f sec", Phase::_t_output.seconds());
duke@0 161 tty->print_cr (" isched : %3.3f sec", Phase::_t_instrSched.seconds());
duke@0 162 tty->print_cr (" bldOopMaps: %3.3f sec", Phase::_t_buildOopMaps.seconds());
duke@0 163 }
duke@0 164 #endif