| 1 | /* | 
|---|
| 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. | 
|---|
| 4 | * | 
|---|
| 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 | 
|---|
| 7 | * published by the Free Software Foundation. | 
|---|
| 8 | * | 
|---|
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT | 
|---|
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 
|---|
| 11 | * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License | 
|---|
| 12 | * version 2 for more details (a copy is included in the LICENSE file that | 
|---|
| 13 | * accompanied this code). | 
|---|
| 14 | * | 
|---|
| 15 | * You should have received a copy of the GNU General Public License version | 
|---|
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, | 
|---|
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | 
|---|
| 18 | * | 
|---|
| 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | 
|---|
| 20 | * or visit www.oracle.com if you need additional information or have any | 
|---|
| 21 | * questions. | 
|---|
| 22 | * | 
|---|
| 23 | */ | 
|---|
| 24 |  | 
|---|
| 25 | #include "precompiled.hpp" | 
|---|
| 26 | #include "code/nmethod.hpp" | 
|---|
| 27 | #include "compiler/compileBroker.hpp" | 
|---|
| 28 | #include "opto/compile.hpp" | 
|---|
| 29 | #include "opto/matcher.hpp" | 
|---|
| 30 | #include "opto/node.hpp" | 
|---|
| 31 | #include "opto/phase.hpp" | 
|---|
| 32 |  | 
|---|
| 33 | int Phase::_total_bytes_compiled = 0; | 
|---|
| 34 |  | 
|---|
| 35 | elapsedTimer Phase::_t_totalCompilation; | 
|---|
| 36 | elapsedTimer Phase::_t_methodCompilation; | 
|---|
| 37 | elapsedTimer Phase::_t_stubCompilation; | 
|---|
| 38 |  | 
|---|
| 39 | // The counters to use for LogCompilation | 
|---|
| 40 | elapsedTimer Phase::timers[max_phase_timers]; | 
|---|
| 41 |  | 
|---|
| 42 | //------------------------------Phase------------------------------------------ | 
|---|
| 43 | Phase::Phase( PhaseNumber pnum ) : _pnum(pnum), C( pnum == Compiler ? NULL : Compile::current()) { | 
|---|
| 44 | // Poll for requests from shutdown mechanism to quiesce compiler (4448539, 4448544). | 
|---|
| 45 | // This is an effective place to poll, since the compiler is full of phases. | 
|---|
| 46 | // In particular, every inlining site uses a recursively created Parse phase. | 
|---|
| 47 | CompileBroker::maybe_block(); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | void Phase::print_timers() { | 
|---|
| 51 | tty->print_cr ( "    C2 Compile Time:      %7.3f s", Phase::_t_totalCompilation.seconds()); | 
|---|
| 52 | tty->print_cr ( "       Parse:               %7.3f s", timers[_t_parser].seconds()); | 
|---|
| 53 |  | 
|---|
| 54 | { | 
|---|
| 55 | tty->print_cr ( "       Optimize:            %7.3f s", timers[_t_optimizer].seconds()); | 
|---|
| 56 | if (DoEscapeAnalysis) { | 
|---|
| 57 | // EA is part of Optimizer. | 
|---|
| 58 | tty->print_cr ( "         Escape Analysis:     %7.3f s", timers[_t_escapeAnalysis].seconds()); | 
|---|
| 59 | tty->print_cr ( "           Conn Graph:          %7.3f s", timers[_t_connectionGraph].seconds()); | 
|---|
| 60 | tty->print_cr ( "           Macro Eliminate:     %7.3f s", timers[_t_macroEliminate].seconds()); | 
|---|
| 61 | } | 
|---|
| 62 | tty->print_cr ( "         GVN 1:               %7.3f s", timers[_t_iterGVN].seconds()); | 
|---|
| 63 |  | 
|---|
| 64 | { | 
|---|
| 65 | tty->print_cr ( "         Incremental Inline:  %7.3f s", timers[_t_incrInline].seconds()); | 
|---|
| 66 | tty->print_cr ( "           IdealLoop:           %7.3f s", timers[_t_incrInline_ideal].seconds()); | 
|---|
| 67 | tty->print_cr ( "           IGVN:                %7.3f s", timers[_t_incrInline_igvn].seconds()); | 
|---|
| 68 | tty->print_cr ( "           Inline:              %7.3f s", timers[_t_incrInline_inline].seconds()); | 
|---|
| 69 | tty->print_cr ( "           Prune Useless:       %7.3f s", timers[_t_incrInline_pru].seconds()); | 
|---|
| 70 |  | 
|---|
| 71 | double other = timers[_t_incrInline].seconds() - | 
|---|
| 72 | (timers[_t_incrInline_ideal].seconds() + | 
|---|
| 73 | timers[_t_incrInline_igvn].seconds() + | 
|---|
| 74 | timers[_t_incrInline_inline].seconds() + | 
|---|
| 75 | timers[_t_incrInline_pru].seconds()); | 
|---|
| 76 | if (other > 0) { | 
|---|
| 77 | tty->print_cr( "           Other:               %7.3f s", other); | 
|---|
| 78 | } | 
|---|
| 79 | } | 
|---|
| 80 | tty->print_cr ( "         Renumber Live:       %7.3f s", timers[_t_renumberLive].seconds()); | 
|---|
| 81 | tty->print_cr ( "         IdealLoop:           %7.3f s", timers[_t_idealLoop].seconds()); | 
|---|
| 82 | tty->print_cr ( "         IdealLoop Verify:    %7.3f s", timers[_t_idealLoopVerify].seconds()); | 
|---|
| 83 | tty->print_cr ( "         Cond Const Prop:     %7.3f s", timers[_t_ccp].seconds()); | 
|---|
| 84 | tty->print_cr ( "         GVN 2:               %7.3f s", timers[_t_iterGVN2].seconds()); | 
|---|
| 85 | tty->print_cr ( "         Macro Expand:        %7.3f s", timers[_t_macroExpand].seconds()); | 
|---|
| 86 | tty->print_cr ( "         Barrier Expand:      %7.3f s", timers[_t_barrierExpand].seconds()); | 
|---|
| 87 | tty->print_cr ( "         Graph Reshape:       %7.3f s", timers[_t_graphReshaping].seconds()); | 
|---|
| 88 |  | 
|---|
| 89 | double other = timers[_t_optimizer].seconds() - | 
|---|
| 90 | (timers[_t_escapeAnalysis].seconds() + | 
|---|
| 91 | timers[_t_iterGVN].seconds() + | 
|---|
| 92 | timers[_t_incrInline].seconds() + | 
|---|
| 93 | timers[_t_renumberLive].seconds() + | 
|---|
| 94 | timers[_t_idealLoop].seconds() + | 
|---|
| 95 | timers[_t_idealLoopVerify].seconds() + | 
|---|
| 96 | timers[_t_ccp].seconds() + | 
|---|
| 97 | timers[_t_iterGVN2].seconds() + | 
|---|
| 98 | timers[_t_macroExpand].seconds() + | 
|---|
| 99 | timers[_t_barrierExpand].seconds() + | 
|---|
| 100 | timers[_t_graphReshaping].seconds()); | 
|---|
| 101 | if (other > 0) { | 
|---|
| 102 | tty->print_cr( "         Other:               %7.3f s", other); | 
|---|
| 103 | } | 
|---|
| 104 | } | 
|---|
| 105 |  | 
|---|
| 106 | tty->print_cr ( "       Matcher:             %7.3f s", timers[_t_matcher].seconds()); | 
|---|
| 107 | tty->print_cr ( "       Scheduler:           %7.3f s", timers[_t_scheduler].seconds()); | 
|---|
| 108 |  | 
|---|
| 109 | { | 
|---|
| 110 | tty->print_cr ( "       Regalloc:            %7.3f s", timers[_t_registerAllocation].seconds()); | 
|---|
| 111 | tty->print_cr ( "         Ctor Chaitin:        %7.3f s", timers[_t_ctorChaitin].seconds()); | 
|---|
| 112 | tty->print_cr ( "         Build IFG (virt):    %7.3f s", timers[_t_buildIFGvirtual].seconds()); | 
|---|
| 113 | tty->print_cr ( "         Build IFG (phys):    %7.3f s", timers[_t_buildIFGphysical].seconds()); | 
|---|
| 114 | tty->print_cr ( "         Compute Liveness:    %7.3f s", timers[_t_computeLive].seconds()); | 
|---|
| 115 | tty->print_cr ( "         Regalloc Split:      %7.3f s", timers[_t_regAllocSplit].seconds()); | 
|---|
| 116 | tty->print_cr ( "         Postalloc Copy Rem:  %7.3f s", timers[_t_postAllocCopyRemoval].seconds()); | 
|---|
| 117 | tty->print_cr ( "         Merge multidefs:     %7.3f s", timers[_t_mergeMultidefs].seconds()); | 
|---|
| 118 | tty->print_cr ( "         Fixup Spills:        %7.3f s", timers[_t_fixupSpills].seconds()); | 
|---|
| 119 | tty->print_cr ( "         Compact:             %7.3f s", timers[_t_chaitinCompact].seconds()); | 
|---|
| 120 | tty->print_cr ( "         Coalesce 1:          %7.3f s", timers[_t_chaitinCoalesce1].seconds()); | 
|---|
| 121 | tty->print_cr ( "         Coalesce 2:          %7.3f s", timers[_t_chaitinCoalesce2].seconds()); | 
|---|
| 122 | tty->print_cr ( "         Coalesce 3:          %7.3f s", timers[_t_chaitinCoalesce3].seconds()); | 
|---|
| 123 | tty->print_cr ( "         Cache LRG:           %7.3f s", timers[_t_chaitinCacheLRG].seconds()); | 
|---|
| 124 | tty->print_cr ( "         Simplify:            %7.3f s", timers[_t_chaitinSimplify].seconds()); | 
|---|
| 125 | tty->print_cr ( "         Select:              %7.3f s", timers[_t_chaitinSelect].seconds()); | 
|---|
| 126 |  | 
|---|
| 127 | double other = timers[_t_registerAllocation].seconds() - | 
|---|
| 128 | (timers[_t_ctorChaitin].seconds() + | 
|---|
| 129 | timers[_t_buildIFGvirtual].seconds() + | 
|---|
| 130 | timers[_t_buildIFGphysical].seconds() + | 
|---|
| 131 | timers[_t_computeLive].seconds() + | 
|---|
| 132 | timers[_t_regAllocSplit].seconds() + | 
|---|
| 133 | timers[_t_postAllocCopyRemoval].seconds() + | 
|---|
| 134 | timers[_t_mergeMultidefs].seconds() + | 
|---|
| 135 | timers[_t_fixupSpills].seconds() + | 
|---|
| 136 | timers[_t_chaitinCompact].seconds() + | 
|---|
| 137 | timers[_t_chaitinCoalesce1].seconds() + | 
|---|
| 138 | timers[_t_chaitinCoalesce2].seconds() + | 
|---|
| 139 | timers[_t_chaitinCoalesce3].seconds() + | 
|---|
| 140 | timers[_t_chaitinCacheLRG].seconds() + | 
|---|
| 141 | timers[_t_chaitinSimplify].seconds() + | 
|---|
| 142 | timers[_t_chaitinSelect].seconds()); | 
|---|
| 143 |  | 
|---|
| 144 | if (other > 0) { | 
|---|
| 145 | tty->print_cr( "         Other:               %7.3f s", other); | 
|---|
| 146 | } | 
|---|
| 147 | } | 
|---|
| 148 | tty->print_cr ( "       Block Ordering:      %7.3f s", timers[_t_blockOrdering].seconds()); | 
|---|
| 149 | tty->print_cr ( "       Peephole:            %7.3f s", timers[_t_peephole].seconds()); | 
|---|
| 150 | if (Matcher::require_postalloc_expand) { | 
|---|
| 151 | tty->print_cr ( "       Postalloc Expand:    %7.3f s", timers[_t_postalloc_expand].seconds()); | 
|---|
| 152 | } | 
|---|
| 153 | tty->print_cr ( "       Code Emission:         %7.3f s", timers[_t_output].seconds()); | 
|---|
| 154 | tty->print_cr ( "         Insn Scheduling:     %7.3f s", timers[_t_instrSched].seconds()); | 
|---|
| 155 | tty->print_cr ( "         Build OOP maps:      %7.3f s", timers[_t_buildOopMaps].seconds()); | 
|---|
| 156 | tty->print_cr ( "       Code Installation:   %7.3f s", timers[_t_registerMethod].seconds()); | 
|---|
| 157 |  | 
|---|
| 158 | if( timers[_t_temporaryTimer1].seconds() > 0 ) { | 
|---|
| 159 | tty->cr(); | 
|---|
| 160 | tty->print_cr ( "       Temp Timer 1:        %7.3f s", timers[_t_temporaryTimer1].seconds()); | 
|---|
| 161 | } | 
|---|
| 162 | if( timers[_t_temporaryTimer2].seconds() > 0 ) { | 
|---|
| 163 | tty->cr(); | 
|---|
| 164 | tty->print_cr ( "       Temp Timer 2:        %7.3f s", timers[_t_temporaryTimer2].seconds()); | 
|---|
| 165 | } | 
|---|
| 166 |  | 
|---|
| 167 | double other = Phase::_t_totalCompilation.seconds() - | 
|---|
| 168 | (timers[_t_parser].seconds() + | 
|---|
| 169 | timers[_t_optimizer].seconds() + | 
|---|
| 170 | timers[_t_matcher].seconds() + | 
|---|
| 171 | timers[_t_scheduler].seconds() + | 
|---|
| 172 | timers[_t_registerAllocation].seconds() + | 
|---|
| 173 | timers[_t_blockOrdering].seconds() + | 
|---|
| 174 | timers[_t_peephole].seconds() + | 
|---|
| 175 | timers[_t_postalloc_expand].seconds() + | 
|---|
| 176 | timers[_t_output].seconds() + | 
|---|
| 177 | timers[_t_registerMethod].seconds() + | 
|---|
| 178 | timers[_t_temporaryTimer1].seconds() + | 
|---|
| 179 | timers[_t_temporaryTimer2].seconds()); | 
|---|
| 180 | if (other > 0) { | 
|---|
| 181 | tty->print_cr( "       Other:               %7.3f s", other); | 
|---|
| 182 | } | 
|---|
| 183 |  | 
|---|
| 184 | } | 
|---|
| 185 |  | 
|---|