131 public: 132 Type_Array(Arena *a) : _a(a), _max(0), _types(0) {} 133 Type_Array(Type_Array *ta) : _a(ta->_a), _max(ta->_max), _types(ta->_types) { } 134 const Type *fast_lookup(uint i) const{assert(i<_max,"oob");return _types[i];} 135 // Extend the mapping: index i maps to Type *n. 136 void map( uint i, const Type *n ) { if( i>=_max ) grow(i); _types[i] = n; } 137 uint Size() const { return _max; } 138 #ifndef PRODUCT 139 void dump() const; 140 #endif 141 }; 142 143 144 //------------------------------PhaseRemoveUseless----------------------------- 145 // Remove useless nodes from GVN hash-table, worklist, and graph 146 class PhaseRemoveUseless : public Phase { 147 protected: 148 Unique_Node_List _useful; // Nodes reachable from root 149 // list is allocated from current resource area 150 public: 151 PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist ); 152 153 Unique_Node_List *get_useful() { return &_useful; } 154 }; 155 156 157 //------------------------------PhaseTransform--------------------------------- 158 // Phases that analyze, then transform. Constructing the Phase object does any 159 // global or slow analysis. The results are cached later for a fast 160 // transformation pass. When the Phase object is deleted the cached analysis 161 // results are deleted. 162 class PhaseTransform : public Phase { 163 protected: 164 Arena* _arena; 165 Node_Array _nodes; // Map old node indices to new nodes. 166 Type_Array _types; // Map old node indices to Types. 167 168 // ConNode caches: 169 enum { _icon_min = -1 * HeapWordSize, 170 _icon_max = 16 * HeapWordSize, 171 _lcon_min = _icon_min, 172 _lcon_max = _icon_max, 173 _zcon_max = (uint)T_CONFLICT 174 }; 175 ConINode* _icons[_icon_max - _icon_min + 1]; // cached jint constant nodes 176 ConLNode* _lcons[_lcon_max - _lcon_min + 1]; // cached jlong constant nodes 177 ConNode* _zcons[_zcon_max + 1]; // cached is_zero_type nodes 178 void init_con_caches(); 179 180 // Support both int and long caches because either might be an intptr_t, 181 // so they show up frequently in address computations. 182 183 public: 184 PhaseTransform( PhaseNumber pnum ); 185 PhaseTransform( Arena *arena, PhaseNumber pnum ); 186 PhaseTransform( PhaseTransform *phase, PhaseNumber pnum ); 187 188 Arena* arena() { return _arena; } 189 Type_Array& types() { return _types; } 190 // _nodes is used in varying ways by subclasses, which define local accessors 191 192 public: 193 // Get a previously recorded type for the node n. 194 // This type must already have been recorded. 195 // If you want the type of a very new (untransformed) node, 196 // you must use type_or_null, and test the result for NULL. 197 const Type* type(const Node* n) const { 198 assert(n != NULL, "must not be null"); 199 const Type* t = _types.fast_lookup(n->_idx); 200 assert(t != NULL, "must set before get"); 201 return t; 202 } 203 // Get a previously recorded type for the node n, 204 // or else return NULL if there is none. 205 const Type* type_or_null(const Node* n) const { 206 return _types.fast_lookup(n->_idx); 207 } 208 // Record a type for a node. 209 void set_type(const Node* n, const Type *t) { 210 assert(t != NULL, "type must not be null"); | 131 public: 132 Type_Array(Arena *a) : _a(a), _max(0), _types(0) {} 133 Type_Array(Type_Array *ta) : _a(ta->_a), _max(ta->_max), _types(ta->_types) { } 134 const Type *fast_lookup(uint i) const{assert(i<_max,"oob");return _types[i];} 135 // Extend the mapping: index i maps to Type *n. 136 void map( uint i, const Type *n ) { if( i>=_max ) grow(i); _types[i] = n; } 137 uint Size() const { return _max; } 138 #ifndef PRODUCT 139 void dump() const; 140 #endif 141 }; 142 143 144 //------------------------------PhaseRemoveUseless----------------------------- 145 // Remove useless nodes from GVN hash-table, worklist, and graph 146 class PhaseRemoveUseless : public Phase { 147 protected: 148 Unique_Node_List _useful; // Nodes reachable from root 149 // list is allocated from current resource area 150 public: 151 PhaseRemoveUseless(PhaseGVN *gvn, Unique_Node_List *worklist, PhaseNumber phase_num = Remove_Useless); 152 153 Unique_Node_List *get_useful() { return &_useful; } 154 }; 155 156 //------------------------------PhaseRenumber---------------------------------- 157 // Phase that first performs a PhaseRemoveUseless, then it renumbers compiler 158 // structures accordingly. 159 class PhaseRenumberLive : public PhaseRemoveUseless { 160 public: 161 PhaseRenumberLive(PhaseGVN* gvn, 162 Unique_Node_List* worklist, Unique_Node_List* new_worklist, 163 PhaseNumber phase_num = Renumber_Live); 164 }; 165 166 167 //------------------------------PhaseTransform--------------------------------- 168 // Phases that analyze, then transform. Constructing the Phase object does any 169 // global or slow analysis. The results are cached later for a fast 170 // transformation pass. When the Phase object is deleted the cached analysis 171 // results are deleted. 172 class PhaseTransform : public Phase { 173 protected: 174 Arena* _arena; 175 Node_List _nodes; // Map old node indices to new nodes. 176 Type_Array _types; // Map old node indices to Types. 177 178 // ConNode caches: 179 enum { _icon_min = -1 * HeapWordSize, 180 _icon_max = 16 * HeapWordSize, 181 _lcon_min = _icon_min, 182 _lcon_max = _icon_max, 183 _zcon_max = (uint)T_CONFLICT 184 }; 185 ConINode* _icons[_icon_max - _icon_min + 1]; // cached jint constant nodes 186 ConLNode* _lcons[_lcon_max - _lcon_min + 1]; // cached jlong constant nodes 187 ConNode* _zcons[_zcon_max + 1]; // cached is_zero_type nodes 188 void init_con_caches(); 189 190 // Support both int and long caches because either might be an intptr_t, 191 // so they show up frequently in address computations. 192 193 public: 194 PhaseTransform( PhaseNumber pnum ); 195 PhaseTransform( Arena *arena, PhaseNumber pnum ); 196 PhaseTransform( PhaseTransform *phase, PhaseNumber pnum ); 197 198 Arena* arena() { return _arena; } 199 Type_Array& types() { return _types; } 200 void replace_types(Type_Array new_types) { 201 _types = new_types; 202 } 203 // _nodes is used in varying ways by subclasses, which define local accessors 204 uint nodes_size() { 205 return _nodes.size(); 206 } 207 208 public: 209 // Get a previously recorded type for the node n. 210 // This type must already have been recorded. 211 // If you want the type of a very new (untransformed) node, 212 // you must use type_or_null, and test the result for NULL. 213 const Type* type(const Node* n) const { 214 assert(n != NULL, "must not be null"); 215 const Type* t = _types.fast_lookup(n->_idx); 216 assert(t != NULL, "must set before get"); 217 return t; 218 } 219 // Get a previously recorded type for the node n, 220 // or else return NULL if there is none. 221 const Type* type_or_null(const Node* n) const { 222 return _types.fast_lookup(n->_idx); 223 } 224 // Record a type for a node. 225 void set_type(const Node* n, const Type *t) { 226 assert(t != NULL, "type must not be null"); |