1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/phaseX.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,516 @@ 1.4 +/* 1.5 + * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +class Compile; 1.29 +class ConINode; 1.30 +class ConLNode; 1.31 +class Node; 1.32 +class Type; 1.33 +class PhaseTransform; 1.34 +class PhaseGVN; 1.35 +class PhaseIterGVN; 1.36 +class PhaseCCP; 1.37 +class PhasePeephole; 1.38 +class PhaseRegAlloc; 1.39 + 1.40 + 1.41 +//----------------------------------------------------------------------------- 1.42 +// Expandable closed hash-table of nodes, initialized to NULL. 1.43 +// Note that the constructor just zeros things 1.44 +// Storage is reclaimed when the Arena's lifetime is over. 1.45 +class NodeHash : public StackObj { 1.46 +protected: 1.47 + Arena *_a; // Arena to allocate in 1.48 + uint _max; // Size of table (power of 2) 1.49 + uint _inserts; // For grow and debug, count of hash_inserts 1.50 + uint _insert_limit; // 'grow' when _inserts reaches _insert_limit 1.51 + Node **_table; // Hash table of Node pointers 1.52 + Node *_sentinel; // Replaces deleted entries in hash table 1.53 + 1.54 +public: 1.55 + NodeHash(uint est_max_size); 1.56 + NodeHash(Arena *arena, uint est_max_size); 1.57 + NodeHash(NodeHash *use_this_state); 1.58 +#ifdef ASSERT 1.59 + ~NodeHash(); // Unlock all nodes upon destruction of table. 1.60 + void operator=(const NodeHash&); // Unlock all nodes upon replacement of table. 1.61 +#endif 1.62 + Node *hash_find(const Node*);// Find an equivalent version in hash table 1.63 + Node *hash_find_insert(Node*);// If not in table insert else return found node 1.64 + void hash_insert(Node*); // Insert into hash table 1.65 + bool hash_delete(const Node*);// Replace with _sentinel in hash table 1.66 + void check_grow() { 1.67 + _inserts++; 1.68 + if( _inserts == _insert_limit ) { grow(); } 1.69 + assert( _inserts <= _insert_limit, "hash table overflow"); 1.70 + assert( _inserts < _max, "hash table overflow" ); 1.71 + } 1.72 + static uint round_up(uint); // Round up to nearest power of 2 1.73 + void grow(); // Grow _table to next power of 2 and rehash 1.74 + // Return 75% of _max, rounded up. 1.75 + uint insert_limit() const { return _max - (_max>>2); } 1.76 + 1.77 + void clear(); // Set all entries to NULL, keep storage. 1.78 + // Size of hash table 1.79 + uint size() const { return _max; } 1.80 + // Return Node* at index in table 1.81 + Node *at(uint table_index) { 1.82 + assert(table_index < _max, "Must be within table"); 1.83 + return _table[table_index]; 1.84 + } 1.85 + 1.86 + void remove_useless_nodes(VectorSet &useful); // replace with sentinel 1.87 + 1.88 + Node *sentinel() { return _sentinel; } 1.89 + 1.90 +#ifndef PRODUCT 1.91 + Node *find_index(uint idx); // For debugging 1.92 + void dump(); // For debugging, dump statistics 1.93 +#endif 1.94 + uint _grows; // For debugging, count of table grow()s 1.95 + uint _look_probes; // For debugging, count of hash probes 1.96 + uint _lookup_hits; // For debugging, count of hash_finds 1.97 + uint _lookup_misses; // For debugging, count of hash_finds 1.98 + uint _insert_probes; // For debugging, count of hash probes 1.99 + uint _delete_probes; // For debugging, count of hash probes for deletes 1.100 + uint _delete_hits; // For debugging, count of hash probes for deletes 1.101 + uint _delete_misses; // For debugging, count of hash probes for deletes 1.102 + uint _total_inserts; // For debugging, total inserts into hash table 1.103 + uint _total_insert_probes; // For debugging, total probes while inserting 1.104 +}; 1.105 + 1.106 + 1.107 +//----------------------------------------------------------------------------- 1.108 +// Map dense integer indices to Types. Uses classic doubling-array trick. 1.109 +// Abstractly provides an infinite array of Type*'s, initialized to NULL. 1.110 +// Note that the constructor just zeros things, and since I use Arena 1.111 +// allocation I do not need a destructor to reclaim storage. 1.112 +// Despite the general name, this class is customized for use by PhaseTransform. 1.113 +class Type_Array : public StackObj { 1.114 + Arena *_a; // Arena to allocate in 1.115 + uint _max; 1.116 + const Type **_types; 1.117 + void grow( uint i ); // Grow array node to fit 1.118 + const Type *operator[] ( uint i ) const // Lookup, or NULL for not mapped 1.119 + { return (i<_max) ? _types[i] : (Type*)NULL; } 1.120 + friend class PhaseTransform; 1.121 +public: 1.122 + Type_Array(Arena *a) : _a(a), _max(0), _types(0) {} 1.123 + Type_Array(Type_Array *ta) : _a(ta->_a), _max(ta->_max), _types(ta->_types) { } 1.124 + const Type *fast_lookup(uint i) const{assert(i<_max,"oob");return _types[i];} 1.125 + // Extend the mapping: index i maps to Type *n. 1.126 + void map( uint i, const Type *n ) { if( i>=_max ) grow(i); _types[i] = n; } 1.127 + uint Size() const { return _max; } 1.128 +#ifndef PRODUCT 1.129 + void dump() const; 1.130 +#endif 1.131 +}; 1.132 + 1.133 + 1.134 +//------------------------------PhaseRemoveUseless----------------------------- 1.135 +// Remove useless nodes from GVN hash-table, worklist, and graph 1.136 +class PhaseRemoveUseless : public Phase { 1.137 +protected: 1.138 + Unique_Node_List _useful; // Nodes reachable from root 1.139 + // list is allocated from current resource area 1.140 +public: 1.141 + PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist ); 1.142 + 1.143 + Unique_Node_List *get_useful() { return &_useful; } 1.144 +}; 1.145 + 1.146 + 1.147 +//------------------------------PhaseTransform--------------------------------- 1.148 +// Phases that analyze, then transform. Constructing the Phase object does any 1.149 +// global or slow analysis. The results are cached later for a fast 1.150 +// transformation pass. When the Phase object is deleted the cached analysis 1.151 +// results are deleted. 1.152 +class PhaseTransform : public Phase { 1.153 +protected: 1.154 + Arena* _arena; 1.155 + Node_Array _nodes; // Map old node indices to new nodes. 1.156 + Type_Array _types; // Map old node indices to Types. 1.157 + 1.158 + // ConNode caches: 1.159 + enum { _icon_min = -1 * HeapWordSize, 1.160 + _icon_max = 16 * HeapWordSize, 1.161 + _lcon_min = _icon_min, 1.162 + _lcon_max = _icon_max, 1.163 + _zcon_max = (uint)T_CONFLICT 1.164 + }; 1.165 + ConINode* _icons[_icon_max - _icon_min + 1]; // cached jint constant nodes 1.166 + ConLNode* _lcons[_lcon_max - _lcon_min + 1]; // cached jlong constant nodes 1.167 + ConNode* _zcons[_zcon_max + 1]; // cached is_zero_type nodes 1.168 + void init_con_caches(); 1.169 + 1.170 + // Support both int and long caches because either might be an intptr_t, 1.171 + // so they show up frequently in address computations. 1.172 + 1.173 +public: 1.174 + PhaseTransform( PhaseNumber pnum ); 1.175 + PhaseTransform( Arena *arena, PhaseNumber pnum ); 1.176 + PhaseTransform( PhaseTransform *phase, PhaseNumber pnum ); 1.177 + 1.178 + Arena* arena() { return _arena; } 1.179 + Type_Array& types() { return _types; } 1.180 + // _nodes is used in varying ways by subclasses, which define local accessors 1.181 + 1.182 +public: 1.183 + // Get a previously recorded type for the node n. 1.184 + // This type must already have been recorded. 1.185 + // If you want the type of a very new (untransformed) node, 1.186 + // you must use type_or_null, and test the result for NULL. 1.187 + const Type* type(const Node* n) const { 1.188 + const Type* t = _types.fast_lookup(n->_idx); 1.189 + assert(t != NULL, "must set before get"); 1.190 + return t; 1.191 + } 1.192 + // Get a previously recorded type for the node n, 1.193 + // or else return NULL if there is none. 1.194 + const Type* type_or_null(const Node* n) const { 1.195 + return _types.fast_lookup(n->_idx); 1.196 + } 1.197 + // Record a type for a node. 1.198 + void set_type(const Node* n, const Type *t) { 1.199 + assert(t != NULL, "type must not be null"); 1.200 + _types.map(n->_idx, t); 1.201 + } 1.202 + // Record an initial type for a node, the node's bottom type. 1.203 + void set_type_bottom(const Node* n) { 1.204 + // Use this for initialization when bottom_type() (or better) is not handy. 1.205 + // Usually the initialization shoudl be to n->Value(this) instead, 1.206 + // or a hand-optimized value like Type::MEMORY or Type::CONTROL. 1.207 + assert(_types[n->_idx] == NULL, "must set the initial type just once"); 1.208 + _types.map(n->_idx, n->bottom_type()); 1.209 + } 1.210 + // Make sure the types array is big enough to record a size for the node n. 1.211 + // (In product builds, we never want to do range checks on the types array!) 1.212 + void ensure_type_or_null(const Node* n) { 1.213 + if (n->_idx >= _types.Size()) 1.214 + _types.map(n->_idx, NULL); // Grow the types array as needed. 1.215 + } 1.216 + 1.217 + // Utility functions: 1.218 + const TypeInt* find_int_type( Node* n); 1.219 + const TypeLong* find_long_type(Node* n); 1.220 + jint find_int_con( Node* n, jint value_if_unknown) { 1.221 + const TypeInt* t = find_int_type(n); 1.222 + return (t != NULL && t->is_con()) ? t->get_con() : value_if_unknown; 1.223 + } 1.224 + jlong find_long_con(Node* n, jlong value_if_unknown) { 1.225 + const TypeLong* t = find_long_type(n); 1.226 + return (t != NULL && t->is_con()) ? t->get_con() : value_if_unknown; 1.227 + } 1.228 + 1.229 + // Make an idealized constant, i.e., one of ConINode, ConPNode, ConFNode, etc. 1.230 + // Same as transform(ConNode::make(t)). 1.231 + ConNode* makecon(const Type* t); 1.232 + virtual ConNode* uncached_makecon(const Type* t) // override in PhaseValues 1.233 + { ShouldNotCallThis(); return NULL; } 1.234 + 1.235 + // Fast int or long constant. Same as TypeInt::make(i) or TypeLong::make(l). 1.236 + ConINode* intcon(jint i); 1.237 + ConLNode* longcon(jlong l); 1.238 + 1.239 + // Fast zero or null constant. Same as makecon(Type::get_zero_type(bt)). 1.240 + ConNode* zerocon(BasicType bt); 1.241 + 1.242 + // Return a node which computes the same function as this node, but 1.243 + // in a faster or cheaper fashion. 1.244 + virtual Node *transform( Node *n ) = 0; 1.245 + 1.246 + // Return whether two Nodes are equivalent. 1.247 + // Must not be recursive, since the recursive version is built from this. 1.248 + // For pessimistic optimizations this is simply pointer equivalence. 1.249 + bool eqv(const Node* n1, const Node* n2) const { return n1 == n2; } 1.250 + 1.251 + // Return whether two Nodes are equivalent, after stripping casting. 1.252 + bool eqv_uncast(const Node* n1, const Node* n2) const { 1.253 + return eqv(n1->uncast(), n2->uncast()); 1.254 + } 1.255 + 1.256 + // For pessimistic passes, the return type must monotonically narrow. 1.257 + // For optimistic passes, the return type must monotonically widen. 1.258 + // It is possible to get into a "death march" in either type of pass, 1.259 + // where the types are continually moving but it will take 2**31 or 1.260 + // more steps to converge. This doesn't happen on most normal loops. 1.261 + // 1.262 + // Here is an example of a deadly loop for an optimistic pass, along 1.263 + // with a partial trace of inferred types: 1.264 + // x = phi(0,x'); L: x' = x+1; if (x' >= 0) goto L; 1.265 + // 0 1 join([0..max], 1) 1.266 + // [0..1] [1..2] join([0..max], [1..2]) 1.267 + // [0..2] [1..3] join([0..max], [1..3]) 1.268 + // ... ... ... 1.269 + // [0..max] [min]u[1..max] join([0..max], [min..max]) 1.270 + // [0..max] ==> fixpoint 1.271 + // We would have proven, the hard way, that the iteration space is all 1.272 + // non-negative ints, with the loop terminating due to 32-bit overflow. 1.273 + // 1.274 + // Here is the corresponding example for a pessimistic pass: 1.275 + // x = phi(0,x'); L: x' = x-1; if (x' >= 0) goto L; 1.276 + // int int join([0..max], int) 1.277 + // [0..max] [-1..max-1] join([0..max], [-1..max-1]) 1.278 + // [0..max-1] [-1..max-2] join([0..max], [-1..max-2]) 1.279 + // ... ... ... 1.280 + // [0..1] [-1..0] join([0..max], [-1..0]) 1.281 + // 0 -1 join([0..max], -1) 1.282 + // 0 == fixpoint 1.283 + // We would have proven, the hard way, that the iteration space is {0}. 1.284 + // (Usually, other optimizations will make the "if (x >= 0)" fold up 1.285 + // before we get into trouble. But not always.) 1.286 + // 1.287 + // It's a pleasant thing to observe that the pessimistic pass 1.288 + // will make short work of the optimistic pass's deadly loop, 1.289 + // and vice versa. That is a good example of the complementary 1.290 + // purposes of the CCP (optimistic) vs. GVN (pessimistic) phases. 1.291 + // 1.292 + // In any case, only widen or narrow a few times before going to the 1.293 + // correct flavor of top or bottom. 1.294 + // 1.295 + // This call only needs to be made once as the data flows around any 1.296 + // given cycle. We do it at Phis, and nowhere else. 1.297 + // The types presented are the new type of a phi (computed by PhiNode::Value) 1.298 + // and the previously computed type, last time the phi was visited. 1.299 + // 1.300 + // The third argument is upper limit for the saturated value, 1.301 + // if the phase wishes to widen the new_type. 1.302 + // If the phase is narrowing, the old type provides a lower limit. 1.303 + // Caller guarantees that old_type and new_type are no higher than limit_type. 1.304 + virtual const Type* saturate(const Type* new_type, const Type* old_type, 1.305 + const Type* limit_type) const 1.306 + { ShouldNotCallThis(); return NULL; } 1.307 + 1.308 +#ifndef PRODUCT 1.309 + void dump_old2new_map() const; 1.310 + void dump_new( uint new_lidx ) const; 1.311 + void dump_types() const; 1.312 + void dump_nodes_and_types(const Node *root, uint depth, bool only_ctrl = true); 1.313 + void dump_nodes_and_types_recur( const Node *n, uint depth, bool only_ctrl, VectorSet &visited); 1.314 + 1.315 + uint _count_progress; // For profiling, count transforms that make progress 1.316 + void set_progress() { ++_count_progress; assert( allow_progress(),"No progress allowed during verification") } 1.317 + void clear_progress() { _count_progress = 0; } 1.318 + uint made_progress() const { return _count_progress; } 1.319 + 1.320 + uint _count_transforms; // For profiling, count transforms performed 1.321 + void set_transforms() { ++_count_transforms; } 1.322 + void clear_transforms() { _count_transforms = 0; } 1.323 + uint made_transforms() const{ return _count_transforms; } 1.324 + 1.325 + bool _allow_progress; // progress not allowed during verification pass 1.326 + void set_allow_progress(bool allow) { _allow_progress = allow; } 1.327 + bool allow_progress() { return _allow_progress; } 1.328 +#endif 1.329 +}; 1.330 + 1.331 +//------------------------------PhaseValues------------------------------------ 1.332 +// Phase infrastructure to support values 1.333 +class PhaseValues : public PhaseTransform { 1.334 +protected: 1.335 + NodeHash _table; // Hash table for value-numbering 1.336 + 1.337 +public: 1.338 + PhaseValues( Arena *arena, uint est_max_size ); 1.339 + PhaseValues( PhaseValues *pt ); 1.340 + PhaseValues( PhaseValues *ptv, const char *dummy ); 1.341 + NOT_PRODUCT( ~PhaseValues(); ) 1.342 + virtual PhaseIterGVN *is_IterGVN() { return 0; } 1.343 + 1.344 + // Some Ideal and other transforms delete --> modify --> insert values 1.345 + bool hash_delete(Node *n) { return _table.hash_delete(n); } 1.346 + void hash_insert(Node *n) { _table.hash_insert(n); } 1.347 + Node *hash_find_insert(Node *n){ return _table.hash_find_insert(n); } 1.348 + Node *hash_find(const Node *n) { return _table.hash_find(n); } 1.349 + 1.350 + // Used after parsing to eliminate values that are no longer in program 1.351 + void remove_useless_nodes(VectorSet &useful) { _table.remove_useless_nodes(useful); } 1.352 + 1.353 + virtual ConNode* uncached_makecon(const Type* t); // override from PhaseTransform 1.354 + 1.355 + virtual const Type* saturate(const Type* new_type, const Type* old_type, 1.356 + const Type* limit_type) const 1.357 + { return new_type; } 1.358 + 1.359 +#ifndef PRODUCT 1.360 + uint _count_new_values; // For profiling, count new values produced 1.361 + void inc_new_values() { ++_count_new_values; } 1.362 + void clear_new_values() { _count_new_values = 0; } 1.363 + uint made_new_values() const { return _count_new_values; } 1.364 +#endif 1.365 +}; 1.366 + 1.367 + 1.368 +//------------------------------PhaseGVN--------------------------------------- 1.369 +// Phase for performing local, pessimistic GVN-style optimizations. 1.370 +class PhaseGVN : public PhaseValues { 1.371 +public: 1.372 + PhaseGVN( Arena *arena, uint est_max_size ) : PhaseValues( arena, est_max_size ) {} 1.373 + PhaseGVN( PhaseGVN *gvn ) : PhaseValues( gvn ) {} 1.374 + PhaseGVN( PhaseGVN *gvn, const char *dummy ) : PhaseValues( gvn, dummy ) {} 1.375 + 1.376 + // Return a node which computes the same function as this node, but 1.377 + // in a faster or cheaper fashion. 1.378 + Node *transform( Node *n ); 1.379 + Node *transform_no_reclaim( Node *n ); 1.380 + 1.381 + // Check for a simple dead loop when a data node references itself. 1.382 + DEBUG_ONLY(void dead_loop_check(Node *n);) 1.383 +}; 1.384 + 1.385 +//------------------------------PhaseIterGVN----------------------------------- 1.386 +// Phase for iteratively performing local, pessimistic GVN-style optimizations. 1.387 +// and ideal transformations on the graph. 1.388 +class PhaseIterGVN : public PhaseGVN { 1.389 + // Idealize old Node 'n' with respect to its inputs and its value 1.390 + virtual Node *transform_old( Node *a_node ); 1.391 +protected: 1.392 + 1.393 + // Idealize new Node 'n' with respect to its inputs and its value 1.394 + virtual Node *transform( Node *a_node ); 1.395 + 1.396 + // Warm up hash table, type table and initial worklist 1.397 + void init_worklist( Node *a_root ); 1.398 + 1.399 + virtual const Type* saturate(const Type* new_type, const Type* old_type, 1.400 + const Type* limit_type) const; 1.401 + // Usually returns new_type. Returns old_type if new_type is only a slight 1.402 + // improvement, such that it would take many (>>10) steps to reach 2**32. 1.403 + 1.404 +public: 1.405 + PhaseIterGVN( PhaseIterGVN *igvn ); // Used by CCP constructor 1.406 + PhaseIterGVN( PhaseGVN *gvn ); // Used after Parser 1.407 + PhaseIterGVN( PhaseIterGVN *igvn, const char *dummy ); // Used after +VerifyOpto 1.408 + 1.409 + virtual PhaseIterGVN *is_IterGVN() { return this; } 1.410 + 1.411 + Unique_Node_List _worklist; // Iterative worklist 1.412 + 1.413 + // Given def-use info and an initial worklist, apply Node::Ideal, 1.414 + // Node::Value, Node::Identity, hash-based value numbering, Node::Ideal_DU 1.415 + // and dominator info to a fixed point. 1.416 + void optimize(); 1.417 + 1.418 + // Register a new node with the iter GVN pass without transforming it. 1.419 + // Used when we need to restructure a Region/Phi area and all the Regions 1.420 + // and Phis need to complete this one big transform before any other 1.421 + // transforms can be triggered on the region. 1.422 + // Optional 'orig' is an earlier version of this node. 1.423 + // It is significant only for debugging and profiling. 1.424 + Node* register_new_node_with_optimizer(Node* n, Node* orig = NULL); 1.425 + 1.426 + // Kill a globally dead Node. It is allowed to have uses which are 1.427 + // assumed dead and left 'in limbo'. 1.428 + void remove_globally_dead_node( Node *dead ); 1.429 + 1.430 + // Kill all inputs to a dead node, recursively making more dead nodes. 1.431 + // The Node must be dead locally, i.e., have no uses. 1.432 + void remove_dead_node( Node *dead ) { 1.433 + assert(dead->outcnt() == 0 && !dead->is_top(), "node must be dead"); 1.434 + remove_globally_dead_node(dead); 1.435 + } 1.436 + 1.437 + // Subsume users of node 'old' into node 'nn' 1.438 + // If no Def-Use info existed for 'nn' it will after call. 1.439 + void subsume_node( Node *old, Node *nn ); 1.440 + 1.441 + // Add users of 'n' to worklist 1.442 + void add_users_to_worklist0( Node *n ); 1.443 + void add_users_to_worklist ( Node *n ); 1.444 + 1.445 +#ifndef PRODUCT 1.446 +protected: 1.447 + // Sub-quadratic implementation of VerifyIterativeGVN. 1.448 + unsigned long _verify_counter; 1.449 + unsigned long _verify_full_passes; 1.450 + enum { _verify_window_size = 30 }; 1.451 + Node* _verify_window[_verify_window_size]; 1.452 + void verify_step(Node* n); 1.453 +#endif 1.454 +}; 1.455 + 1.456 +//------------------------------PhaseCCP--------------------------------------- 1.457 +// Phase for performing global Conditional Constant Propagation. 1.458 +// Should be replaced with combined CCP & GVN someday. 1.459 +class PhaseCCP : public PhaseIterGVN { 1.460 + // Non-recursive. Use analysis to transform single Node. 1.461 + virtual Node *transform_once( Node *n ); 1.462 + 1.463 +public: 1.464 + PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants 1.465 + NOT_PRODUCT( ~PhaseCCP(); ) 1.466 + 1.467 + // Worklist algorithm identifies constants 1.468 + void analyze(); 1.469 + // Recursive traversal of program. Used analysis to modify program. 1.470 + virtual Node *transform( Node *n ); 1.471 + // Do any transformation after analysis 1.472 + void do_transform(); 1.473 + 1.474 + virtual const Type* saturate(const Type* new_type, const Type* old_type, 1.475 + const Type* limit_type) const; 1.476 + // Returns new_type->widen(old_type), which increments the widen bits until 1.477 + // giving up with TypeInt::INT or TypeLong::LONG. 1.478 + // Result is clipped to limit_type if necessary. 1.479 + 1.480 +#ifndef PRODUCT 1.481 + static uint _total_invokes; // For profiling, count invocations 1.482 + void inc_invokes() { ++PhaseCCP::_total_invokes; } 1.483 + 1.484 + static uint _total_constants; // For profiling, count constants found 1.485 + uint _count_constants; 1.486 + void clear_constants() { _count_constants = 0; } 1.487 + void inc_constants() { ++_count_constants; } 1.488 + uint count_constants() const { return _count_constants; } 1.489 + 1.490 + static void print_statistics(); 1.491 +#endif 1.492 +}; 1.493 + 1.494 + 1.495 +//------------------------------PhasePeephole---------------------------------- 1.496 +// Phase for performing peephole optimizations on register allocated basic blocks. 1.497 +class PhasePeephole : public PhaseTransform { 1.498 + PhaseRegAlloc *_regalloc; 1.499 + PhaseCFG &_cfg; 1.500 + // Recursive traversal of program. Pure function is unused in this phase 1.501 + virtual Node *transform( Node *n ); 1.502 + 1.503 +public: 1.504 + PhasePeephole( PhaseRegAlloc *regalloc, PhaseCFG &cfg ); 1.505 + NOT_PRODUCT( ~PhasePeephole(); ) 1.506 + 1.507 + // Do any transformation after analysis 1.508 + void do_transform(); 1.509 + 1.510 +#ifndef PRODUCT 1.511 + static uint _total_peepholes; // For profiling, count peephole rules applied 1.512 + uint _count_peepholes; 1.513 + void clear_peepholes() { _count_peepholes = 0; } 1.514 + void inc_peepholes() { ++_count_peepholes; } 1.515 + uint count_peepholes() const { return _count_peepholes; } 1.516 + 1.517 + static void print_statistics(); 1.518 +#endif 1.519 +};