0N/A/*
3619N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "code/nmethod.hpp"
1879N/A#include "compiler/compileBroker.hpp"
1879N/A#include "opto/compile.hpp"
1879N/A#include "opto/node.hpp"
1879N/A#include "opto/phase.hpp"
0N/A
0N/A#ifndef PRODUCT
0N/Aint Phase::_total_bytes_compiled = 0;
0N/A
0N/AelapsedTimer Phase::_t_totalCompilation;
0N/AelapsedTimer Phase::_t_methodCompilation;
0N/AelapsedTimer Phase::_t_stubCompilation;
0N/A#endif
0N/A
0N/A// The next timers used for LogCompilation
0N/AelapsedTimer Phase::_t_parser;
0N/AelapsedTimer Phase::_t_optimizer;
3619N/AelapsedTimer Phase::_t_escapeAnalysis;
3619N/AelapsedTimer Phase::_t_connectionGraph;
0N/AelapsedTimer Phase::_t_idealLoop;
0N/AelapsedTimer Phase::_t_ccp;
0N/AelapsedTimer Phase::_t_matcher;
0N/AelapsedTimer Phase::_t_registerAllocation;
0N/AelapsedTimer Phase::_t_output;
0N/A
0N/A#ifndef PRODUCT
0N/AelapsedTimer Phase::_t_graphReshaping;
0N/AelapsedTimer Phase::_t_scheduler;
418N/AelapsedTimer Phase::_t_blockOrdering;
3619N/AelapsedTimer Phase::_t_macroEliminate;
0N/AelapsedTimer Phase::_t_macroExpand;
0N/AelapsedTimer Phase::_t_peephole;
0N/AelapsedTimer Phase::_t_codeGeneration;
0N/AelapsedTimer Phase::_t_registerMethod;
0N/AelapsedTimer Phase::_t_temporaryTimer1;
0N/AelapsedTimer Phase::_t_temporaryTimer2;
921N/AelapsedTimer Phase::_t_idealLoopVerify;
0N/A
0N/A// Subtimers for _t_optimizer
0N/AelapsedTimer Phase::_t_iterGVN;
0N/AelapsedTimer Phase::_t_iterGVN2;
0N/A
0N/A// Subtimers for _t_registerAllocation
0N/AelapsedTimer Phase::_t_ctorChaitin;
0N/AelapsedTimer Phase::_t_buildIFGphysical;
0N/AelapsedTimer Phase::_t_computeLive;
0N/AelapsedTimer Phase::_t_regAllocSplit;
0N/AelapsedTimer Phase::_t_postAllocCopyRemoval;
0N/AelapsedTimer Phase::_t_fixupSpills;
0N/A
0N/A// Subtimers for _t_output
0N/AelapsedTimer Phase::_t_instrSched;
0N/AelapsedTimer Phase::_t_buildOopMaps;
0N/A#endif
0N/A
0N/A//------------------------------Phase------------------------------------------
0N/APhase::Phase( PhaseNumber pnum ) : _pnum(pnum), C( pnum == Compiler ? NULL : Compile::current()) {
605N/A // Poll for requests from shutdown mechanism to quiesce compiler (4448539, 4448544).
0N/A // This is an effective place to poll, since the compiler is full of phases.
0N/A // In particular, every inlining site uses a recursively created Parse phase.
0N/A CompileBroker::maybe_block();
0N/A}
0N/A
0N/A#ifndef PRODUCT
0N/Astatic const double minimum_reported_time = 0.0001; // seconds
0N/Astatic const double expected_method_compile_coverage = 0.97; // %
0N/Astatic const double minimum_meaningful_method_compile = 2.00; // seconds
0N/A
0N/Avoid Phase::print_timers() {
0N/A tty->print_cr ("Accumulated compiler times:");
0N/A tty->print_cr ("---------------------------");
0N/A tty->print_cr (" Total compilation: %3.3f sec.", Phase::_t_totalCompilation.seconds());
921N/A tty->print (" method compilation : %3.3f sec", Phase::_t_methodCompilation.seconds());
0N/A tty->print ("/%d bytes",_total_bytes_compiled);
0N/A tty->print_cr (" (%3.0f bytes per sec) ", Phase::_total_bytes_compiled / Phase::_t_methodCompilation.seconds());
921N/A tty->print_cr (" stub compilation : %3.3f sec.", Phase::_t_stubCompilation.seconds());
0N/A tty->print_cr (" Phases:");
921N/A tty->print_cr (" parse : %3.3f sec", Phase::_t_parser.seconds());
921N/A tty->print_cr (" optimizer : %3.3f sec", Phase::_t_optimizer.seconds());
0N/A if( Verbose || WizardMode ) {
2121N/A if (DoEscapeAnalysis) {
2121N/A // EA is part of Optimizer.
2121N/A tty->print_cr (" escape analysis: %3.3f sec", Phase::_t_escapeAnalysis.seconds());
3619N/A tty->print_cr (" connection graph: %3.3f sec", Phase::_t_connectionGraph.seconds());
3619N/A tty->print_cr (" macroEliminate : %3.3f sec", Phase::_t_macroEliminate.seconds());
2121N/A }
921N/A tty->print_cr (" iterGVN : %3.3f sec", Phase::_t_iterGVN.seconds());
921N/A tty->print_cr (" idealLoop : %3.3f sec", Phase::_t_idealLoop.seconds());
921N/A tty->print_cr (" idealLoopVerify: %3.3f sec", Phase::_t_idealLoopVerify.seconds());
921N/A tty->print_cr (" ccp : %3.3f sec", Phase::_t_ccp.seconds());
921N/A tty->print_cr (" iterGVN2 : %3.3f sec", Phase::_t_iterGVN2.seconds());
2121N/A tty->print_cr (" macroExpand : %3.3f sec", Phase::_t_macroExpand.seconds());
921N/A tty->print_cr (" graphReshape : %3.3f sec", Phase::_t_graphReshaping.seconds());
3619N/A double optimizer_subtotal = Phase::_t_iterGVN.seconds() + Phase::_t_iterGVN2.seconds() +
3619N/A Phase::_t_escapeAnalysis.seconds() + Phase::_t_macroEliminate.seconds() +
0N/A Phase::_t_idealLoop.seconds() + Phase::_t_ccp.seconds() +
3619N/A Phase::_t_macroExpand.seconds() + Phase::_t_graphReshaping.seconds();
0N/A double percent_of_optimizer = ((optimizer_subtotal == 0.0) ? 0.0 : (optimizer_subtotal / Phase::_t_optimizer.seconds() * 100.0));
921N/A tty->print_cr (" subtotal : %3.3f sec, %3.2f %%", optimizer_subtotal, percent_of_optimizer);
0N/A }
921N/A tty->print_cr (" matcher : %3.3f sec", Phase::_t_matcher.seconds());
921N/A tty->print_cr (" scheduler : %3.3f sec", Phase::_t_scheduler.seconds());
921N/A tty->print_cr (" regalloc : %3.3f sec", Phase::_t_registerAllocation.seconds());
0N/A if( Verbose || WizardMode ) {
921N/A tty->print_cr (" ctorChaitin : %3.3f sec", Phase::_t_ctorChaitin.seconds());
921N/A tty->print_cr (" buildIFG : %3.3f sec", Phase::_t_buildIFGphysical.seconds());
921N/A tty->print_cr (" computeLive : %3.3f sec", Phase::_t_computeLive.seconds());
921N/A tty->print_cr (" regAllocSplit : %3.3f sec", Phase::_t_regAllocSplit.seconds());
0N/A tty->print_cr (" postAllocCopyRemoval: %3.3f sec", Phase::_t_postAllocCopyRemoval.seconds());
921N/A tty->print_cr (" fixupSpills : %3.3f sec", Phase::_t_fixupSpills.seconds());
0N/A double regalloc_subtotal = Phase::_t_ctorChaitin.seconds() +
0N/A Phase::_t_buildIFGphysical.seconds() + Phase::_t_computeLive.seconds() +
0N/A Phase::_t_regAllocSplit.seconds() + Phase::_t_fixupSpills.seconds() +
0N/A Phase::_t_postAllocCopyRemoval.seconds();
0N/A double percent_of_regalloc = ((regalloc_subtotal == 0.0) ? 0.0 : (regalloc_subtotal / Phase::_t_registerAllocation.seconds() * 100.0));
921N/A tty->print_cr (" subtotal : %3.3f sec, %3.2f %%", regalloc_subtotal, percent_of_regalloc);
0N/A }
921N/A tty->print_cr (" blockOrdering : %3.3f sec", Phase::_t_blockOrdering.seconds());
921N/A tty->print_cr (" peephole : %3.3f sec", Phase::_t_peephole.seconds());
921N/A tty->print_cr (" codeGen : %3.3f sec", Phase::_t_codeGeneration.seconds());
921N/A tty->print_cr (" install_code : %3.3f sec", Phase::_t_registerMethod.seconds());
921N/A tty->print_cr (" -------------- : ----------");
0N/A double phase_subtotal = Phase::_t_parser.seconds() +
0N/A Phase::_t_optimizer.seconds() + Phase::_t_graphReshaping.seconds() +
0N/A Phase::_t_matcher.seconds() + Phase::_t_scheduler.seconds() +
418N/A Phase::_t_registerAllocation.seconds() + Phase::_t_blockOrdering.seconds() +
0N/A Phase::_t_codeGeneration.seconds() + Phase::_t_registerMethod.seconds();
0N/A double percent_of_method_compile = ((phase_subtotal == 0.0) ? 0.0 : phase_subtotal / Phase::_t_methodCompilation.seconds()) * 100.0;
0N/A // counters inside Compile::CodeGen include time for adapters and stubs
0N/A // so phase-total can be greater than 100%
921N/A tty->print_cr (" total : %3.3f sec, %3.2f %%", phase_subtotal, percent_of_method_compile);
0N/A
0N/A assert( percent_of_method_compile > expected_method_compile_coverage ||
0N/A phase_subtotal < minimum_meaningful_method_compile,
0N/A "Must account for method compilation");
0N/A
0N/A if( Phase::_t_temporaryTimer1.seconds() > minimum_reported_time ) {
0N/A tty->cr();
0N/A tty->print_cr (" temporaryTimer1: %3.3f sec", Phase::_t_temporaryTimer1.seconds());
0N/A }
0N/A if( Phase::_t_temporaryTimer2.seconds() > minimum_reported_time ) {
0N/A tty->cr();
0N/A tty->print_cr (" temporaryTimer2: %3.3f sec", Phase::_t_temporaryTimer2.seconds());
0N/A }
921N/A tty->print_cr (" output : %3.3f sec", Phase::_t_output.seconds());
921N/A tty->print_cr (" isched : %3.3f sec", Phase::_t_instrSched.seconds());
921N/A tty->print_cr (" bldOopMaps : %3.3f sec", Phase::_t_buildOopMaps.seconds());
0N/A}
0N/A#endif