phase.hpp revision 1879:f95d63e2154a
1130803Smarcel/* 2130803Smarcel * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 3130803Smarcel * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4130803Smarcel * 5130803Smarcel * This code is free software; you can redistribute it and/or modify it 6130803Smarcel * under the terms of the GNU General Public License version 2 only, as 7130803Smarcel * published by the Free Software Foundation. 8130803Smarcel * 9130803Smarcel * This code is distributed in the hope that it will be useful, but WITHOUT 10130803Smarcel * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11130803Smarcel * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12130803Smarcel * version 2 for more details (a copy is included in the LICENSE file that 13130803Smarcel * accompanied this code). 14130803Smarcel * 15130803Smarcel * You should have received a copy of the GNU General Public License version 16130803Smarcel * 2 along with this work; if not, write to the Free Software Foundation, 17130803Smarcel * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18130803Smarcel * 19130803Smarcel * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20130803Smarcel * or visit www.oracle.com if you need additional information or have any 21130803Smarcel * questions. 22130803Smarcel * 23130803Smarcel */ 24130803Smarcel 25130803Smarcel#ifndef SHARE_VM_OPTO_PHASE_HPP 26130803Smarcel#define SHARE_VM_OPTO_PHASE_HPP 27130803Smarcel 28130803Smarcel#include "libadt/port.hpp" 29130803Smarcel#include "runtime/timer.hpp" 30130803Smarcel 31130803Smarcelclass Compile; 32130803Smarcel 33130803Smarcel//------------------------------Phase------------------------------------------ 34130803Smarcel// Most optimizations are done in Phases. Creating a phase does any long 35130803Smarcel// running analysis required, and caches the analysis in internal data 36130803Smarcel// structures. Later the analysis is queried using transform() calls to 37130803Smarcel// guide transforming the program. When the Phase is deleted, so is any 38130803Smarcel// cached analysis info. This basic Phase class mostly contains timing and 39130803Smarcel// memory management code. 40130803Smarcelclass Phase : public StackObj { 41130803Smarcelpublic: 42130803Smarcel enum PhaseNumber { 43130803Smarcel Compiler, // Top-level compiler phase 44130803Smarcel Parser, // Parse bytecodes 45130803Smarcel Remove_Useless, // Remove useless nodes 46130803Smarcel Optimistic, // Optimistic analysis phase 47130803Smarcel GVN, // Pessimistic global value numbering phase 48130803Smarcel Ins_Select, // Instruction selection phase 49130803Smarcel CFG, // Build a CFG 50130803Smarcel BlockLayout, // Linear ordering of blocks 51130803Smarcel Register_Allocation, // Register allocation, duh 52130803Smarcel LIVE, // Dragon-book LIVE range problem 53130803Smarcel StringOpts, // StringBuilder related optimizations 54130803Smarcel Interference_Graph, // Building the IFG 55130803Smarcel Coalesce, // Coalescing copies 56130803Smarcel Ideal_Loop, // Find idealized trip-counted loops 57130803Smarcel Macro_Expand, // Expand macro nodes 58130803Smarcel Peephole, // Apply peephole optimizations 59130803Smarcel last_phase 60130803Smarcel }; 61130803Smarcelprotected: 62130803Smarcel enum PhaseNumber _pnum; // Phase number (for stat gathering) 63130803Smarcel 64130803Smarcel#ifndef PRODUCT 65130803Smarcel static int _total_bytes_compiled; 66130803Smarcel 67130803Smarcel // accumulated timers 68130803Smarcel static elapsedTimer _t_totalCompilation; 69130803Smarcel static elapsedTimer _t_methodCompilation; 70130803Smarcel static elapsedTimer _t_stubCompilation; 71130803Smarcel#endif 72130803Smarcel 73130803Smarcel// The next timers used for LogCompilation 74130803Smarcel static elapsedTimer _t_parser; 75130803Smarcel static elapsedTimer _t_escapeAnalysis; 76130803Smarcel static elapsedTimer _t_optimizer; 77130803Smarcel static elapsedTimer _t_idealLoop; 78130803Smarcel static elapsedTimer _t_ccp; 79130803Smarcel static elapsedTimer _t_matcher; 80130803Smarcel static elapsedTimer _t_registerAllocation; 81130803Smarcel static elapsedTimer _t_output; 82130803Smarcel 83130803Smarcel#ifndef PRODUCT 84130803Smarcel static elapsedTimer _t_graphReshaping; 85130803Smarcel static elapsedTimer _t_scheduler; 86130803Smarcel static elapsedTimer _t_blockOrdering; 87130803Smarcel static elapsedTimer _t_macroExpand; 88130803Smarcel static elapsedTimer _t_peephole; 89130803Smarcel static elapsedTimer _t_codeGeneration; 90130803Smarcel static elapsedTimer _t_registerMethod; 91130803Smarcel static elapsedTimer _t_temporaryTimer1; 92130803Smarcel static elapsedTimer _t_temporaryTimer2; 93130803Smarcel static elapsedTimer _t_idealLoopVerify; 94130803Smarcel 95130803Smarcel// Subtimers for _t_optimizer 96130803Smarcel static elapsedTimer _t_iterGVN; 97130803Smarcel static elapsedTimer _t_iterGVN2; 98130803Smarcel 99130803Smarcel// Subtimers for _t_registerAllocation 100130803Smarcel static elapsedTimer _t_ctorChaitin; 101130803Smarcel static elapsedTimer _t_buildIFGphysical; 102130803Smarcel static elapsedTimer _t_computeLive; 103130803Smarcel static elapsedTimer _t_regAllocSplit; 104130803Smarcel static elapsedTimer _t_postAllocCopyRemoval; 105130803Smarcel static elapsedTimer _t_fixupSpills; 106130803Smarcel 107130803Smarcel// Subtimers for _t_output 108130803Smarcel static elapsedTimer _t_instrSched; 109130803Smarcel static elapsedTimer _t_buildOopMaps; 110130803Smarcel#endif 111130803Smarcelpublic: 112130803Smarcel Compile * C; 113130803Smarcel Phase( PhaseNumber pnum ); 114130803Smarcel#ifndef PRODUCT 115130803Smarcel static void print_timers(); 116130803Smarcel#endif 117130803Smarcel}; 118130803Smarcel 119130803Smarcel#endif // SHARE_VM_OPTO_PHASE_HPP 120130803Smarcel