annotate src/share/vm/opto/phase.cpp @ 196:d1605aabd0a1 jdk7-b30

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