phase.hpp revision 5776:de6a9e811145
160107Sobrien/*
22786Ssos * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
32786Ssos * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42786Ssos *
52786Ssos * This code is free software; you can redistribute it and/or modify it
62786Ssos * under the terms of the GNU General Public License version 2 only, as
72786Ssos * published by the Free Software Foundation.
82786Ssos *
92786Ssos * This code is distributed in the hope that it will be useful, but WITHOUT
102786Ssos * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
112786Ssos * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
122786Ssos * version 2 for more details (a copy is included in the LICENSE file that
132786Ssos * accompanied this code).
142786Ssos *
152786Ssos * You should have received a copy of the GNU General Public License version
162786Ssos * 2 along with this work; if not, write to the Free Software Foundation,
172786Ssos * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1838140Syokota *
192786Ssos * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
206867Sache * or visit www.oracle.com if you need additional information or have any
214686Sache * questions.
222786Ssos *
232786Ssos */
242786Ssos
252786Ssos#ifndef SHARE_VM_OPTO_PHASE_HPP
262786Ssos#define SHARE_VM_OPTO_PHASE_HPP
272786Ssos
282786Ssos#include "libadt/port.hpp"
292786Ssos#include "runtime/timer.hpp"
302786Ssos
312786Ssosclass Compile;
322786Ssos
332786Ssos//------------------------------Phase------------------------------------------
342786Ssos// Most optimizations are done in Phases.  Creating a phase does any long
352786Ssos// running analysis required, and caches the analysis in internal data
362786Ssos// structures.  Later the analysis is queried using transform() calls to
372786Ssos// guide transforming the program.  When the Phase is deleted, so is any
382786Ssos// cached analysis info.  This basic Phase class mostly contains timing and
392786Ssos// memory management code.
402786Ssosclass Phase : public StackObj {
412786Ssospublic:
422786Ssos  enum PhaseNumber {
432786Ssos    Compiler,                   // Top-level compiler phase
442786Ssos    Parser,                     // Parse bytecodes
452786Ssos    Remove_Useless,             // Remove useless nodes
462786Ssos    Optimistic,                 // Optimistic analysis phase
472786Ssos    GVN,                        // Pessimistic global value numbering phase
482786Ssos    Ins_Select,                 // Instruction selection phase
492786Ssos    CFG,                        // Build a CFG
502786Ssos    BlockLayout,                // Linear ordering of blocks
512786Ssos    Register_Allocation,        // Register allocation, duh
522786Ssos    LIVE,                       // Dragon-book LIVE range problem
532786Ssos    StringOpts,                 // StringBuilder related optimizations
542786Ssos    Interference_Graph,         // Building the IFG
552786Ssos    Coalesce,                   // Coalescing copies
562786Ssos    Ideal_Loop,                 // Find idealized trip-counted loops
572786Ssos    Macro_Expand,               // Expand macro nodes
582786Ssos    Peephole,                   // Apply peephole optimizations
592786Ssos    last_phase
602786Ssos  };
612786Ssosprotected:
622786Ssos  enum PhaseNumber _pnum;       // Phase number (for stat gathering)
6332848Syokota
642786Ssos#ifndef PRODUCT
652786Ssos  static int _total_bytes_compiled;
662786Ssos
672786Ssos  // accumulated timers
682786Ssos  static elapsedTimer _t_totalCompilation;
692786Ssos  static elapsedTimer _t_methodCompilation;
702786Ssos  static elapsedTimer _t_stubCompilation;
712786Ssos#endif
722786Ssos
732786Ssos// The next timers used for LogCompilation
742786Ssos  static elapsedTimer _t_parser;
752786Ssos  static elapsedTimer _t_optimizer;
762786Ssospublic:
772786Ssos  // ConnectionGraph can't be Phase since it is used after EA done.
782786Ssos  static elapsedTimer   _t_escapeAnalysis;
792786Ssos  static elapsedTimer     _t_connectionGraph;
802786Ssosprotected:
812786Ssos  static elapsedTimer   _t_idealLoop;
825994Ssos  static elapsedTimer   _t_ccp;
832786Ssos  static elapsedTimer _t_matcher;
842786Ssos  static elapsedTimer _t_registerAllocation;
852786Ssos  static elapsedTimer _t_output;
862786Ssos
872786Ssos#ifndef PRODUCT
882786Ssos  static elapsedTimer _t_graphReshaping;
896869Sache  static elapsedTimer _t_scheduler;
902786Ssos  static elapsedTimer _t_blockOrdering;
912786Ssos  static elapsedTimer _t_macroEliminate;
922786Ssos  static elapsedTimer _t_macroExpand;
932786Ssos  static elapsedTimer _t_peephole;
942786Ssos  static elapsedTimer _t_codeGeneration;
952786Ssos  static elapsedTimer _t_registerMethod;
962786Ssos  static elapsedTimer _t_temporaryTimer1;
972786Ssos  static elapsedTimer _t_temporaryTimer2;
9874119Sache  static elapsedTimer _t_idealLoopVerify;
992786Ssos
1002786Ssos// Subtimers for _t_optimizer
1012786Ssos  static elapsedTimer   _t_iterGVN;
1022786Ssos  static elapsedTimer   _t_iterGVN2;
1032786Ssos  static elapsedTimer   _t_incrInline;
1042786Ssos
1052786Ssos// Subtimers for _t_registerAllocation
1062786Ssos  static elapsedTimer   _t_ctorChaitin;
1072786Ssos  static elapsedTimer   _t_buildIFGphysical;
10874119Sache  static elapsedTimer   _t_computeLive;
10975339Ssobomax  static elapsedTimer   _t_regAllocSplit;
11043334Syokota  static elapsedTimer   _t_postAllocCopyRemoval;
11175339Ssobomax  static elapsedTimer   _t_fixupSpills;
11275339Ssobomax
11375339Ssobomax// Subtimers for _t_output
1142786Ssos  static elapsedTimer   _t_instrSched;
1152786Ssos  static elapsedTimer   _t_buildOopMaps;
1162786Ssos#endif
1172786Ssospublic:
1182786Ssos  Compile * C;
1192786Ssos  Phase( PhaseNumber pnum );
1202786Ssos#ifndef PRODUCT
1212786Ssos  static void print_timers();
1222786Ssos#endif
1232786Ssos};
1242786Ssos
1252786Ssos#endif // SHARE_VM_OPTO_PHASE_HPP
1262786Ssos