phaseX.hpp revision 4030
0N/A/*
1472N/A * Copyright (c) 1997, 2010, 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
0N/A#ifndef SHARE_VM_OPTO_PHASEX_HPP
304N/A#define SHARE_VM_OPTO_PHASEX_HPP
0N/A
0N/A#include "libadt/dict.hpp"
0N/A#include "libadt/vectset.hpp"
0N/A#include "memory/resourceArea.hpp"
0N/A#include "opto/memnode.hpp"
0N/A#include "opto/node.hpp"
0N/A#include "opto/phase.hpp"
0N/A#include "opto/type.hpp"
0N/A
0N/Aclass Compile;
0N/Aclass ConINode;
0N/Aclass ConLNode;
0N/Aclass Node;
0N/Aclass Type;
0N/Aclass PhaseTransform;
0N/Aclass PhaseGVN;
0N/Aclass PhaseIterGVN;
0N/Aclass PhaseCCP;
0N/Aclass PhasePeephole;
0N/Aclass PhaseRegAlloc;
0N/A
0N/A
0N/A//-----------------------------------------------------------------------------
0N/A// Expandable closed hash-table of nodes, initialized to NULL.
0N/A// Note that the constructor just zeros things
0N/A// Storage is reclaimed when the Arena's lifetime is over.
0N/Aclass NodeHash : public StackObj {
0N/Aprotected:
0N/A Arena *_a; // Arena to allocate in
0N/A uint _max; // Size of table (power of 2)
0N/A uint _inserts; // For grow and debug, count of hash_inserts
0N/A uint _insert_limit; // 'grow' when _inserts reaches _insert_limit
0N/A Node **_table; // Hash table of Node pointers
0N/A Node *_sentinel; // Replaces deleted entries in hash table
0N/A
0N/Apublic:
0N/A NodeHash(uint est_max_size);
0N/A NodeHash(Arena *arena, uint est_max_size);
0N/A NodeHash(NodeHash *use_this_state);
0N/A#ifdef ASSERT
0N/A ~NodeHash(); // Unlock all nodes upon destruction of table.
0N/A void operator=(const NodeHash&); // Unlock all nodes upon replacement of table.
304N/A#endif
304N/A Node *hash_find(const Node*);// Find an equivalent version in hash table
0N/A Node *hash_find_insert(Node*);// If not in table insert else return found node
0N/A void hash_insert(Node*); // Insert into hash table
0N/A bool hash_delete(const Node*);// Replace with _sentinel in hash table
0N/A void check_grow() {
304N/A _inserts++;
304N/A if( _inserts == _insert_limit ) { grow(); }
304N/A assert( _inserts <= _insert_limit, "hash table overflow");
304N/A assert( _inserts < _max, "hash table overflow" );
304N/A }
304N/A static uint round_up(uint); // Round up to nearest power of 2
304N/A void grow(); // Grow _table to next power of 2 and rehash
304N/A // Return 75% of _max, rounded up.
304N/A uint insert_limit() const { return _max - (_max>>2); }
304N/A
304N/A void clear(); // Set all entries to NULL, keep storage.
304N/A // Size of hash table
304N/A uint size() const { return _max; }
304N/A // Return Node* at index in table
304N/A Node *at(uint table_index) {
304N/A assert(table_index < _max, "Must be within table");
304N/A return _table[table_index];
304N/A }
304N/A
304N/A void remove_useless_nodes(VectorSet &useful); // replace with sentinel
304N/A
304N/A Node *sentinel() { return _sentinel; }
304N/A
304N/A#ifndef PRODUCT
304N/A Node *find_index(uint idx); // For debugging
304N/A void dump(); // For debugging, dump statistics
304N/A#endif
304N/A uint _grows; // For debugging, count of table grow()s
304N/A uint _look_probes; // For debugging, count of hash probes
304N/A uint _lookup_hits; // For debugging, count of hash_finds
304N/A uint _lookup_misses; // For debugging, count of hash_finds
304N/A uint _insert_probes; // For debugging, count of hash probes
304N/A uint _delete_probes; // For debugging, count of hash probes for deletes
0N/A uint _delete_hits; // For debugging, count of hash probes for deletes
0N/A uint _delete_misses; // For debugging, count of hash probes for deletes
0N/A uint _total_inserts; // For debugging, total inserts into hash table
0N/A uint _total_insert_probes; // For debugging, total probes while inserting
0N/A};
0N/A
304N/A
0N/A//-----------------------------------------------------------------------------
0N/A// Map dense integer indices to Types. Uses classic doubling-array trick.
0N/A// Abstractly provides an infinite array of Type*'s, initialized to NULL.
0N/A// Note that the constructor just zeros things, and since I use Arena
0N/A// allocation I do not need a destructor to reclaim storage.
0N/A// Despite the general name, this class is customized for use by PhaseTransform.
0N/Aclass Type_Array : public StackObj {
0N/A Arena *_a; // Arena to allocate in
0N/A uint _max;
304N/A const Type **_types;
0N/A void grow( uint i ); // Grow array node to fit
0N/A const Type *operator[] ( uint i ) const // Lookup, or NULL for not mapped
304N/A { return (i<_max) ? _types[i] : (Type*)NULL; }
304N/A friend class PhaseTransform;
0N/Apublic:
0N/A Type_Array(Arena *a) : _a(a), _max(0), _types(0) {}
0N/A Type_Array(Type_Array *ta) : _a(ta->_a), _max(ta->_max), _types(ta->_types) { }
624N/A const Type *fast_lookup(uint i) const{assert(i<_max,"oob");return _types[i];}
624N/A // Extend the mapping: index i maps to Type *n.
624N/A void map( uint i, const Type *n ) { if( i>=_max ) grow(i); _types[i] = n; }
624N/A uint Size() const { return _max; }
624N/A#ifndef PRODUCT
0N/A void dump() const;
0N/A#endif
0N/A};
624N/A
0N/A
0N/A//------------------------------PhaseRemoveUseless-----------------------------
0N/A// Remove useless nodes from GVN hash-table, worklist, and graph
624N/Aclass PhaseRemoveUseless : public Phase {
0N/Aprotected:
0N/A Unique_Node_List _useful; // Nodes reachable from root
0N/A // list is allocated from current resource area
0N/Apublic:
0N/A PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist );
0N/A
0N/A Unique_Node_List *get_useful() { return &_useful; }
0N/A};
0N/A
0N/A
0N/A//------------------------------PhaseTransform---------------------------------
0N/A// Phases that analyze, then transform. Constructing the Phase object does any
0N/A// global or slow analysis. The results are cached later for a fast
0N/A// transformation pass. When the Phase object is deleted the cached analysis
0N/A// results are deleted.
0N/Aclass PhaseTransform : public Phase {
0N/Aprotected:
0N/A Arena* _arena;
304N/A Node_Array _nodes; // Map old node indices to new nodes.
0N/A Type_Array _types; // Map old node indices to Types.
0N/A
0N/A // ConNode caches:
0N/A enum { _icon_min = -1 * HeapWordSize,
0N/A _icon_max = 16 * HeapWordSize,
0N/A _lcon_min = _icon_min,
0N/A _lcon_max = _icon_max,
0N/A _zcon_max = (uint)T_CONFLICT
0N/A };
0N/A ConINode* _icons[_icon_max - _icon_min + 1]; // cached jint constant nodes
0N/A ConLNode* _lcons[_lcon_max - _lcon_min + 1]; // cached jlong constant nodes
0N/A ConNode* _zcons[_zcon_max + 1]; // cached is_zero_type nodes
0N/A void init_con_caches();
0N/A
0N/A // Support both int and long caches because either might be an intptr_t,
0N/A // so they show up frequently in address computations.
0N/A
304N/Apublic:
304N/A PhaseTransform( PhaseNumber pnum );
304N/A PhaseTransform( Arena *arena, PhaseNumber pnum );
304N/A PhaseTransform( PhaseTransform *phase, PhaseNumber pnum );
304N/A
304N/A Arena* arena() { return _arena; }
304N/A Type_Array& types() { return _types; }
304N/A // _nodes is used in varying ways by subclasses, which define local accessors
304N/A
304N/Apublic:
304N/A // Get a previously recorded type for the node n.
304N/A // This type must already have been recorded.
304N/A // If you want the type of a very new (untransformed) node,
304N/A // you must use type_or_null, and test the result for NULL.
304N/A const Type* type(const Node* n) const {
0N/A assert(n != NULL, "must not be null");
0N/A const Type* t = _types.fast_lookup(n->_idx);
0N/A assert(t != NULL, "must set before get");
0N/A return t;
0N/A }
0N/A // Get a previously recorded type for the node n,
0N/A // or else return NULL if there is none.
304N/A const Type* type_or_null(const Node* n) const {
0N/A return _types.fast_lookup(n->_idx);
0N/A }
0N/A // Record a type for a node.
0N/A void set_type(const Node* n, const Type *t) {
304N/A assert(t != NULL, "type must not be null");
0N/A _types.map(n->_idx, t);
0N/A }
0N/A // Record an initial type for a node, the node's bottom type.
0N/A void set_type_bottom(const Node* n) {
0N/A // Use this for initialization when bottom_type() (or better) is not handy.
304N/A // Usually the initialization shoudl be to n->Value(this) instead,
0N/A // or a hand-optimized value like Type::MEMORY or Type::CONTROL.
0N/A assert(_types[n->_idx] == NULL, "must set the initial type just once");
0N/A _types.map(n->_idx, n->bottom_type());
304N/A }
0N/A // Make sure the types array is big enough to record a size for the node n.
0N/A // (In product builds, we never want to do range checks on the types array!)
0N/A void ensure_type_or_null(const Node* n) {
0N/A if (n->_idx >= _types.Size())
0N/A _types.map(n->_idx, NULL); // Grow the types array as needed.
304N/A }
0N/A
0N/A // Utility functions:
0N/A const TypeInt* find_int_type( Node* n);
0N/A const TypeLong* find_long_type(Node* n);
304N/A jint find_int_con( Node* n, jint value_if_unknown) {
0N/A const TypeInt* t = find_int_type(n);
0N/A return (t != NULL && t->is_con()) ? t->get_con() : value_if_unknown;
0N/A }
304N/A jlong find_long_con(Node* n, jlong value_if_unknown) {
0N/A const TypeLong* t = find_long_type(n);
0N/A return (t != NULL && t->is_con()) ? t->get_con() : value_if_unknown;
0N/A }
0N/A
0N/A // Make an idealized constant, i.e., one of ConINode, ConPNode, ConFNode, etc.
304N/A // Same as transform(ConNode::make(t)).
0N/A ConNode* makecon(const Type* t);
0N/A virtual ConNode* uncached_makecon(const Type* t) // override in PhaseValues
0N/A { ShouldNotCallThis(); return NULL; }
0N/A
0N/A // Fast int or long constant. Same as TypeInt::make(i) or TypeLong::make(l).
304N/A ConINode* intcon(jint i);
304N/A ConLNode* longcon(jlong l);
0N/A
0N/A // Fast zero or null constant. Same as makecon(Type::get_zero_type(bt)).
0N/A ConNode* zerocon(BasicType bt);
0N/A
0N/A // Return a node which computes the same function as this node, but
0N/A // in a faster or cheaper fashion.
304N/A virtual Node *transform( Node *n ) = 0;
304N/A
304N/A // Return whether two Nodes are equivalent.
304N/A // Must not be recursive, since the recursive version is built from this.
304N/A // For pessimistic optimizations this is simply pointer equivalence.
304N/A bool eqv(const Node* n1, const Node* n2) const { return n1 == n2; }
304N/A
304N/A // For pessimistic passes, the return type must monotonically narrow.
0N/A // For optimistic passes, the return type must monotonically widen.
304N/A // It is possible to get into a "death march" in either type of pass,
304N/A // where the types are continually moving but it will take 2**31 or
304N/A // more steps to converge. This doesn't happen on most normal loops.
304N/A //
304N/A // Here is an example of a deadly loop for an optimistic pass, along
304N/A // with a partial trace of inferred types:
304N/A // x = phi(0,x'); L: x' = x+1; if (x' >= 0) goto L;
0N/A // 0 1 join([0..max], 1)
0N/A // [0..1] [1..2] join([0..max], [1..2])
0N/A // [0..2] [1..3] join([0..max], [1..3])
0N/A // ... ... ...
304N/A // [0..max] [min]u[1..max] join([0..max], [min..max])
304N/A // [0..max] ==> fixpoint
0N/A // We would have proven, the hard way, that the iteration space is all
0N/A // non-negative ints, with the loop terminating due to 32-bit overflow.
0N/A //
304N/A // Here is the corresponding example for a pessimistic pass:
304N/A // x = phi(0,x'); L: x' = x-1; if (x' >= 0) goto L;
0N/A // int int join([0..max], int)
0N/A // [0..max] [-1..max-1] join([0..max], [-1..max-1])
0N/A // [0..max-1] [-1..max-2] join([0..max], [-1..max-2])
0N/A // ... ... ...
304N/A // [0..1] [-1..0] join([0..max], [-1..0])
304N/A // 0 -1 join([0..max], -1)
0N/A // 0 == fixpoint
0N/A // We would have proven, the hard way, that the iteration space is {0}.
304N/A // (Usually, other optimizations will make the "if (x >= 0)" fold up
304N/A // before we get into trouble. But not always.)
0N/A //
304N/A // It's a pleasant thing to observe that the pessimistic pass
304N/A // will make short work of the optimistic pass's deadly loop,
0N/A // and vice versa. That is a good example of the complementary
0N/A // purposes of the CCP (optimistic) vs. GVN (pessimistic) phases.
304N/A //
304N/A // In any case, only widen or narrow a few times before going to the
0N/A // correct flavor of top or bottom.
304N/A //
0N/A // This call only needs to be made once as the data flows around any
304N/A // given cycle. We do it at Phis, and nowhere else.
0N/A // The types presented are the new type of a phi (computed by PhiNode::Value)
0N/A // and the previously computed type, last time the phi was visited.
304N/A //
304N/A // The third argument is upper limit for the saturated value,
304N/A // if the phase wishes to widen the new_type.
0N/A // If the phase is narrowing, the old type provides a lower limit.
0N/A // Caller guarantees that old_type and new_type are no higher than limit_type.
0N/A virtual const Type* saturate(const Type* new_type, const Type* old_type,
304N/A const Type* limit_type) const
304N/A { ShouldNotCallThis(); return NULL; }
304N/A
0N/A#ifndef PRODUCT
0N/A void dump_old2new_map() const;
0N/A void dump_new( uint new_lidx ) const;
0N/A void dump_types() const;
0N/A void dump_nodes_and_types(const Node *root, uint depth, bool only_ctrl = true);
304N/A void dump_nodes_and_types_recur( const Node *n, uint depth, bool only_ctrl, VectorSet &visited);
304N/A
304N/A uint _count_progress; // For profiling, count transforms that make progress
0N/A void set_progress() { ++_count_progress; assert( allow_progress(),"No progress allowed during verification"); }
0N/A void clear_progress() { _count_progress = 0; }
304N/A uint made_progress() const { return _count_progress; }
0N/A
304N/A uint _count_transforms; // For profiling, count transforms performed
304N/A void set_transforms() { ++_count_transforms; }
304N/A void clear_transforms() { _count_transforms = 0; }
0N/A uint made_transforms() const{ return _count_transforms; }
0N/A
304N/A bool _allow_progress; // progress not allowed during verification pass
304N/A void set_allow_progress(bool allow) { _allow_progress = allow; }
304N/A bool allow_progress() { return _allow_progress; }
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------PhaseValues------------------------------------
0N/A// Phase infrastructure to support values
0N/Aclass PhaseValues : public PhaseTransform {
0N/Aprotected:
304N/A NodeHash _table; // Hash table for value-numbering
0N/A
304N/Apublic:
304N/A PhaseValues( Arena *arena, uint est_max_size );
0N/A PhaseValues( PhaseValues *pt );
304N/A PhaseValues( PhaseValues *ptv, const char *dummy );
304N/A NOT_PRODUCT( ~PhaseValues(); )
304N/A virtual PhaseIterGVN *is_IterGVN() { return 0; }
304N/A
304N/A // Some Ideal and other transforms delete --> modify --> insert values
304N/A bool hash_delete(Node *n) { return _table.hash_delete(n); }
304N/A void hash_insert(Node *n) { _table.hash_insert(n); }
304N/A Node *hash_find_insert(Node *n){ return _table.hash_find_insert(n); }
304N/A Node *hash_find(const Node *n) { return _table.hash_find(n); }
304N/A
304N/A // Used after parsing to eliminate values that are no longer in program
304N/A void remove_useless_nodes(VectorSet &useful) {
304N/A _table.remove_useless_nodes(useful);
304N/A // this may invalidate cached cons so reset the cache
304N/A init_con_caches();
304N/A }
304N/A
304N/A virtual ConNode* uncached_makecon(const Type* t); // override from PhaseTransform
304N/A
304N/A virtual const Type* saturate(const Type* new_type, const Type* old_type,
0N/A const Type* limit_type) const
304N/A { return new_type; }
304N/A
304N/A#ifndef PRODUCT
304N/A uint _count_new_values; // For profiling, count new values produced
304N/A void inc_new_values() { ++_count_new_values; }
0N/A void clear_new_values() { _count_new_values = 0; }
0N/A uint made_new_values() const { return _count_new_values; }
0N/A#endif
0N/A};
0N/A
304N/A
304N/A//------------------------------PhaseGVN---------------------------------------
304N/A// Phase for performing local, pessimistic GVN-style optimizations.
304N/Aclass PhaseGVN : public PhaseValues {
304N/Apublic:
304N/A PhaseGVN( Arena *arena, uint est_max_size ) : PhaseValues( arena, est_max_size ) {}
0N/A PhaseGVN( PhaseGVN *gvn ) : PhaseValues( gvn ) {}
0N/A PhaseGVN( PhaseGVN *gvn, const char *dummy ) : PhaseValues( gvn, dummy ) {}
0N/A
0N/A // Return a node which computes the same function as this node, but
0N/A // in a faster or cheaper fashion.
0N/A Node *transform( Node *n );
0N/A Node *transform_no_reclaim( Node *n );
0N/A
0N/A // Check for a simple dead loop when a data node references itself.
304N/A DEBUG_ONLY(void dead_loop_check(Node *n);)
0N/A};
0N/A
304N/A//------------------------------PhaseIterGVN-----------------------------------
0N/A// Phase for iteratively performing local, pessimistic GVN-style optimizations.
0N/A// and ideal transformations on the graph.
0N/Aclass PhaseIterGVN : public PhaseGVN {
0N/A private:
304N/A bool _delay_transform; // When true simply register the node when calling transform
304N/A // instead of actually optimizing it
304N/A
304N/A // Idealize old Node 'n' with respect to its inputs and its value
304N/A virtual Node *transform_old( Node *a_node );
304N/A
0N/A // Subsume users of node 'old' into node 'nn'
0N/A void subsume_node( Node *old, Node *nn );
0N/A
304N/A Node_Stack _stack; // Stack used to avoid recursion
304N/A
0N/Aprotected:
304N/A
0N/A // Idealize new Node 'n' with respect to its inputs and its value
0N/A virtual Node *transform( Node *a_node );
0N/A
0N/A // Warm up hash table, type table and initial worklist
0N/A void init_worklist( Node *a_root );
0N/A
0N/A virtual const Type* saturate(const Type* new_type, const Type* old_type,
0N/A const Type* limit_type) const;
304N/A // Usually returns new_type. Returns old_type if new_type is only a slight
304N/A // improvement, such that it would take many (>>10) steps to reach 2**32.
0N/A
0N/Apublic:
0N/A PhaseIterGVN( PhaseIterGVN *igvn ); // Used by CCP constructor
304N/A PhaseIterGVN( PhaseGVN *gvn ); // Used after Parser
304N/A PhaseIterGVN( PhaseIterGVN *igvn, const char *dummy ); // Used after +VerifyOpto
304N/A
304N/A virtual PhaseIterGVN *is_IterGVN() { return this; }
304N/A
304N/A Unique_Node_List _worklist; // Iterative worklist
304N/A
304N/A // Given def-use info and an initial worklist, apply Node::Ideal,
304N/A // Node::Value, Node::Identity, hash-based value numbering, Node::Ideal_DU
304N/A // and dominator info to a fixed point.
304N/A void optimize();
304N/A
304N/A // Register a new node with the iter GVN pass without transforming it.
304N/A // Used when we need to restructure a Region/Phi area and all the Regions
304N/A // and Phis need to complete this one big transform before any other
304N/A // transforms can be triggered on the region.
304N/A // Optional 'orig' is an earlier version of this node.
304N/A // It is significant only for debugging and profiling.
304N/A Node* register_new_node_with_optimizer(Node* n, Node* orig = NULL);
304N/A
304N/A // Kill a globally dead Node. All uses are also globally dead and are
304N/A // aggressively trimmed.
304N/A void remove_globally_dead_node( Node *dead );
304N/A
304N/A // Kill all inputs to a dead node, recursively making more dead nodes.
0N/A // The Node must be dead locally, i.e., have no uses.
0N/A void remove_dead_node( Node *dead ) {
0N/A assert(dead->outcnt() == 0 && !dead->is_top(), "node must be dead");
0N/A remove_globally_dead_node(dead);
0N/A }
304N/A
0N/A // Add users of 'n' to worklist
0N/A void add_users_to_worklist0( Node *n );
304N/A void add_users_to_worklist ( Node *n );
304N/A
304N/A // Replace old node with new one.
304N/A void replace_node( Node *old, Node *nn ) {
304N/A add_users_to_worklist(old);
0N/A hash_delete(old); // Yank from hash before hacking edges
0N/A subsume_node(old, nn);
0N/A }
304N/A
0N/A // Delayed node rehash: remove a node from the hash table and rehash it during
304N/A // next optimizing pass
304N/A void rehash_node_delayed(Node* n) {
304N/A hash_delete(n);
304N/A _worklist.push(n);
304N/A }
304N/A
304N/A // Replace ith edge of "n" with "in"
304N/A void replace_input_of(Node* n, int i, Node* in) {
304N/A rehash_node_delayed(n);
304N/A n->set_req(i, in);
304N/A }
304N/A
304N/A // Delete ith edge of "n"
304N/A void delete_input_of(Node* n, int i) {
304N/A rehash_node_delayed(n);
304N/A n->del_req(i);
304N/A }
304N/A
0N/A bool delay_transform() const { return _delay_transform; }
0N/A
304N/A void set_delay_transform(bool delay) {
0N/A _delay_transform = delay;
0N/A }
304N/A
0N/A // Clone loop predicates. Defined in loopTransform.cpp.
0N/A Node* clone_loop_predicates(Node* old_entry, Node* new_entry, bool clone_limit_check);
0N/A // Create a new if below new_entry for the predicate to be cloned
0N/A ProjNode* create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
0N/A Deoptimization::DeoptReason reason);
0N/A
0N/A#ifndef PRODUCT
0N/Aprotected:
0N/A // Sub-quadratic implementation of VerifyIterativeGVN.
0N/A julong _verify_counter;
304N/A julong _verify_full_passes;
304N/A enum { _verify_window_size = 30 };
304N/A Node* _verify_window[_verify_window_size];
304N/A void verify_step(Node* n);
304N/A#endif
304N/A};
304N/A
304N/A//------------------------------PhaseCCP---------------------------------------
304N/A// Phase for performing global Conditional Constant Propagation.
0N/A// Should be replaced with combined CCP & GVN someday.
0N/Aclass PhaseCCP : public PhaseIterGVN {
0N/A // Non-recursive. Use analysis to transform single Node.
0N/A virtual Node *transform_once( Node *n );
0N/A
304N/Apublic:
0N/A PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants
0N/A NOT_PRODUCT( ~PhaseCCP(); )
0N/A
0N/A // Worklist algorithm identifies constants
0N/A void analyze();
0N/A // Recursive traversal of program. Used analysis to modify program.
0N/A virtual Node *transform( Node *n );
0N/A // Do any transformation after analysis
0N/A void do_transform();
0N/A
0N/A virtual const Type* saturate(const Type* new_type, const Type* old_type,
0N/A const Type* limit_type) const;
0N/A // Returns new_type->widen(old_type), which increments the widen bits until
0N/A // giving up with TypeInt::INT or TypeLong::LONG.
0N/A // Result is clipped to limit_type if necessary.
304N/A
304N/A#ifndef PRODUCT
304N/A static uint _total_invokes; // For profiling, count invocations
0N/A void inc_invokes() { ++PhaseCCP::_total_invokes; }
0N/A
0N/A static uint _total_constants; // For profiling, count constants found
0N/A uint _count_constants;
304N/A void clear_constants() { _count_constants = 0; }
304N/A void inc_constants() { ++_count_constants; }
304N/A uint count_constants() const { return _count_constants; }
304N/A
0N/A static void print_statistics();
0N/A#endif
0N/A};
0N/A
0N/A
0N/A//------------------------------PhasePeephole----------------------------------
304N/A// Phase for performing peephole optimizations on register allocated basic blocks.
0N/Aclass PhasePeephole : public PhaseTransform {
0N/A PhaseRegAlloc *_regalloc;
304N/A PhaseCFG &_cfg;
0N/A // Recursive traversal of program. Pure function is unused in this phase
304N/A virtual Node *transform( Node *n );
0N/A
0N/Apublic:
304N/A PhasePeephole( PhaseRegAlloc *regalloc, PhaseCFG &cfg );
0N/A NOT_PRODUCT( ~PhasePeephole(); )
0N/A
304N/A // Do any transformation after analysis
0N/A void do_transform();
0N/A
0N/A#ifndef PRODUCT
0N/A static uint _total_peepholes; // For profiling, count peephole rules applied
0N/A uint _count_peepholes;
0N/A void clear_peepholes() { _count_peepholes = 0; }
0N/A void inc_peepholes() { ++_count_peepholes; }
0N/A uint count_peepholes() const { return _count_peepholes; }
304N/A
0N/A static void print_statistics();
304N/A#endif
0N/A};
0N/A
0N/A#endif // SHARE_VM_OPTO_PHASEX_HPP
0N/A