1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/phase.cpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,164 @@ 1.4 +/* 1.5 + * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "incls/_precompiled.incl" 1.29 +#include "incls/_phase.cpp.incl" 1.30 + 1.31 +#ifndef PRODUCT 1.32 +int Phase::_total_bytes_compiled = 0; 1.33 + 1.34 +elapsedTimer Phase::_t_totalCompilation; 1.35 +elapsedTimer Phase::_t_methodCompilation; 1.36 +elapsedTimer Phase::_t_stubCompilation; 1.37 +#endif 1.38 + 1.39 +// The next timers used for LogCompilation 1.40 +elapsedTimer Phase::_t_parser; 1.41 +elapsedTimer Phase::_t_escapeAnalysis; 1.42 +elapsedTimer Phase::_t_optimizer; 1.43 +elapsedTimer Phase::_t_idealLoop; 1.44 +elapsedTimer Phase::_t_ccp; 1.45 +elapsedTimer Phase::_t_matcher; 1.46 +elapsedTimer Phase::_t_registerAllocation; 1.47 +elapsedTimer Phase::_t_output; 1.48 + 1.49 +#ifndef PRODUCT 1.50 +elapsedTimer Phase::_t_graphReshaping; 1.51 +elapsedTimer Phase::_t_scheduler; 1.52 +elapsedTimer Phase::_t_removeEmptyBlocks; 1.53 +elapsedTimer Phase::_t_macroExpand; 1.54 +elapsedTimer Phase::_t_peephole; 1.55 +elapsedTimer Phase::_t_codeGeneration; 1.56 +elapsedTimer Phase::_t_registerMethod; 1.57 +elapsedTimer Phase::_t_temporaryTimer1; 1.58 +elapsedTimer Phase::_t_temporaryTimer2; 1.59 + 1.60 +// Subtimers for _t_optimizer 1.61 +elapsedTimer Phase::_t_iterGVN; 1.62 +elapsedTimer Phase::_t_iterGVN2; 1.63 + 1.64 +// Subtimers for _t_registerAllocation 1.65 +elapsedTimer Phase::_t_ctorChaitin; 1.66 +elapsedTimer Phase::_t_buildIFGphysical; 1.67 +elapsedTimer Phase::_t_computeLive; 1.68 +elapsedTimer Phase::_t_regAllocSplit; 1.69 +elapsedTimer Phase::_t_postAllocCopyRemoval; 1.70 +elapsedTimer Phase::_t_fixupSpills; 1.71 + 1.72 +// Subtimers for _t_output 1.73 +elapsedTimer Phase::_t_instrSched; 1.74 +elapsedTimer Phase::_t_buildOopMaps; 1.75 +#endif 1.76 + 1.77 +//------------------------------Phase------------------------------------------ 1.78 +Phase::Phase( PhaseNumber pnum ) : _pnum(pnum), C( pnum == Compiler ? NULL : Compile::current()) { 1.79 + // Poll for requests from shutdown mechanism to quiesce comiler (4448539, 4448544). 1.80 + // This is an effective place to poll, since the compiler is full of phases. 1.81 + // In particular, every inlining site uses a recursively created Parse phase. 1.82 + CompileBroker::maybe_block(); 1.83 +} 1.84 + 1.85 +#ifndef PRODUCT 1.86 +static const double minimum_reported_time = 0.0001; // seconds 1.87 +static const double expected_method_compile_coverage = 0.97; // % 1.88 +static const double minimum_meaningful_method_compile = 2.00; // seconds 1.89 + 1.90 +void Phase::print_timers() { 1.91 + tty->print_cr ("Accumulated compiler times:"); 1.92 + tty->print_cr ("---------------------------"); 1.93 + tty->print_cr (" Total compilation: %3.3f sec.", Phase::_t_totalCompilation.seconds()); 1.94 + tty->print (" method compilation : %3.3f sec", Phase::_t_methodCompilation.seconds()); 1.95 + tty->print ("/%d bytes",_total_bytes_compiled); 1.96 + tty->print_cr (" (%3.0f bytes per sec) ", Phase::_total_bytes_compiled / Phase::_t_methodCompilation.seconds()); 1.97 + tty->print_cr (" stub compilation : %3.3f sec.", Phase::_t_stubCompilation.seconds()); 1.98 + tty->print_cr (" Phases:"); 1.99 + tty->print_cr (" parse : %3.3f sec", Phase::_t_parser.seconds()); 1.100 + if (DoEscapeAnalysis) { 1.101 + tty->print_cr (" escape analysis : %3.3f sec", Phase::_t_escapeAnalysis.seconds()); 1.102 + } 1.103 + tty->print_cr (" optimizer : %3.3f sec", Phase::_t_optimizer.seconds()); 1.104 + if( Verbose || WizardMode ) { 1.105 + tty->print_cr (" iterGVN : %3.3f sec", Phase::_t_iterGVN.seconds()); 1.106 + tty->print_cr (" idealLoop : %3.3f sec", Phase::_t_idealLoop.seconds()); 1.107 + tty->print_cr (" ccp : %3.3f sec", Phase::_t_ccp.seconds()); 1.108 + tty->print_cr (" iterGVN2 : %3.3f sec", Phase::_t_iterGVN2.seconds()); 1.109 + tty->print_cr (" graphReshape : %3.3f sec", Phase::_t_graphReshaping.seconds()); 1.110 + double optimizer_subtotal = Phase::_t_iterGVN.seconds() + 1.111 + Phase::_t_idealLoop.seconds() + Phase::_t_ccp.seconds() + 1.112 + Phase::_t_graphReshaping.seconds(); 1.113 + double percent_of_optimizer = ((optimizer_subtotal == 0.0) ? 0.0 : (optimizer_subtotal / Phase::_t_optimizer.seconds() * 100.0)); 1.114 + tty->print_cr (" subtotal : %3.3f sec, %3.2f %%", optimizer_subtotal, percent_of_optimizer); 1.115 + } 1.116 + tty->print_cr (" matcher : %3.3f sec", Phase::_t_matcher.seconds()); 1.117 + tty->print_cr (" scheduler : %3.3f sec", Phase::_t_scheduler.seconds()); 1.118 + tty->print_cr (" regalloc : %3.3f sec", Phase::_t_registerAllocation.seconds()); 1.119 + if( Verbose || WizardMode ) { 1.120 + tty->print_cr (" ctorChaitin : %3.3f sec", Phase::_t_ctorChaitin.seconds()); 1.121 + tty->print_cr (" buildIFG : %3.3f sec", Phase::_t_buildIFGphysical.seconds()); 1.122 + tty->print_cr (" computeLive : %3.3f sec", Phase::_t_computeLive.seconds()); 1.123 + tty->print_cr (" regAllocSplit: %3.3f sec", Phase::_t_regAllocSplit.seconds()); 1.124 + tty->print_cr (" postAllocCopyRemoval: %3.3f sec", Phase::_t_postAllocCopyRemoval.seconds()); 1.125 + tty->print_cr (" fixupSpills : %3.3f sec", Phase::_t_fixupSpills.seconds()); 1.126 + double regalloc_subtotal = Phase::_t_ctorChaitin.seconds() + 1.127 + Phase::_t_buildIFGphysical.seconds() + Phase::_t_computeLive.seconds() + 1.128 + Phase::_t_regAllocSplit.seconds() + Phase::_t_fixupSpills.seconds() + 1.129 + Phase::_t_postAllocCopyRemoval.seconds(); 1.130 + double percent_of_regalloc = ((regalloc_subtotal == 0.0) ? 0.0 : (regalloc_subtotal / Phase::_t_registerAllocation.seconds() * 100.0)); 1.131 + tty->print_cr (" subtotal : %3.3f sec, %3.2f %%", regalloc_subtotal, percent_of_regalloc); 1.132 + } 1.133 + tty->print_cr (" macroExpand : %3.3f sec", Phase::_t_macroExpand.seconds()); 1.134 + tty->print_cr (" removeEmpty : %3.3f sec", Phase::_t_removeEmptyBlocks.seconds()); 1.135 + tty->print_cr (" peephole : %3.3f sec", Phase::_t_peephole.seconds()); 1.136 + tty->print_cr (" codeGen : %3.3f sec", Phase::_t_codeGeneration.seconds()); 1.137 + tty->print_cr (" install_code : %3.3f sec", Phase::_t_registerMethod.seconds()); 1.138 + tty->print_cr (" ------------ : ----------"); 1.139 + double phase_subtotal = Phase::_t_parser.seconds() + 1.140 + (DoEscapeAnalysis ? Phase::_t_escapeAnalysis.seconds() : 0.0) + 1.141 + Phase::_t_optimizer.seconds() + Phase::_t_graphReshaping.seconds() + 1.142 + Phase::_t_matcher.seconds() + Phase::_t_scheduler.seconds() + 1.143 + Phase::_t_registerAllocation.seconds() + Phase::_t_removeEmptyBlocks.seconds() + 1.144 + Phase::_t_macroExpand.seconds() + Phase::_t_peephole.seconds() + 1.145 + Phase::_t_codeGeneration.seconds() + Phase::_t_registerMethod.seconds(); 1.146 + double percent_of_method_compile = ((phase_subtotal == 0.0) ? 0.0 : phase_subtotal / Phase::_t_methodCompilation.seconds()) * 100.0; 1.147 + // counters inside Compile::CodeGen include time for adapters and stubs 1.148 + // so phase-total can be greater than 100% 1.149 + tty->print_cr (" total : %3.3f sec, %3.2f %%", phase_subtotal, percent_of_method_compile); 1.150 + 1.151 + assert( percent_of_method_compile > expected_method_compile_coverage || 1.152 + phase_subtotal < minimum_meaningful_method_compile, 1.153 + "Must account for method compilation"); 1.154 + 1.155 + if( Phase::_t_temporaryTimer1.seconds() > minimum_reported_time ) { 1.156 + tty->cr(); 1.157 + tty->print_cr (" temporaryTimer1: %3.3f sec", Phase::_t_temporaryTimer1.seconds()); 1.158 + } 1.159 + if( Phase::_t_temporaryTimer2.seconds() > minimum_reported_time ) { 1.160 + tty->cr(); 1.161 + tty->print_cr (" temporaryTimer2: %3.3f sec", Phase::_t_temporaryTimer2.seconds()); 1.162 + } 1.163 + tty->print_cr (" output : %3.3f sec", Phase::_t_output.seconds()); 1.164 + tty->print_cr (" isched : %3.3f sec", Phase::_t_instrSched.seconds()); 1.165 + tty->print_cr (" bldOopMaps: %3.3f sec", Phase::_t_buildOopMaps.seconds()); 1.166 +} 1.167 +#endif