Mercurial > hg > truffle
annotate src/share/vm/opto/phaseX.hpp @ 5274:e72dd6533eb9
documented importance of nmethod::_graal_compiled_method wrt code unloading and GC
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 23 Apr 2012 15:42:30 +0200 |
parents | 35acf8f0a2e4 |
children | 5e990493719e |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1489
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_OPTO_PHASEX_HPP |
26 #define SHARE_VM_OPTO_PHASEX_HPP | |
27 | |
28 #include "libadt/dict.hpp" | |
29 #include "libadt/vectset.hpp" | |
30 #include "memory/resourceArea.hpp" | |
31 #include "opto/memnode.hpp" | |
32 #include "opto/node.hpp" | |
33 #include "opto/phase.hpp" | |
34 #include "opto/type.hpp" | |
35 | |
0 | 36 class Compile; |
37 class ConINode; | |
38 class ConLNode; | |
39 class Node; | |
40 class Type; | |
41 class PhaseTransform; | |
42 class PhaseGVN; | |
43 class PhaseIterGVN; | |
44 class PhaseCCP; | |
45 class PhasePeephole; | |
46 class PhaseRegAlloc; | |
47 | |
48 | |
49 //----------------------------------------------------------------------------- | |
50 // Expandable closed hash-table of nodes, initialized to NULL. | |
51 // Note that the constructor just zeros things | |
52 // Storage is reclaimed when the Arena's lifetime is over. | |
53 class NodeHash : public StackObj { | |
54 protected: | |
55 Arena *_a; // Arena to allocate in | |
56 uint _max; // Size of table (power of 2) | |
57 uint _inserts; // For grow and debug, count of hash_inserts | |
58 uint _insert_limit; // 'grow' when _inserts reaches _insert_limit | |
59 Node **_table; // Hash table of Node pointers | |
60 Node *_sentinel; // Replaces deleted entries in hash table | |
61 | |
62 public: | |
63 NodeHash(uint est_max_size); | |
64 NodeHash(Arena *arena, uint est_max_size); | |
65 NodeHash(NodeHash *use_this_state); | |
66 #ifdef ASSERT | |
67 ~NodeHash(); // Unlock all nodes upon destruction of table. | |
68 void operator=(const NodeHash&); // Unlock all nodes upon replacement of table. | |
69 #endif | |
70 Node *hash_find(const Node*);// Find an equivalent version in hash table | |
71 Node *hash_find_insert(Node*);// If not in table insert else return found node | |
72 void hash_insert(Node*); // Insert into hash table | |
73 bool hash_delete(const Node*);// Replace with _sentinel in hash table | |
74 void check_grow() { | |
75 _inserts++; | |
76 if( _inserts == _insert_limit ) { grow(); } | |
77 assert( _inserts <= _insert_limit, "hash table overflow"); | |
78 assert( _inserts < _max, "hash table overflow" ); | |
79 } | |
80 static uint round_up(uint); // Round up to nearest power of 2 | |
81 void grow(); // Grow _table to next power of 2 and rehash | |
82 // Return 75% of _max, rounded up. | |
83 uint insert_limit() const { return _max - (_max>>2); } | |
84 | |
85 void clear(); // Set all entries to NULL, keep storage. | |
86 // Size of hash table | |
87 uint size() const { return _max; } | |
88 // Return Node* at index in table | |
89 Node *at(uint table_index) { | |
90 assert(table_index < _max, "Must be within table"); | |
91 return _table[table_index]; | |
92 } | |
93 | |
94 void remove_useless_nodes(VectorSet &useful); // replace with sentinel | |
95 | |
96 Node *sentinel() { return _sentinel; } | |
97 | |
98 #ifndef PRODUCT | |
99 Node *find_index(uint idx); // For debugging | |
100 void dump(); // For debugging, dump statistics | |
101 #endif | |
102 uint _grows; // For debugging, count of table grow()s | |
103 uint _look_probes; // For debugging, count of hash probes | |
104 uint _lookup_hits; // For debugging, count of hash_finds | |
105 uint _lookup_misses; // For debugging, count of hash_finds | |
106 uint _insert_probes; // For debugging, count of hash probes | |
107 uint _delete_probes; // For debugging, count of hash probes for deletes | |
108 uint _delete_hits; // For debugging, count of hash probes for deletes | |
109 uint _delete_misses; // For debugging, count of hash probes for deletes | |
110 uint _total_inserts; // For debugging, total inserts into hash table | |
111 uint _total_insert_probes; // For debugging, total probes while inserting | |
112 }; | |
113 | |
114 | |
115 //----------------------------------------------------------------------------- | |
116 // Map dense integer indices to Types. Uses classic doubling-array trick. | |
117 // Abstractly provides an infinite array of Type*'s, initialized to NULL. | |
118 // Note that the constructor just zeros things, and since I use Arena | |
119 // allocation I do not need a destructor to reclaim storage. | |
120 // Despite the general name, this class is customized for use by PhaseTransform. | |
121 class Type_Array : public StackObj { | |
122 Arena *_a; // Arena to allocate in | |
123 uint _max; | |
124 const Type **_types; | |
125 void grow( uint i ); // Grow array node to fit | |
126 const Type *operator[] ( uint i ) const // Lookup, or NULL for not mapped | |
127 { return (i<_max) ? _types[i] : (Type*)NULL; } | |
128 friend class PhaseTransform; | |
129 public: | |
130 Type_Array(Arena *a) : _a(a), _max(0), _types(0) {} | |
131 Type_Array(Type_Array *ta) : _a(ta->_a), _max(ta->_max), _types(ta->_types) { } | |
132 const Type *fast_lookup(uint i) const{assert(i<_max,"oob");return _types[i];} | |
133 // Extend the mapping: index i maps to Type *n. | |
134 void map( uint i, const Type *n ) { if( i>=_max ) grow(i); _types[i] = n; } | |
135 uint Size() const { return _max; } | |
136 #ifndef PRODUCT | |
137 void dump() const; | |
138 #endif | |
139 }; | |
140 | |
141 | |
142 //------------------------------PhaseRemoveUseless----------------------------- | |
143 // Remove useless nodes from GVN hash-table, worklist, and graph | |
144 class PhaseRemoveUseless : public Phase { | |
145 protected: | |
146 Unique_Node_List _useful; // Nodes reachable from root | |
147 // list is allocated from current resource area | |
148 public: | |
149 PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist ); | |
150 | |
151 Unique_Node_List *get_useful() { return &_useful; } | |
152 }; | |
153 | |
154 | |
155 //------------------------------PhaseTransform--------------------------------- | |
156 // Phases that analyze, then transform. Constructing the Phase object does any | |
157 // global or slow analysis. The results are cached later for a fast | |
158 // transformation pass. When the Phase object is deleted the cached analysis | |
159 // results are deleted. | |
160 class PhaseTransform : public Phase { | |
161 protected: | |
162 Arena* _arena; | |
163 Node_Array _nodes; // Map old node indices to new nodes. | |
164 Type_Array _types; // Map old node indices to Types. | |
165 | |
166 // ConNode caches: | |
167 enum { _icon_min = -1 * HeapWordSize, | |
168 _icon_max = 16 * HeapWordSize, | |
169 _lcon_min = _icon_min, | |
170 _lcon_max = _icon_max, | |
171 _zcon_max = (uint)T_CONFLICT | |
172 }; | |
173 ConINode* _icons[_icon_max - _icon_min + 1]; // cached jint constant nodes | |
174 ConLNode* _lcons[_lcon_max - _lcon_min + 1]; // cached jlong constant nodes | |
175 ConNode* _zcons[_zcon_max + 1]; // cached is_zero_type nodes | |
176 void init_con_caches(); | |
177 | |
178 // Support both int and long caches because either might be an intptr_t, | |
179 // so they show up frequently in address computations. | |
180 | |
181 public: | |
182 PhaseTransform( PhaseNumber pnum ); | |
183 PhaseTransform( Arena *arena, PhaseNumber pnum ); | |
184 PhaseTransform( PhaseTransform *phase, PhaseNumber pnum ); | |
185 | |
186 Arena* arena() { return _arena; } | |
187 Type_Array& types() { return _types; } | |
188 // _nodes is used in varying ways by subclasses, which define local accessors | |
189 | |
190 public: | |
191 // Get a previously recorded type for the node n. | |
192 // This type must already have been recorded. | |
193 // If you want the type of a very new (untransformed) node, | |
194 // you must use type_or_null, and test the result for NULL. | |
195 const Type* type(const Node* n) const { | |
196 const Type* t = _types.fast_lookup(n->_idx); | |
197 assert(t != NULL, "must set before get"); | |
198 return t; | |
199 } | |
200 // Get a previously recorded type for the node n, | |
201 // or else return NULL if there is none. | |
202 const Type* type_or_null(const Node* n) const { | |
203 return _types.fast_lookup(n->_idx); | |
204 } | |
205 // Record a type for a node. | |
206 void set_type(const Node* n, const Type *t) { | |
207 assert(t != NULL, "type must not be null"); | |
208 _types.map(n->_idx, t); | |
209 } | |
210 // Record an initial type for a node, the node's bottom type. | |
211 void set_type_bottom(const Node* n) { | |
212 // Use this for initialization when bottom_type() (or better) is not handy. | |
213 // Usually the initialization shoudl be to n->Value(this) instead, | |
214 // or a hand-optimized value like Type::MEMORY or Type::CONTROL. | |
215 assert(_types[n->_idx] == NULL, "must set the initial type just once"); | |
216 _types.map(n->_idx, n->bottom_type()); | |
217 } | |
218 // Make sure the types array is big enough to record a size for the node n. | |
219 // (In product builds, we never want to do range checks on the types array!) | |
220 void ensure_type_or_null(const Node* n) { | |
221 if (n->_idx >= _types.Size()) | |
222 _types.map(n->_idx, NULL); // Grow the types array as needed. | |
223 } | |
224 | |
225 // Utility functions: | |
226 const TypeInt* find_int_type( Node* n); | |
227 const TypeLong* find_long_type(Node* n); | |
228 jint find_int_con( Node* n, jint value_if_unknown) { | |
229 const TypeInt* t = find_int_type(n); | |
230 return (t != NULL && t->is_con()) ? t->get_con() : value_if_unknown; | |
231 } | |
232 jlong find_long_con(Node* n, jlong value_if_unknown) { | |
233 const TypeLong* t = find_long_type(n); | |
234 return (t != NULL && t->is_con()) ? t->get_con() : value_if_unknown; | |
235 } | |
236 | |
237 // Make an idealized constant, i.e., one of ConINode, ConPNode, ConFNode, etc. | |
238 // Same as transform(ConNode::make(t)). | |
239 ConNode* makecon(const Type* t); | |
240 virtual ConNode* uncached_makecon(const Type* t) // override in PhaseValues | |
241 { ShouldNotCallThis(); return NULL; } | |
242 | |
243 // Fast int or long constant. Same as TypeInt::make(i) or TypeLong::make(l). | |
244 ConINode* intcon(jint i); | |
245 ConLNode* longcon(jlong l); | |
246 | |
247 // Fast zero or null constant. Same as makecon(Type::get_zero_type(bt)). | |
248 ConNode* zerocon(BasicType bt); | |
249 | |
250 // Return a node which computes the same function as this node, but | |
251 // in a faster or cheaper fashion. | |
252 virtual Node *transform( Node *n ) = 0; | |
253 | |
254 // Return whether two Nodes are equivalent. | |
255 // Must not be recursive, since the recursive version is built from this. | |
256 // For pessimistic optimizations this is simply pointer equivalence. | |
257 bool eqv(const Node* n1, const Node* n2) const { return n1 == n2; } | |
258 | |
259 // For pessimistic passes, the return type must monotonically narrow. | |
260 // For optimistic passes, the return type must monotonically widen. | |
261 // It is possible to get into a "death march" in either type of pass, | |
262 // where the types are continually moving but it will take 2**31 or | |
263 // more steps to converge. This doesn't happen on most normal loops. | |
264 // | |
265 // Here is an example of a deadly loop for an optimistic pass, along | |
266 // with a partial trace of inferred types: | |
267 // x = phi(0,x'); L: x' = x+1; if (x' >= 0) goto L; | |
268 // 0 1 join([0..max], 1) | |
269 // [0..1] [1..2] join([0..max], [1..2]) | |
270 // [0..2] [1..3] join([0..max], [1..3]) | |
271 // ... ... ... | |
272 // [0..max] [min]u[1..max] join([0..max], [min..max]) | |
273 // [0..max] ==> fixpoint | |
274 // We would have proven, the hard way, that the iteration space is all | |
275 // non-negative ints, with the loop terminating due to 32-bit overflow. | |
276 // | |
277 // Here is the corresponding example for a pessimistic pass: | |
278 // x = phi(0,x'); L: x' = x-1; if (x' >= 0) goto L; | |
279 // int int join([0..max], int) | |
280 // [0..max] [-1..max-1] join([0..max], [-1..max-1]) | |
281 // [0..max-1] [-1..max-2] join([0..max], [-1..max-2]) | |
282 // ... ... ... | |
283 // [0..1] [-1..0] join([0..max], [-1..0]) | |
284 // 0 -1 join([0..max], -1) | |
285 // 0 == fixpoint | |
286 // We would have proven, the hard way, that the iteration space is {0}. | |
287 // (Usually, other optimizations will make the "if (x >= 0)" fold up | |
288 // before we get into trouble. But not always.) | |
289 // | |
290 // It's a pleasant thing to observe that the pessimistic pass | |
291 // will make short work of the optimistic pass's deadly loop, | |
292 // and vice versa. That is a good example of the complementary | |
293 // purposes of the CCP (optimistic) vs. GVN (pessimistic) phases. | |
294 // | |
295 // In any case, only widen or narrow a few times before going to the | |
296 // correct flavor of top or bottom. | |
297 // | |
298 // This call only needs to be made once as the data flows around any | |
299 // given cycle. We do it at Phis, and nowhere else. | |
300 // The types presented are the new type of a phi (computed by PhiNode::Value) | |
301 // and the previously computed type, last time the phi was visited. | |
302 // | |
303 // The third argument is upper limit for the saturated value, | |
304 // if the phase wishes to widen the new_type. | |
305 // If the phase is narrowing, the old type provides a lower limit. | |
306 // Caller guarantees that old_type and new_type are no higher than limit_type. | |
307 virtual const Type* saturate(const Type* new_type, const Type* old_type, | |
308 const Type* limit_type) const | |
309 { ShouldNotCallThis(); return NULL; } | |
310 | |
311 #ifndef PRODUCT | |
312 void dump_old2new_map() const; | |
313 void dump_new( uint new_lidx ) const; | |
314 void dump_types() const; | |
315 void dump_nodes_and_types(const Node *root, uint depth, bool only_ctrl = true); | |
316 void dump_nodes_and_types_recur( const Node *n, uint depth, bool only_ctrl, VectorSet &visited); | |
317 | |
318 uint _count_progress; // For profiling, count transforms that make progress | |
1489
cff162798819
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
1080
diff
changeset
|
319 void set_progress() { ++_count_progress; assert( allow_progress(),"No progress allowed during verification"); } |
0 | 320 void clear_progress() { _count_progress = 0; } |
321 uint made_progress() const { return _count_progress; } | |
322 | |
323 uint _count_transforms; // For profiling, count transforms performed | |
324 void set_transforms() { ++_count_transforms; } | |
325 void clear_transforms() { _count_transforms = 0; } | |
326 uint made_transforms() const{ return _count_transforms; } | |
327 | |
328 bool _allow_progress; // progress not allowed during verification pass | |
329 void set_allow_progress(bool allow) { _allow_progress = allow; } | |
330 bool allow_progress() { return _allow_progress; } | |
331 #endif | |
332 }; | |
333 | |
334 //------------------------------PhaseValues------------------------------------ | |
335 // Phase infrastructure to support values | |
336 class PhaseValues : public PhaseTransform { | |
337 protected: | |
338 NodeHash _table; // Hash table for value-numbering | |
339 | |
340 public: | |
341 PhaseValues( Arena *arena, uint est_max_size ); | |
342 PhaseValues( PhaseValues *pt ); | |
343 PhaseValues( PhaseValues *ptv, const char *dummy ); | |
344 NOT_PRODUCT( ~PhaseValues(); ) | |
345 virtual PhaseIterGVN *is_IterGVN() { return 0; } | |
346 | |
347 // Some Ideal and other transforms delete --> modify --> insert values | |
348 bool hash_delete(Node *n) { return _table.hash_delete(n); } | |
349 void hash_insert(Node *n) { _table.hash_insert(n); } | |
350 Node *hash_find_insert(Node *n){ return _table.hash_find_insert(n); } | |
351 Node *hash_find(const Node *n) { return _table.hash_find(n); } | |
352 | |
353 // Used after parsing to eliminate values that are no longer in program | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
948
diff
changeset
|
354 void remove_useless_nodes(VectorSet &useful) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
948
diff
changeset
|
355 _table.remove_useless_nodes(useful); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
948
diff
changeset
|
356 // this may invalidate cached cons so reset the cache |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
948
diff
changeset
|
357 init_con_caches(); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
948
diff
changeset
|
358 } |
0 | 359 |
360 virtual ConNode* uncached_makecon(const Type* t); // override from PhaseTransform | |
361 | |
362 virtual const Type* saturate(const Type* new_type, const Type* old_type, | |
363 const Type* limit_type) const | |
364 { return new_type; } | |
365 | |
366 #ifndef PRODUCT | |
367 uint _count_new_values; // For profiling, count new values produced | |
368 void inc_new_values() { ++_count_new_values; } | |
369 void clear_new_values() { _count_new_values = 0; } | |
370 uint made_new_values() const { return _count_new_values; } | |
371 #endif | |
372 }; | |
373 | |
374 | |
375 //------------------------------PhaseGVN--------------------------------------- | |
376 // Phase for performing local, pessimistic GVN-style optimizations. | |
377 class PhaseGVN : public PhaseValues { | |
378 public: | |
379 PhaseGVN( Arena *arena, uint est_max_size ) : PhaseValues( arena, est_max_size ) {} | |
380 PhaseGVN( PhaseGVN *gvn ) : PhaseValues( gvn ) {} | |
381 PhaseGVN( PhaseGVN *gvn, const char *dummy ) : PhaseValues( gvn, dummy ) {} | |
382 | |
383 // Return a node which computes the same function as this node, but | |
384 // in a faster or cheaper fashion. | |
385 Node *transform( Node *n ); | |
386 Node *transform_no_reclaim( Node *n ); | |
387 | |
388 // Check for a simple dead loop when a data node references itself. | |
389 DEBUG_ONLY(void dead_loop_check(Node *n);) | |
390 }; | |
391 | |
392 //------------------------------PhaseIterGVN----------------------------------- | |
393 // Phase for iteratively performing local, pessimistic GVN-style optimizations. | |
394 // and ideal transformations on the graph. | |
395 class PhaseIterGVN : public PhaseGVN { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
73
diff
changeset
|
396 private: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
73
diff
changeset
|
397 bool _delay_transform; // When true simply register the node when calling transform |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
73
diff
changeset
|
398 // instead of actually optimizing it |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
73
diff
changeset
|
399 |
0 | 400 // Idealize old Node 'n' with respect to its inputs and its value |
401 virtual Node *transform_old( Node *a_node ); | |
1621
6027dddc26c6
6677629: PhaseIterGVN::subsume_node() should call hash_delete() and add_users_to_worklist()
kvn
parents:
1552
diff
changeset
|
402 |
6027dddc26c6
6677629: PhaseIterGVN::subsume_node() should call hash_delete() and add_users_to_worklist()
kvn
parents:
1552
diff
changeset
|
403 // Subsume users of node 'old' into node 'nn' |
6027dddc26c6
6677629: PhaseIterGVN::subsume_node() should call hash_delete() and add_users_to_worklist()
kvn
parents:
1552
diff
changeset
|
404 void subsume_node( Node *old, Node *nn ); |
6027dddc26c6
6677629: PhaseIterGVN::subsume_node() should call hash_delete() and add_users_to_worklist()
kvn
parents:
1552
diff
changeset
|
405 |
0 | 406 protected: |
407 | |
408 // Idealize new Node 'n' with respect to its inputs and its value | |
409 virtual Node *transform( Node *a_node ); | |
410 | |
411 // Warm up hash table, type table and initial worklist | |
412 void init_worklist( Node *a_root ); | |
413 | |
414 virtual const Type* saturate(const Type* new_type, const Type* old_type, | |
415 const Type* limit_type) const; | |
416 // Usually returns new_type. Returns old_type if new_type is only a slight | |
417 // improvement, such that it would take many (>>10) steps to reach 2**32. | |
418 | |
419 public: | |
420 PhaseIterGVN( PhaseIterGVN *igvn ); // Used by CCP constructor | |
421 PhaseIterGVN( PhaseGVN *gvn ); // Used after Parser | |
422 PhaseIterGVN( PhaseIterGVN *igvn, const char *dummy ); // Used after +VerifyOpto | |
423 | |
424 virtual PhaseIterGVN *is_IterGVN() { return this; } | |
425 | |
426 Unique_Node_List _worklist; // Iterative worklist | |
427 | |
428 // Given def-use info and an initial worklist, apply Node::Ideal, | |
429 // Node::Value, Node::Identity, hash-based value numbering, Node::Ideal_DU | |
430 // and dominator info to a fixed point. | |
431 void optimize(); | |
432 | |
433 // Register a new node with the iter GVN pass without transforming it. | |
434 // Used when we need to restructure a Region/Phi area and all the Regions | |
435 // and Phis need to complete this one big transform before any other | |
436 // transforms can be triggered on the region. | |
437 // Optional 'orig' is an earlier version of this node. | |
438 // It is significant only for debugging and profiling. | |
439 Node* register_new_node_with_optimizer(Node* n, Node* orig = NULL); | |
440 | |
441 // Kill a globally dead Node. It is allowed to have uses which are | |
442 // assumed dead and left 'in limbo'. | |
443 void remove_globally_dead_node( Node *dead ); | |
444 | |
445 // Kill all inputs to a dead node, recursively making more dead nodes. | |
446 // The Node must be dead locally, i.e., have no uses. | |
447 void remove_dead_node( Node *dead ) { | |
448 assert(dead->outcnt() == 0 && !dead->is_top(), "node must be dead"); | |
449 remove_globally_dead_node(dead); | |
450 } | |
451 | |
452 // Add users of 'n' to worklist | |
453 void add_users_to_worklist0( Node *n ); | |
454 void add_users_to_worklist ( Node *n ); | |
455 | |
73
a8880a78d355
6259129: (Escape Analysis) scalar replacement for not escaping objects
kvn
parents:
0
diff
changeset
|
456 // Replace old node with new one. |
a8880a78d355
6259129: (Escape Analysis) scalar replacement for not escaping objects
kvn
parents:
0
diff
changeset
|
457 void replace_node( Node *old, Node *nn ) { |
a8880a78d355
6259129: (Escape Analysis) scalar replacement for not escaping objects
kvn
parents:
0
diff
changeset
|
458 add_users_to_worklist(old); |
1621
6027dddc26c6
6677629: PhaseIterGVN::subsume_node() should call hash_delete() and add_users_to_worklist()
kvn
parents:
1552
diff
changeset
|
459 hash_delete(old); // Yank from hash before hacking edges |
73
a8880a78d355
6259129: (Escape Analysis) scalar replacement for not escaping objects
kvn
parents:
0
diff
changeset
|
460 subsume_node(old, nn); |
a8880a78d355
6259129: (Escape Analysis) scalar replacement for not escaping objects
kvn
parents:
0
diff
changeset
|
461 } |
a8880a78d355
6259129: (Escape Analysis) scalar replacement for not escaping objects
kvn
parents:
0
diff
changeset
|
462 |
851
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
463 bool delay_transform() const { return _delay_transform; } |
fc4be448891f
6851742: (EA) allocation elimination doesn't work with UseG1GC
kvn
parents:
196
diff
changeset
|
464 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
73
diff
changeset
|
465 void set_delay_transform(bool delay) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
73
diff
changeset
|
466 _delay_transform = delay; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
73
diff
changeset
|
467 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
73
diff
changeset
|
468 |
2445 | 469 // Clone loop predicates. Defined in loopTransform.cpp. |
3345 | 470 Node* clone_loop_predicates(Node* old_entry, Node* new_entry, bool clone_limit_check); |
2445 | 471 // Create a new if below new_entry for the predicate to be cloned |
472 ProjNode* create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry, | |
473 Deoptimization::DeoptReason reason); | |
474 | |
0 | 475 #ifndef PRODUCT |
476 protected: | |
477 // Sub-quadratic implementation of VerifyIterativeGVN. | |
478 unsigned long _verify_counter; | |
479 unsigned long _verify_full_passes; | |
480 enum { _verify_window_size = 30 }; | |
481 Node* _verify_window[_verify_window_size]; | |
482 void verify_step(Node* n); | |
483 #endif | |
484 }; | |
485 | |
486 //------------------------------PhaseCCP--------------------------------------- | |
487 // Phase for performing global Conditional Constant Propagation. | |
488 // Should be replaced with combined CCP & GVN someday. | |
489 class PhaseCCP : public PhaseIterGVN { | |
490 // Non-recursive. Use analysis to transform single Node. | |
491 virtual Node *transform_once( Node *n ); | |
492 | |
493 public: | |
494 PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants | |
495 NOT_PRODUCT( ~PhaseCCP(); ) | |
496 | |
497 // Worklist algorithm identifies constants | |
498 void analyze(); | |
499 // Recursive traversal of program. Used analysis to modify program. | |
500 virtual Node *transform( Node *n ); | |
501 // Do any transformation after analysis | |
502 void do_transform(); | |
503 | |
504 virtual const Type* saturate(const Type* new_type, const Type* old_type, | |
505 const Type* limit_type) const; | |
506 // Returns new_type->widen(old_type), which increments the widen bits until | |
507 // giving up with TypeInt::INT or TypeLong::LONG. | |
508 // Result is clipped to limit_type if necessary. | |
509 | |
510 #ifndef PRODUCT | |
511 static uint _total_invokes; // For profiling, count invocations | |
512 void inc_invokes() { ++PhaseCCP::_total_invokes; } | |
513 | |
514 static uint _total_constants; // For profiling, count constants found | |
515 uint _count_constants; | |
516 void clear_constants() { _count_constants = 0; } | |
517 void inc_constants() { ++_count_constants; } | |
518 uint count_constants() const { return _count_constants; } | |
519 | |
520 static void print_statistics(); | |
521 #endif | |
522 }; | |
523 | |
524 | |
525 //------------------------------PhasePeephole---------------------------------- | |
526 // Phase for performing peephole optimizations on register allocated basic blocks. | |
527 class PhasePeephole : public PhaseTransform { | |
528 PhaseRegAlloc *_regalloc; | |
529 PhaseCFG &_cfg; | |
530 // Recursive traversal of program. Pure function is unused in this phase | |
531 virtual Node *transform( Node *n ); | |
532 | |
533 public: | |
534 PhasePeephole( PhaseRegAlloc *regalloc, PhaseCFG &cfg ); | |
535 NOT_PRODUCT( ~PhasePeephole(); ) | |
536 | |
537 // Do any transformation after analysis | |
538 void do_transform(); | |
539 | |
540 #ifndef PRODUCT | |
541 static uint _total_peepholes; // For profiling, count peephole rules applied | |
542 uint _count_peepholes; | |
543 void clear_peepholes() { _count_peepholes = 0; } | |
544 void inc_peepholes() { ++_count_peepholes; } | |
545 uint count_peepholes() const { return _count_peepholes; } | |
546 | |
547 static void print_statistics(); | |
548 #endif | |
549 }; | |
1972 | 550 |
551 #endif // SHARE_VM_OPTO_PHASEX_HPP |