author | iveresov |
Thu, 22 Jan 2015 11:25:23 -0800 | |
changeset 28723 | 0a36120cb225 |
parent 28648 | 102bdbb42723 |
child 30624 | 2e1803c8a26d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
20704
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3678
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3678
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3678
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_OPTO_CHAITIN_HPP |
26 |
#define SHARE_VM_OPTO_CHAITIN_HPP |
|
27 |
||
28 |
#include "code/vmreg.hpp" |
|
29 |
#include "memory/resourceArea.hpp" |
|
30 |
#include "opto/connode.hpp" |
|
31 |
#include "opto/live.hpp" |
|
32 |
#include "opto/matcher.hpp" |
|
33 |
#include "opto/phase.hpp" |
|
34 |
#include "opto/regalloc.hpp" |
|
35 |
#include "opto/regmask.hpp" |
|
22914
0712db174bbb
8032656: Tag the MachSpillCopies with purpose information
adlertz
parents:
22912
diff
changeset
|
36 |
#include "opto/machnode.hpp" |
7397 | 37 |
|
1 | 38 |
class LoopTree; |
39 |
class Matcher; |
|
40 |
class PhaseCFG; |
|
41 |
class PhaseLive; |
|
42 |
class PhaseRegAlloc; |
|
43 |
class PhaseChaitin; |
|
44 |
||
45 |
#define OPTO_DEBUG_SPLIT_FREQ BLOCK_FREQUENCY(0.001) |
|
46 |
#define OPTO_LRG_HIGH_FREQ BLOCK_FREQUENCY(0.25) |
|
47 |
||
48 |
//------------------------------LRG-------------------------------------------- |
|
49 |
// Live-RanGe structure. |
|
50 |
class LRG : public ResourceObj { |
|
10547 | 51 |
friend class VMStructs; |
1 | 52 |
public: |
20704
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
53 |
static const uint AllStack_size = 0xFFFFF; // This mask size is used to tell that the mask of this LRG supports stack positions |
1 | 54 |
enum { SPILL_REG=29999 }; // Register number of a spilled LRG |
55 |
||
56 |
double _cost; // 2 for loads/1 for stores times block freq |
|
57 |
double _area; // Sum of all simultaneously live values |
|
58 |
double score() const; // Compute score from cost and area |
|
59 |
double _maxfreq; // Maximum frequency of any def or use |
|
60 |
||
61 |
Node *_def; // Check for multi-def live ranges |
|
62 |
#ifndef PRODUCT |
|
63 |
GrowableArray<Node*>* _defs; |
|
64 |
#endif |
|
65 |
||
66 |
uint _risk_bias; // Index of LRG which we want to avoid color |
|
67 |
uint _copy_bias; // Index of LRG which we want to share color |
|
68 |
||
69 |
uint _next; // Index of next LRG in linked list |
|
70 |
uint _prev; // Index of prev LRG in linked list |
|
71 |
private: |
|
72 |
uint _reg; // Chosen register; undefined if mask is plural |
|
73 |
public: |
|
74 |
// Return chosen register for this LRG. Error if the LRG is not bound to |
|
75 |
// a single register. |
|
76 |
OptoReg::Name reg() const { return OptoReg::Name(_reg); } |
|
77 |
void set_reg( OptoReg::Name r ) { _reg = r; } |
|
78 |
||
79 |
private: |
|
80 |
uint _eff_degree; // Effective degree: Sum of neighbors _num_regs |
|
81 |
public: |
|
20704
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
82 |
int degree() const { assert( _degree_valid , "" ); return _eff_degree; } |
1 | 83 |
// Degree starts not valid and any change to the IFG neighbor |
84 |
// set makes it not valid. |
|
20704
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
85 |
void set_degree( uint degree ) { |
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
86 |
_eff_degree = degree; |
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
87 |
debug_only(_degree_valid = 1;) |
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
88 |
assert(!_mask.is_AllStack() || (_mask.is_AllStack() && lo_degree()), "_eff_degree can't be bigger than AllStack_size - _num_regs if the mask supports stack registers"); |
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
89 |
} |
1 | 90 |
// Made a change that hammered degree |
91 |
void invalid_degree() { debug_only(_degree_valid=0;) } |
|
92 |
// Incrementally modify degree. If it was correct, it should remain correct |
|
20704
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
93 |
void inc_degree( uint mod ) { |
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
94 |
_eff_degree += mod; |
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
95 |
assert(!_mask.is_AllStack() || (_mask.is_AllStack() && lo_degree()), "_eff_degree can't be bigger than AllStack_size - _num_regs if the mask supports stack registers"); |
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
96 |
} |
1 | 97 |
// Compute the degree between 2 live ranges |
98 |
int compute_degree( LRG &l ) const; |
|
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
99 |
bool mask_is_nonempty_and_up() const { |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
100 |
return mask().is_UP() && mask_size(); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
101 |
} |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
102 |
bool is_float_or_vector() const { |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
103 |
return _is_float || _is_vector; |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
104 |
} |
1 | 105 |
|
106 |
private: |
|
107 |
RegMask _mask; // Allowed registers for this LRG |
|
108 |
uint _mask_size; // cache of _mask.Size(); |
|
109 |
public: |
|
20704
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
110 |
int compute_mask_size() const { return _mask.is_AllStack() ? AllStack_size : _mask.Size(); } |
1 | 111 |
void set_mask_size( int size ) { |
20704
b689a120e974
8011415: CTW on Sparc: assert(lrg.lo_degree()) failed:
adlertz
parents:
20007
diff
changeset
|
112 |
assert((size == (int)AllStack_size) || (size == (int)_mask.Size()), ""); |
1 | 113 |
_mask_size = size; |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
114 |
#ifdef ASSERT |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
115 |
_msize_valid=1; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
116 |
if (_is_vector) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
117 |
assert(!_fat_proj, "sanity"); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
118 |
_mask.verify_sets(_num_regs); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
119 |
} else if (_num_regs == 2 && !_fat_proj) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
120 |
_mask.verify_pairs(); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
121 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
122 |
#endif |
1 | 123 |
} |
124 |
void compute_set_mask_size() { set_mask_size(compute_mask_size()); } |
|
125 |
int mask_size() const { assert( _msize_valid, "mask size not valid" ); |
|
126 |
return _mask_size; } |
|
127 |
// Get the last mask size computed, even if it does not match the |
|
128 |
// count of bits in the current mask. |
|
129 |
int get_invalid_mask_size() const { return _mask_size; } |
|
130 |
const RegMask &mask() const { return _mask; } |
|
131 |
void set_mask( const RegMask &rm ) { _mask = rm; debug_only(_msize_valid=0;)} |
|
132 |
void AND( const RegMask &rm ) { _mask.AND(rm); debug_only(_msize_valid=0;)} |
|
133 |
void SUBTRACT( const RegMask &rm ) { _mask.SUBTRACT(rm); debug_only(_msize_valid=0;)} |
|
134 |
void Clear() { _mask.Clear() ; debug_only(_msize_valid=1); _mask_size = 0; } |
|
135 |
void Set_All() { _mask.Set_All(); debug_only(_msize_valid=1); _mask_size = RegMask::CHUNK_SIZE; } |
|
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
136 |
|
1 | 137 |
void Insert( OptoReg::Name reg ) { _mask.Insert(reg); debug_only(_msize_valid=0;) } |
138 |
void Remove( OptoReg::Name reg ) { _mask.Remove(reg); debug_only(_msize_valid=0;) } |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
139 |
void clear_to_pairs() { _mask.clear_to_pairs(); debug_only(_msize_valid=0;) } |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
140 |
void clear_to_sets() { _mask.clear_to_sets(_num_regs); debug_only(_msize_valid=0;) } |
1 | 141 |
|
142 |
// Number of registers this live range uses when it colors |
|
143 |
private: |
|
24425 | 144 |
uint8_t _num_regs; // 2 for Longs and Doubles, 1 for all else |
1 | 145 |
// except _num_regs is kill count for fat_proj |
146 |
public: |
|
147 |
int num_regs() const { return _num_regs; } |
|
148 |
void set_num_regs( int reg ) { assert( _num_regs == reg || !_num_regs, "" ); _num_regs = reg; } |
|
149 |
||
150 |
private: |
|
151 |
// Number of physical registers this live range uses when it colors |
|
152 |
// Architecture and register-set dependent |
|
24425 | 153 |
uint8_t _reg_pressure; |
1 | 154 |
public: |
155 |
void set_reg_pressure(int i) { _reg_pressure = i; } |
|
156 |
int reg_pressure() const { return _reg_pressure; } |
|
157 |
||
158 |
// How much 'wiggle room' does this live range have? |
|
159 |
// How many color choices can it make (scaled by _num_regs)? |
|
160 |
int degrees_of_freedom() const { return mask_size() - _num_regs; } |
|
161 |
// Bound LRGs have ZERO degrees of freedom. We also count |
|
162 |
// must_spill as bound. |
|
163 |
bool is_bound () const { return _is_bound; } |
|
164 |
// Negative degrees-of-freedom; even with no neighbors this |
|
165 |
// live range must spill. |
|
166 |
bool not_free() const { return degrees_of_freedom() < 0; } |
|
167 |
// Is this live range of "low-degree"? Trivially colorable? |
|
168 |
bool lo_degree () const { return degree() <= degrees_of_freedom(); } |
|
169 |
// Is this live range just barely "low-degree"? Trivially colorable? |
|
170 |
bool just_lo_degree () const { return degree() == degrees_of_freedom(); } |
|
171 |
||
172 |
uint _is_oop:1, // Live-range holds an oop |
|
173 |
_is_float:1, // True if in float registers |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11444
diff
changeset
|
174 |
_is_vector:1, // True if in vector registers |
1 | 175 |
_was_spilled1:1, // True if prior spilling on def |
176 |
_was_spilled2:1, // True if twice prior spilling on def |
|
177 |
_is_bound:1, // live range starts life with no |
|
178 |
// degrees of freedom. |
|
179 |
_direct_conflict:1, // True if def and use registers in conflict |
|
180 |
_must_spill:1, // live range has lost all degrees of freedom |
|
181 |
// If _fat_proj is set, live range does NOT require aligned, adjacent |
|
182 |
// registers and has NO interferences. |
|
183 |
// If _fat_proj is clear, live range requires num_regs() to be a power of |
|
184 |
// 2, and it requires registers to form an aligned, adjacent set. |
|
185 |
_fat_proj:1, // |
|
186 |
_was_lo:1, // Was lo-degree prior to coalesce |
|
187 |
_msize_valid:1, // _mask_size cache valid |
|
188 |
_degree_valid:1, // _degree cache valid |
|
189 |
_has_copy:1, // Adjacent to some copy instruction |
|
190 |
_at_risk:1; // Simplify says this guy is at risk to spill |
|
191 |
||
192 |
||
193 |
// Alive if non-zero, dead if zero |
|
194 |
bool alive() const { return _def != NULL; } |
|
1057
44220ef9a775
6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents:
670
diff
changeset
|
195 |
bool is_multidef() const { return _def == NodeSentinel; } |
44220ef9a775
6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents:
670
diff
changeset
|
196 |
bool is_singledef() const { return _def != NodeSentinel; } |
1 | 197 |
|
198 |
#ifndef PRODUCT |
|
199 |
void dump( ) const; |
|
200 |
#endif |
|
201 |
}; |
|
202 |
||
203 |
//------------------------------IFG-------------------------------------------- |
|
204 |
// InterFerence Graph |
|
205 |
// An undirected graph implementation. Created with a fixed number of |
|
206 |
// vertices. Edges can be added & tested. Vertices can be removed, then |
|
207 |
// added back later with all edges intact. Can add edges between one vertex |
|
208 |
// and a list of other vertices. Can union vertices (and their edges) |
|
209 |
// together. The IFG needs to be really really fast, and also fairly |
|
210 |
// abstract! It needs abstraction so I can fiddle with the implementation to |
|
211 |
// get even more speed. |
|
212 |
class PhaseIFG : public Phase { |
|
10547 | 213 |
friend class VMStructs; |
1 | 214 |
// Current implementation: a triangular adjacency list. |
215 |
||
216 |
// Array of adjacency-lists, indexed by live-range number |
|
217 |
IndexSet *_adjs; |
|
218 |
||
219 |
// Assertion bit for proper use of Squaring |
|
220 |
bool _is_square; |
|
221 |
||
222 |
// Live range structure goes here |
|
223 |
LRG *_lrgs; // Array of LRG structures |
|
224 |
||
225 |
public: |
|
226 |
// Largest live-range number |
|
227 |
uint _maxlrg; |
|
228 |
||
229 |
Arena *_arena; |
|
230 |
||
231 |
// Keep track of inserted and deleted Nodes |
|
232 |
VectorSet *_yanked; |
|
233 |
||
234 |
PhaseIFG( Arena *arena ); |
|
235 |
void init( uint maxlrg ); |
|
236 |
||
237 |
// Add edge between a and b. Returns true if actually addded. |
|
238 |
int add_edge( uint a, uint b ); |
|
239 |
||
240 |
// Add edge between a and everything in the vector |
|
241 |
void add_vector( uint a, IndexSet *vec ); |
|
242 |
||
243 |
// Test for edge existance |
|
244 |
int test_edge( uint a, uint b ) const; |
|
245 |
||
246 |
// Square-up matrix for faster Union |
|
247 |
void SquareUp(); |
|
248 |
||
249 |
// Return number of LRG neighbors |
|
250 |
uint neighbor_cnt( uint a ) const { return _adjs[a].count(); } |
|
251 |
// Union edges of b into a on Squared-up matrix |
|
252 |
void Union( uint a, uint b ); |
|
253 |
// Test for edge in Squared-up matrix |
|
254 |
int test_edge_sq( uint a, uint b ) const; |
|
255 |
// Yank a Node and all connected edges from the IFG. Be prepared to |
|
256 |
// re-insert the yanked Node in reverse order of yanking. Return a |
|
257 |
// list of neighbors (edges) yanked. |
|
258 |
IndexSet *remove_node( uint a ); |
|
259 |
// Reinsert a yanked Node |
|
260 |
void re_insert( uint a ); |
|
261 |
// Return set of neighbors |
|
262 |
IndexSet *neighbors( uint a ) const { return &_adjs[a]; } |
|
263 |
||
264 |
#ifndef PRODUCT |
|
265 |
// Dump the IFG |
|
266 |
void dump() const; |
|
267 |
void stats() const; |
|
268 |
void verify( const PhaseChaitin * ) const; |
|
269 |
#endif |
|
270 |
||
271 |
//--------------- Live Range Accessors |
|
272 |
LRG &lrgs(uint idx) const { assert(idx < _maxlrg, "oob"); return _lrgs[idx]; } |
|
273 |
||
274 |
// Compute and set effective degree. Might be folded into SquareUp(). |
|
275 |
void Compute_Effective_Degree(); |
|
276 |
||
277 |
// Compute effective degree as the sum of neighbors' _sizes. |
|
278 |
int effective_degree( uint lidx ) const; |
|
279 |
}; |
|
280 |
||
17013 | 281 |
// The LiveRangeMap class is responsible for storing node to live range id mapping. |
282 |
// Each node is mapped to a live range id (a virtual register). Nodes that are |
|
283 |
// not considered for register allocation are given live range id 0. |
|
284 |
class LiveRangeMap VALUE_OBJ_CLASS_SPEC { |
|
285 |
||
286 |
private: |
|
287 |
||
288 |
uint _max_lrg_id; |
|
289 |
||
290 |
// Union-find map. Declared as a short for speed. |
|
291 |
// Indexed by live-range number, it returns the compacted live-range number |
|
292 |
LRG_List _uf_map; |
|
293 |
||
294 |
// Map from Nodes to live ranges |
|
295 |
LRG_List _names; |
|
296 |
||
297 |
// Straight out of Tarjan's union-find algorithm |
|
298 |
uint find_compress(const Node *node) { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
299 |
uint lrg_id = find_compress(_names.at(node->_idx)); |
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
300 |
_names.at_put(node->_idx, lrg_id); |
17013 | 301 |
return lrg_id; |
302 |
} |
|
303 |
||
304 |
uint find_compress(uint lrg); |
|
305 |
||
306 |
public: |
|
307 |
||
308 |
const LRG_List& names() { |
|
309 |
return _names; |
|
310 |
} |
|
311 |
||
312 |
uint max_lrg_id() const { |
|
313 |
return _max_lrg_id; |
|
314 |
} |
|
315 |
||
316 |
void set_max_lrg_id(uint max_lrg_id) { |
|
317 |
_max_lrg_id = max_lrg_id; |
|
318 |
} |
|
319 |
||
320 |
uint size() const { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
321 |
return _names.length(); |
17013 | 322 |
} |
323 |
||
324 |
uint live_range_id(uint idx) const { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
325 |
return _names.at(idx); |
17013 | 326 |
} |
327 |
||
328 |
uint live_range_id(const Node *node) const { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
329 |
return _names.at(node->_idx); |
17013 | 330 |
} |
331 |
||
332 |
uint uf_live_range_id(uint lrg_id) const { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
333 |
return _uf_map.at(lrg_id); |
17013 | 334 |
} |
1 | 335 |
|
17013 | 336 |
void map(uint idx, uint lrg_id) { |
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
337 |
_names.at_put(idx, lrg_id); |
17013 | 338 |
} |
339 |
||
340 |
void uf_map(uint dst_lrg_id, uint src_lrg_id) { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
341 |
_uf_map.at_put(dst_lrg_id, src_lrg_id); |
17013 | 342 |
} |
343 |
||
344 |
void extend(uint idx, uint lrg_id) { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
345 |
_names.at_put_grow(idx, lrg_id); |
17013 | 346 |
} |
347 |
||
348 |
void uf_extend(uint dst_lrg_id, uint src_lrg_id) { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
349 |
_uf_map.at_put_grow(dst_lrg_id, src_lrg_id); |
17013 | 350 |
} |
351 |
||
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
352 |
LiveRangeMap(Arena* arena, uint unique) |
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
353 |
: _names(arena, unique, unique, 0) |
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
354 |
, _uf_map(arena, unique, unique, 0) |
17013 | 355 |
, _max_lrg_id(0) {} |
356 |
||
357 |
uint find_id( const Node *n ) { |
|
358 |
uint retval = live_range_id(n); |
|
359 |
assert(retval == find(n),"Invalid node to lidx mapping"); |
|
360 |
return retval; |
|
361 |
} |
|
362 |
||
363 |
// Reset the Union-Find map to identity |
|
364 |
void reset_uf_map(uint max_lrg_id); |
|
365 |
||
366 |
// Make all Nodes map directly to their final live range; no need for |
|
367 |
// the Union-Find mapping after this call. |
|
368 |
void compress_uf_map_for_nodes(); |
|
369 |
||
370 |
uint find(uint lidx) { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
371 |
uint uf_lidx = _uf_map.at(lidx); |
17013 | 372 |
return (uf_lidx == lidx) ? uf_lidx : find_compress(lidx); |
373 |
} |
|
374 |
||
375 |
// Convert a Node into a Live Range Index - a lidx |
|
376 |
uint find(const Node *node) { |
|
377 |
uint lidx = live_range_id(node); |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
378 |
uint uf_lidx = _uf_map.at(lidx); |
17013 | 379 |
return (uf_lidx == lidx) ? uf_lidx : find_compress(node); |
380 |
} |
|
381 |
||
382 |
// Like Find above, but no path compress, so bad asymptotic behavior |
|
383 |
uint find_const(uint lrg) const; |
|
384 |
||
385 |
// Like Find above, but no path compress, so bad asymptotic behavior |
|
386 |
uint find_const(const Node *node) const { |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
387 |
if(node->_idx >= (uint)_names.length()) { |
17013 | 388 |
return 0; // not mapped, usual for debug dump |
389 |
} |
|
20007
b67e71448544
8024646: Remove LRG_List container, replace it with GrowableArray
adlertz
parents:
19334
diff
changeset
|
390 |
return find_const(_names.at(node->_idx)); |
17013 | 391 |
} |
392 |
}; |
|
1 | 393 |
|
394 |
//------------------------------Chaitin---------------------------------------- |
|
395 |
// Briggs-Chaitin style allocation, mostly. |
|
396 |
class PhaseChaitin : public PhaseRegAlloc { |
|
10547 | 397 |
friend class VMStructs; |
1 | 398 |
|
399 |
int _trip_cnt; |
|
400 |
int _alternate; |
|
401 |
||
402 |
LRG &lrgs(uint idx) const { return _ifg->lrgs(idx); } |
|
403 |
PhaseLive *_live; // Liveness, used in the interference graph |
|
404 |
PhaseIFG *_ifg; // Interference graph (for original chunk) |
|
405 |
Node_List **_lrg_nodes; // Array of node; lists for lrgs which spill |
|
406 |
VectorSet _spilled_once; // Nodes that have been spilled |
|
407 |
VectorSet _spilled_twice; // Nodes that have been spilled twice |
|
408 |
||
409 |
// Combine the Live Range Indices for these 2 Nodes into a single live |
|
410 |
// range. Future requests for any Node in either live range will |
|
411 |
// return the live range index for the combined live range. |
|
412 |
void Union( const Node *src, const Node *dst ); |
|
413 |
||
414 |
void new_lrg( const Node *x, uint lrg ); |
|
415 |
||
416 |
// Compact live ranges, removing unused ones. Return new maxlrg. |
|
417 |
void compact(); |
|
418 |
||
419 |
uint _lo_degree; // Head of lo-degree LRGs list |
|
420 |
uint _lo_stk_degree; // Head of lo-stk-degree LRGs list |
|
421 |
uint _hi_degree; // Head of hi-degree LRGs list |
|
422 |
uint _simplified; // Linked list head of simplified LRGs |
|
423 |
||
424 |
// Helper functions for Split() |
|
22914
0712db174bbb
8032656: Tag the MachSpillCopies with purpose information
adlertz
parents:
22912
diff
changeset
|
425 |
uint split_DEF(Node *def, Block *b, int loc, uint max, Node **Reachblock, Node **debug_defs, GrowableArray<uint> splits, int slidx ); |
0712db174bbb
8032656: Tag the MachSpillCopies with purpose information
adlertz
parents:
22912
diff
changeset
|
426 |
uint split_USE(MachSpillCopyNode::SpillType spill_type, Node *def, Block *b, Node *use, uint useidx, uint max, bool def_down, bool cisc_sp, GrowableArray<uint> splits, int slidx ); |
17013 | 427 |
|
428 |
//------------------------------clone_projs------------------------------------ |
|
429 |
// After cloning some rematerialized instruction, clone any MachProj's that |
|
430 |
// follow it. Example: Intel zero is XOR, kills flags. Sparc FP constants |
|
431 |
// use G3 as an address temp. |
|
19334
3aa9ca404965
8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents:
17013
diff
changeset
|
432 |
int clone_projs(Block* b, uint idx, Node* orig, Node* copy, uint& max_lrg_id); |
17013 | 433 |
|
19334
3aa9ca404965
8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents:
17013
diff
changeset
|
434 |
int clone_projs(Block* b, uint idx, Node* orig, Node* copy, LiveRangeMap& lrg_map) { |
3aa9ca404965
8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents:
17013
diff
changeset
|
435 |
uint max_lrg_id = lrg_map.max_lrg_id(); |
3aa9ca404965
8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents:
17013
diff
changeset
|
436 |
int found_projs = clone_projs(b, idx, orig, copy, max_lrg_id); |
3aa9ca404965
8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents:
17013
diff
changeset
|
437 |
if (found_projs > 0) { |
3aa9ca404965
8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents:
17013
diff
changeset
|
438 |
// max_lrg_id is updated during call above |
3aa9ca404965
8021898: Broken JIT compiler optimization for loop unswitching
kvn
parents:
17013
diff
changeset
|
439 |
lrg_map.set_max_lrg_id(max_lrg_id); |
17013 | 440 |
} |
441 |
return found_projs; |
|
442 |
} |
|
443 |
||
1057
44220ef9a775
6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents:
670
diff
changeset
|
444 |
Node *split_Rematerialize(Node *def, Block *b, uint insidx, uint &maxlrg, GrowableArray<uint> splits, |
44220ef9a775
6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents:
670
diff
changeset
|
445 |
int slidx, uint *lrg2reach, Node **Reachblock, bool walkThru); |
1 | 446 |
// True if lidx is used before any real register is def'd in the block |
447 |
bool prompt_use( Block *b, uint lidx ); |
|
22914
0712db174bbb
8032656: Tag the MachSpillCopies with purpose information
adlertz
parents:
22912
diff
changeset
|
448 |
Node *get_spillcopy_wide(MachSpillCopyNode::SpillType spill_type, Node *def, Node *use, uint uidx ); |
2131 | 449 |
// Insert the spill at chosen location. Skip over any intervening Proj's or |
1 | 450 |
// Phis. Skip over a CatchNode and projs, inserting in the fall-through block |
451 |
// instead. Update high-pressure indices. Create a new live range. |
|
452 |
void insert_proj( Block *b, uint i, Node *spill, uint maxlrg ); |
|
453 |
||
454 |
bool is_high_pressure( Block *b, LRG *lrg, uint insidx ); |
|
455 |
||
456 |
uint _oldphi; // Node index which separates pre-allocation nodes |
|
457 |
||
458 |
Block **_blks; // Array of blocks sorted by frequency for coalescing |
|
459 |
||
2340 | 460 |
float _high_frequency_lrg; // Frequency at which LRG will be spilled for debug info |
461 |
||
1 | 462 |
#ifndef PRODUCT |
463 |
bool _trace_spilling; |
|
464 |
#endif |
|
465 |
||
466 |
public: |
|
467 |
PhaseChaitin( uint unique, PhaseCFG &cfg, Matcher &matcher ); |
|
468 |
~PhaseChaitin() {} |
|
469 |
||
17013 | 470 |
LiveRangeMap _lrg_map; |
1 | 471 |
|
472 |
// Do all the real work of allocate |
|
473 |
void Register_Allocate(); |
|
474 |
||
2340 | 475 |
float high_frequency_lrg() const { return _high_frequency_lrg; } |
476 |
||
1 | 477 |
#ifndef PRODUCT |
478 |
bool trace_spilling() const { return _trace_spilling; } |
|
479 |
#endif |
|
480 |
||
481 |
private: |
|
482 |
// De-SSA the world. Assign registers to Nodes. Use the same register for |
|
483 |
// all inputs to a PhiNode, effectively coalescing live ranges. Insert |
|
484 |
// copies as needed. |
|
485 |
void de_ssa(); |
|
486 |
||
487 |
// Add edge between reg and everything in the vector. |
|
488 |
// Same as _ifg->add_vector(reg,live) EXCEPT use the RegMask |
|
489 |
// information to trim the set of interferences. Return the |
|
490 |
// count of edges added. |
|
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
491 |
void interfere_with_live(uint lid, IndexSet* liveout); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
492 |
#ifdef ASSERT |
1 | 493 |
// Count register pressure for asserts |
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
494 |
uint count_int_pressure(IndexSet* liveout); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
495 |
uint count_float_pressure(IndexSet* liveout); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
496 |
#endif |
1 | 497 |
|
498 |
// Build the interference graph using virtual registers only. |
|
499 |
// Used for aggressive coalescing. |
|
500 |
void build_ifg_virtual( ); |
|
501 |
||
22912 | 502 |
// used when computing the register pressure for each block in the CFG. This |
503 |
// is done during IFG creation. |
|
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
504 |
class Pressure { |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
505 |
// keeps track of the register pressure at the current |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
506 |
// instruction (used when stepping backwards in the block) |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
507 |
uint _current_pressure; |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
508 |
|
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
509 |
// keeps track of the instruction index of the first low to high register pressure |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
510 |
// transition (starting from the top) in the block |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
511 |
// if high_pressure_index == 0 then the whole block is high pressure |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
512 |
// if high_pressure_index = b.end_idx() + 1 then the whole block is low pressure |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
513 |
uint _high_pressure_index; |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
514 |
|
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
515 |
// stores the highest pressure we find |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
516 |
uint _final_pressure; |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
517 |
|
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
518 |
// number of live ranges that constitute high register pressure |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
519 |
const uint _high_pressure_limit; |
22912 | 520 |
public: |
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
521 |
|
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
522 |
// lower the register pressure and look for a low to high pressure |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
523 |
// transition |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
524 |
void lower(LRG& lrg, uint& location) { |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
525 |
_current_pressure -= lrg.reg_pressure(); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
526 |
if (_current_pressure == _high_pressure_limit) { |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
527 |
_high_pressure_index = location; |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
528 |
} |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
529 |
} |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
530 |
|
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
531 |
// raise the pressure and store the pressure if it's the biggest |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
532 |
// pressure so far |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
533 |
void raise(LRG &lrg) { |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
534 |
_current_pressure += lrg.reg_pressure(); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
535 |
if (_current_pressure > _final_pressure) { |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
536 |
_final_pressure = _current_pressure; |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
537 |
} |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
538 |
} |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
539 |
|
22912 | 540 |
uint high_pressure_index() const { |
541 |
return _high_pressure_index; |
|
542 |
} |
|
543 |
||
544 |
uint final_pressure() const { |
|
545 |
return _final_pressure; |
|
546 |
} |
|
547 |
||
548 |
uint current_pressure() const { |
|
549 |
return _current_pressure; |
|
550 |
} |
|
551 |
||
552 |
uint high_pressure_limit() const { |
|
553 |
return _high_pressure_limit; |
|
554 |
} |
|
555 |
||
556 |
void lower_high_pressure_index() { |
|
557 |
_high_pressure_index--; |
|
558 |
} |
|
559 |
||
560 |
void set_high_pressure_index_to_block_start() { |
|
561 |
_high_pressure_index = 0; |
|
562 |
} |
|
563 |
||
564 |
void check_pressure_at_fatproj(uint fatproj_location, RegMask& fatproj_mask) { |
|
565 |
// this pressure is only valid at this instruction, i.e. we don't need to lower |
|
566 |
// the register pressure since the fat proj was never live before (going backwards) |
|
567 |
uint new_pressure = current_pressure() + fatproj_mask.Size(); |
|
568 |
if (new_pressure > final_pressure()) { |
|
569 |
_final_pressure = new_pressure; |
|
570 |
} |
|
571 |
||
572 |
// if we were at a low pressure and now and the fat proj is at high pressure, record the fat proj location |
|
573 |
// as coming from a low to high (to low again) |
|
574 |
if (current_pressure() <= high_pressure_limit() && new_pressure > high_pressure_limit()) { |
|
575 |
_high_pressure_index = fatproj_location; |
|
576 |
} |
|
577 |
} |
|
578 |
||
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
579 |
Pressure(uint high_pressure_index, uint high_pressure_limit) |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
580 |
: _current_pressure(0) |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
581 |
, _high_pressure_index(high_pressure_index) |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
582 |
, _high_pressure_limit(high_pressure_limit) |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
583 |
, _final_pressure(0) {} |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
584 |
}; |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
585 |
|
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
586 |
void lower_pressure(Block* b, uint location, LRG& lrg, IndexSet* liveout, Pressure& int_pressure, Pressure& float_pressure); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
587 |
void raise_pressure(Block* b, LRG& lrg, Pressure& int_pressure, Pressure& float_pressure); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
588 |
void check_for_high_pressure_transition_at_fatproj(uint& block_reg_pressure, uint location, LRG& lrg, Pressure& pressure, const int op_regtype); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
589 |
void add_input_to_liveout(Block* b, Node* n, IndexSet* liveout, double cost, Pressure& int_pressure, Pressure& float_pressure); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
590 |
void compute_initial_block_pressure(Block* b, IndexSet* liveout, Pressure& int_pressure, Pressure& float_pressure, double cost); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
591 |
bool remove_node_if_not_used(Block* b, uint location, Node* n, uint lid, IndexSet* liveout); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
592 |
void assign_high_score_to_immediate_copies(Block* b, Node* n, LRG& lrg, uint next_inst, uint last_inst); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
593 |
void remove_interference_from_copy(Block* b, uint location, uint lid_copy, IndexSet* liveout, double cost, Pressure& int_pressure, Pressure& float_pressure); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
594 |
void remove_bound_register_from_interfering_live_ranges(LRG& lrg, IndexSet* liveout, uint& must_spill); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
595 |
void check_for_high_pressure_block(Pressure& pressure); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
596 |
void adjust_high_pressure_index(Block* b, uint& hrp_index, Pressure& pressure); |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
597 |
|
1 | 598 |
// Build the interference graph using physical registers when available. |
599 |
// That is, if 2 live ranges are simultaneously alive but in their |
|
600 |
// acceptable register sets do not overlap, then they do not interfere. |
|
601 |
uint build_ifg_physical( ResourceArea *a ); |
|
602 |
||
603 |
// Gather LiveRanGe information, including register masks and base pointer/ |
|
604 |
// derived pointer relationships. |
|
605 |
void gather_lrg_masks( bool mod_cisc_masks ); |
|
606 |
||
607 |
// Force the bases of derived pointers to be alive at GC points. |
|
608 |
bool stretch_base_pointer_live_ranges( ResourceArea *a ); |
|
609 |
// Helper to stretch above; recursively discover the base Node for |
|
610 |
// a given derived Node. Easy for AddP-related machine nodes, but |
|
611 |
// needs to be recursive for derived Phis. |
|
612 |
Node *find_base_for_derived( Node **derived_base_map, Node *derived, uint &maxlrg ); |
|
613 |
||
614 |
// Set the was-lo-degree bit. Conservative coalescing should not change the |
|
615 |
// colorability of the graph. If any live range was of low-degree before |
|
616 |
// coalescing, it should Simplify. This call sets the was-lo-degree bit. |
|
617 |
void set_was_low(); |
|
618 |
||
619 |
// Split live-ranges that must spill due to register conflicts (as opposed |
|
620 |
// to capacity spills). Typically these are things def'd in a register |
|
621 |
// and used on the stack or vice-versa. |
|
622 |
void pre_spill(); |
|
623 |
||
624 |
// Init LRG caching of degree, numregs. Init lo_degree list. |
|
625 |
void cache_lrg_info( ); |
|
626 |
||
627 |
// Simplify the IFG by removing LRGs of low degree with no copies |
|
628 |
void Pre_Simplify(); |
|
629 |
||
630 |
// Simplify the IFG by removing LRGs of low degree |
|
631 |
void Simplify(); |
|
632 |
||
633 |
// Select colors by re-inserting edges into the IFG. |
|
2131 | 634 |
// Return TRUE if any spills occurred. |
1 | 635 |
uint Select( ); |
636 |
// Helper function for select which allows biased coloring |
|
637 |
OptoReg::Name choose_color( LRG &lrg, int chunk ); |
|
638 |
// Helper function which implements biasing heuristic |
|
639 |
OptoReg::Name bias_color( LRG &lrg, int chunk ); |
|
640 |
||
641 |
// Split uncolorable live ranges |
|
642 |
// Return new number of live ranges |
|
13520
a1ba7784ef54
7148109: C2 compiler consumes too much heap resources
kvn
parents:
13104
diff
changeset
|
643 |
uint Split(uint maxlrg, ResourceArea* split_arena); |
1 | 644 |
|
645 |
// Copy 'was_spilled'-edness from one Node to another. |
|
646 |
void copy_was_spilled( Node *src, Node *dst ); |
|
647 |
// Set the 'spilled_once' or 'spilled_twice' flag on a node. |
|
648 |
void set_was_spilled( Node *n ); |
|
649 |
||
650 |
// Convert ideal spill-nodes into machine loads & stores |
|
651 |
// Set C->failing when fixup spills could not complete, node limit exceeded. |
|
652 |
void fixup_spills(); |
|
653 |
||
654 |
// Post-Allocation peephole copy removal |
|
655 |
void post_allocate_copy_removal(); |
|
656 |
Node *skip_copies( Node *c ); |
|
3678 | 657 |
// Replace the old node with the current live version of that value |
658 |
// and yank the old value if it's dead. |
|
659 |
int replace_and_yank_if_dead( Node *old, OptoReg::Name nreg, |
|
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
660 |
Block *current_block, Node_List& value, Node_List& regnd ) { |
3678 | 661 |
Node* v = regnd[nreg]; |
662 |
assert(v->outcnt() != 0, "no dead values"); |
|
663 |
old->replace_by(v); |
|
664 |
return yank_if_dead(old, current_block, &value, ®nd); |
|
665 |
} |
|
666 |
||
11444
8a2619fd3fca
7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents:
10547
diff
changeset
|
667 |
int yank_if_dead( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) { |
8a2619fd3fca
7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents:
10547
diff
changeset
|
668 |
return yank_if_dead_recurse(old, old, current_block, value, regnd); |
8a2619fd3fca
7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents:
10547
diff
changeset
|
669 |
} |
8a2619fd3fca
7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents:
10547
diff
changeset
|
670 |
int yank_if_dead_recurse(Node *old, Node *orig_old, Block *current_block, |
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
671 |
Node_List *value, Node_List *regnd); |
10542
93e6f995c75c
7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents:
7441
diff
changeset
|
672 |
int yank( Node *old, Block *current_block, Node_List *value, Node_List *regnd ); |
1 | 673 |
int elide_copy( Node *n, int k, Block *current_block, Node_List &value, Node_List ®nd, bool can_change_regs ); |
674 |
int use_prior_register( Node *copy, uint idx, Node *def, Block *current_block, Node_List &value, Node_List ®nd ); |
|
675 |
bool may_be_copy_of_callee( Node *def ) const; |
|
676 |
||
677 |
// If nreg already contains the same constant as val then eliminate it |
|
243
79b67a7a584a
6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents:
1
diff
changeset
|
678 |
bool eliminate_copy_of_constant(Node* val, Node* n, |
22804
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
679 |
Block *current_block, Node_List& value, Node_List ®nd, |
401135897b65
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical
adlertz
parents:
22234
diff
changeset
|
680 |
OptoReg::Name nreg, OptoReg::Name nreg2); |
1 | 681 |
// Extend the node to LRG mapping |
682 |
void add_reference( const Node *node, const Node *old_node); |
|
683 |
||
28648
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
684 |
// Record the first use of a def in the block for a register. |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
685 |
class RegDefUse { |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
686 |
Node* _def; |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
687 |
Node* _first_use; |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
688 |
public: |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
689 |
RegDefUse() : _def(NULL), _first_use(NULL) { } |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
690 |
Node* def() const { return _def; } |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
691 |
Node* first_use() const { return _first_use; } |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
692 |
|
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
693 |
void update(Node* def, Node* use) { |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
694 |
if (_def != def) { |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
695 |
_def = def; |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
696 |
_first_use = use; |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
697 |
} |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
698 |
} |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
699 |
void clear() { |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
700 |
_def = NULL; |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
701 |
_first_use = NULL; |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
702 |
} |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
703 |
}; |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
704 |
typedef GrowableArray<RegDefUse> RegToDefUseMap; |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
705 |
int possibly_merge_multidef(Node *n, uint k, Block *block, RegToDefUseMap& reg2defuse); |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
706 |
|
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
707 |
// Merge nodes that are a part of a multidef lrg and produce the same value within a block. |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
708 |
void merge_multidefs(); |
102bdbb42723
8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents:
24425
diff
changeset
|
709 |
|
1 | 710 |
private: |
711 |
||
712 |
static int _final_loads, _final_stores, _final_copies, _final_memoves; |
|
713 |
static double _final_load_cost, _final_store_cost, _final_copy_cost, _final_memove_cost; |
|
714 |
static int _conserv_coalesce, _conserv_coalesce_pair; |
|
715 |
static int _conserv_coalesce_trie, _conserv_coalesce_quad; |
|
716 |
static int _post_alloc; |
|
717 |
static int _lost_opp_pp_coalesce, _lost_opp_cflow_coalesce; |
|
718 |
static int _used_cisc_instructions, _unused_cisc_instructions; |
|
719 |
static int _allocator_attempts, _allocator_successes; |
|
720 |
||
721 |
#ifndef PRODUCT |
|
722 |
static uint _high_pressure, _low_pressure; |
|
723 |
||
724 |
void dump() const; |
|
725 |
void dump( const Node *n ) const; |
|
726 |
void dump( const Block * b ) const; |
|
727 |
void dump_degree_lists() const; |
|
728 |
void dump_simplified() const; |
|
7441
47ea904dba6a
7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents:
7397
diff
changeset
|
729 |
void dump_lrg( uint lidx, bool defs_only) const; |
47ea904dba6a
7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents:
7397
diff
changeset
|
730 |
void dump_lrg( uint lidx) const { |
47ea904dba6a
7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents:
7397
diff
changeset
|
731 |
// dump defs and uses by default |
47ea904dba6a
7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents:
7397
diff
changeset
|
732 |
dump_lrg(lidx, false); |
47ea904dba6a
7004940: CTW: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG
never
parents:
7397
diff
changeset
|
733 |
} |
1 | 734 |
void dump_bb( uint pre_order ) const; |
735 |
||
736 |
// Verify that base pointers and derived pointers are still sane |
|
737 |
void verify_base_ptrs( ResourceArea *a ) const; |
|
738 |
||
2030
39d55e4534b4
6791852: assert(b->_nodes[insidx] == n,"got insidx set incorrectly")
kvn
parents:
1057
diff
changeset
|
739 |
void verify( ResourceArea *a, bool verify_ifg = false ) const; |
39d55e4534b4
6791852: assert(b->_nodes[insidx] == n,"got insidx set incorrectly")
kvn
parents:
1057
diff
changeset
|
740 |
|
1 | 741 |
void dump_for_spill_split_recycle() const; |
742 |
||
743 |
public: |
|
744 |
void dump_frame() const; |
|
745 |
char *dump_register( const Node *n, char *buf ) const; |
|
746 |
private: |
|
747 |
static void print_chaitin_statistics(); |
|
748 |
#endif |
|
749 |
friend class PhaseCoalesce; |
|
750 |
friend class PhaseAggressiveCoalesce; |
|
751 |
friend class PhaseConservativeCoalesce; |
|
752 |
}; |
|
7397 | 753 |
|
754 |
#endif // SHARE_VM_OPTO_CHAITIN_HPP |