annotate src/share/vm/opto/chaitin.hpp @ 1145:e018e6884bd8

6631166: CMS: better heuristics when combatting fragmentation Summary: Autonomic per-worker free block cache sizing, tunable coalition policies, fixes to per-size block statistics, retuned gain and bandwidth of some feedback loop filters to allow quicker reactivity to abrupt changes in ambient demand, and other heuristics to reduce fragmentation of the CMS old gen. Also tightened some assertions, including those related to locking. Reviewed-by: jmasa
author ysr
date Wed, 23 Dec 2009 09:23:54 -0800
parents a70508bb21c3
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
579
0fbdb4381b99 6814575: Update copyright year
xdono
parents: 566
diff changeset
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 class LoopTree;
a61af66fc99e Initial load
duke
parents:
diff changeset
26 class MachCallNode;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 class MachSafePointNode;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class Matcher;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class PhaseCFG;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class PhaseLive;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class PhaseRegAlloc;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class PhaseChaitin;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 #define OPTO_DEBUG_SPLIT_FREQ BLOCK_FREQUENCY(0.001)
a61af66fc99e Initial load
duke
parents:
diff changeset
35 #define OPTO_LRG_HIGH_FREQ BLOCK_FREQUENCY(0.25)
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //------------------------------LRG--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Live-RanGe structure.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class LRG : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
41 enum { SPILL_REG=29999 }; // Register number of a spilled LRG
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 double _cost; // 2 for loads/1 for stores times block freq
a61af66fc99e Initial load
duke
parents:
diff changeset
44 double _area; // Sum of all simultaneously live values
a61af66fc99e Initial load
duke
parents:
diff changeset
45 double score() const; // Compute score from cost and area
a61af66fc99e Initial load
duke
parents:
diff changeset
46 double _maxfreq; // Maximum frequency of any def or use
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 Node *_def; // Check for multi-def live ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
49 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
50 GrowableArray<Node*>* _defs;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 uint _risk_bias; // Index of LRG which we want to avoid color
a61af66fc99e Initial load
duke
parents:
diff changeset
54 uint _copy_bias; // Index of LRG which we want to share color
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 uint _next; // Index of next LRG in linked list
a61af66fc99e Initial load
duke
parents:
diff changeset
57 uint _prev; // Index of prev LRG in linked list
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
59 uint _reg; // Chosen register; undefined if mask is plural
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Return chosen register for this LRG. Error if the LRG is not bound to
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // a single register.
a61af66fc99e Initial load
duke
parents:
diff changeset
63 OptoReg::Name reg() const { return OptoReg::Name(_reg); }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 void set_reg( OptoReg::Name r ) { _reg = r; }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
67 uint _eff_degree; // Effective degree: Sum of neighbors _num_regs
a61af66fc99e Initial load
duke
parents:
diff changeset
68 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
69 int degree() const { assert( _degree_valid, "" ); return _eff_degree; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // Degree starts not valid and any change to the IFG neighbor
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // set makes it not valid.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void set_degree( uint degree ) { _eff_degree = degree; debug_only(_degree_valid = 1;) }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // Made a change that hammered degree
a61af66fc99e Initial load
duke
parents:
diff changeset
74 void invalid_degree() { debug_only(_degree_valid=0;) }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Incrementally modify degree. If it was correct, it should remain correct
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void inc_degree( uint mod ) { _eff_degree += mod; }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Compute the degree between 2 live ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
78 int compute_degree( LRG &l ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
81 RegMask _mask; // Allowed registers for this LRG
a61af66fc99e Initial load
duke
parents:
diff changeset
82 uint _mask_size; // cache of _mask.Size();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int compute_mask_size() const { return _mask.is_AllStack() ? 65535 : _mask.Size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void set_mask_size( int size ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 assert((size == 65535) || (size == (int)_mask.Size()), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 _mask_size = size;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 debug_only(_msize_valid=1;)
a61af66fc99e Initial load
duke
parents:
diff changeset
89 debug_only( if( _num_regs == 2 && !_fat_proj ) _mask.VerifyPairs(); )
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void compute_set_mask_size() { set_mask_size(compute_mask_size()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 int mask_size() const { assert( _msize_valid, "mask size not valid" );
a61af66fc99e Initial load
duke
parents:
diff changeset
93 return _mask_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Get the last mask size computed, even if it does not match the
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // count of bits in the current mask.
a61af66fc99e Initial load
duke
parents:
diff changeset
96 int get_invalid_mask_size() const { return _mask_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 const RegMask &mask() const { return _mask; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void set_mask( const RegMask &rm ) { _mask = rm; debug_only(_msize_valid=0;)}
a61af66fc99e Initial load
duke
parents:
diff changeset
99 void AND( const RegMask &rm ) { _mask.AND(rm); debug_only(_msize_valid=0;)}
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void SUBTRACT( const RegMask &rm ) { _mask.SUBTRACT(rm); debug_only(_msize_valid=0;)}
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void Clear() { _mask.Clear() ; debug_only(_msize_valid=1); _mask_size = 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void Set_All() { _mask.Set_All(); debug_only(_msize_valid=1); _mask_size = RegMask::CHUNK_SIZE; }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 void Insert( OptoReg::Name reg ) { _mask.Insert(reg); debug_only(_msize_valid=0;) }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 void Remove( OptoReg::Name reg ) { _mask.Remove(reg); debug_only(_msize_valid=0;) }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void ClearToPairs() { _mask.ClearToPairs(); debug_only(_msize_valid=0;) }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Number of registers this live range uses when it colors
a61af66fc99e Initial load
duke
parents:
diff changeset
108 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
109 uint8 _num_regs; // 2 for Longs and Doubles, 1 for all else
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // except _num_regs is kill count for fat_proj
a61af66fc99e Initial load
duke
parents:
diff changeset
111 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
112 int num_regs() const { return _num_regs; }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 void set_num_regs( int reg ) { assert( _num_regs == reg || !_num_regs, "" ); _num_regs = reg; }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Number of physical registers this live range uses when it colors
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Architecture and register-set dependent
a61af66fc99e Initial load
duke
parents:
diff changeset
118 uint8 _reg_pressure;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void set_reg_pressure(int i) { _reg_pressure = i; }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int reg_pressure() const { return _reg_pressure; }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // How much 'wiggle room' does this live range have?
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // How many color choices can it make (scaled by _num_regs)?
a61af66fc99e Initial load
duke
parents:
diff changeset
125 int degrees_of_freedom() const { return mask_size() - _num_regs; }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Bound LRGs have ZERO degrees of freedom. We also count
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // must_spill as bound.
a61af66fc99e Initial load
duke
parents:
diff changeset
128 bool is_bound () const { return _is_bound; }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Negative degrees-of-freedom; even with no neighbors this
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // live range must spill.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 bool not_free() const { return degrees_of_freedom() < 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // Is this live range of "low-degree"? Trivially colorable?
a61af66fc99e Initial load
duke
parents:
diff changeset
133 bool lo_degree () const { return degree() <= degrees_of_freedom(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Is this live range just barely "low-degree"? Trivially colorable?
a61af66fc99e Initial load
duke
parents:
diff changeset
135 bool just_lo_degree () const { return degree() == degrees_of_freedom(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 uint _is_oop:1, // Live-range holds an oop
a61af66fc99e Initial load
duke
parents:
diff changeset
138 _is_float:1, // True if in float registers
a61af66fc99e Initial load
duke
parents:
diff changeset
139 _was_spilled1:1, // True if prior spilling on def
a61af66fc99e Initial load
duke
parents:
diff changeset
140 _was_spilled2:1, // True if twice prior spilling on def
a61af66fc99e Initial load
duke
parents:
diff changeset
141 _is_bound:1, // live range starts life with no
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // degrees of freedom.
a61af66fc99e Initial load
duke
parents:
diff changeset
143 _direct_conflict:1, // True if def and use registers in conflict
a61af66fc99e Initial load
duke
parents:
diff changeset
144 _must_spill:1, // live range has lost all degrees of freedom
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // If _fat_proj is set, live range does NOT require aligned, adjacent
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // registers and has NO interferences.
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // If _fat_proj is clear, live range requires num_regs() to be a power of
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // 2, and it requires registers to form an aligned, adjacent set.
a61af66fc99e Initial load
duke
parents:
diff changeset
149 _fat_proj:1, //
a61af66fc99e Initial load
duke
parents:
diff changeset
150 _was_lo:1, // Was lo-degree prior to coalesce
a61af66fc99e Initial load
duke
parents:
diff changeset
151 _msize_valid:1, // _mask_size cache valid
a61af66fc99e Initial load
duke
parents:
diff changeset
152 _degree_valid:1, // _degree cache valid
a61af66fc99e Initial load
duke
parents:
diff changeset
153 _has_copy:1, // Adjacent to some copy instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
154 _at_risk:1; // Simplify says this guy is at risk to spill
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // Alive if non-zero, dead if zero
a61af66fc99e Initial load
duke
parents:
diff changeset
158 bool alive() const { return _def != NULL; }
295
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 196
diff changeset
159 bool is_multidef() const { return _def == NodeSentinel; }
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 196
diff changeset
160 bool is_singledef() const { return _def != NodeSentinel; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void dump( ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
165 };
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 //------------------------------LRG_List---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // Map Node indices to Live RanGe indices.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Array lookup in the optimized case.
a61af66fc99e Initial load
duke
parents:
diff changeset
170 class LRG_List : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 uint _cnt, _max;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 uint* _lidxs;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 ReallocMark _nesting; // assertion check for reallocations
a61af66fc99e Initial load
duke
parents:
diff changeset
174 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
175 LRG_List( uint max );
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 uint lookup( uint nidx ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 return _lidxs[nidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 uint operator[] (uint nidx) const { return lookup(nidx); }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void map( uint nidx, uint lidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 assert( nidx < _cnt, "oob" );
a61af66fc99e Initial load
duke
parents:
diff changeset
184 _lidxs[nidx] = lidx;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 void extend( uint nidx, uint lidx );
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 uint Size() const { return _cnt; }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 };
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 //------------------------------IFG--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // InterFerence Graph
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // An undirected graph implementation. Created with a fixed number of
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // vertices. Edges can be added & tested. Vertices can be removed, then
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // added back later with all edges intact. Can add edges between one vertex
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // and a list of other vertices. Can union vertices (and their edges)
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // together. The IFG needs to be really really fast, and also fairly
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // abstract! It needs abstraction so I can fiddle with the implementation to
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // get even more speed.
a61af66fc99e Initial load
duke
parents:
diff changeset
200 class PhaseIFG : public Phase {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Current implementation: a triangular adjacency list.
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // Array of adjacency-lists, indexed by live-range number
a61af66fc99e Initial load
duke
parents:
diff changeset
204 IndexSet *_adjs;
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // Assertion bit for proper use of Squaring
a61af66fc99e Initial load
duke
parents:
diff changeset
207 bool _is_square;
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // Live range structure goes here
a61af66fc99e Initial load
duke
parents:
diff changeset
210 LRG *_lrgs; // Array of LRG structures
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Largest live-range number
a61af66fc99e Initial load
duke
parents:
diff changeset
214 uint _maxlrg;
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 Arena *_arena;
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // Keep track of inserted and deleted Nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
219 VectorSet *_yanked;
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 PhaseIFG( Arena *arena );
a61af66fc99e Initial load
duke
parents:
diff changeset
222 void init( uint maxlrg );
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Add edge between a and b. Returns true if actually addded.
a61af66fc99e Initial load
duke
parents:
diff changeset
225 int add_edge( uint a, uint b );
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // Add edge between a and everything in the vector
a61af66fc99e Initial load
duke
parents:
diff changeset
228 void add_vector( uint a, IndexSet *vec );
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Test for edge existance
a61af66fc99e Initial load
duke
parents:
diff changeset
231 int test_edge( uint a, uint b ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // Square-up matrix for faster Union
a61af66fc99e Initial load
duke
parents:
diff changeset
234 void SquareUp();
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // Return number of LRG neighbors
a61af66fc99e Initial load
duke
parents:
diff changeset
237 uint neighbor_cnt( uint a ) const { return _adjs[a].count(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Union edges of b into a on Squared-up matrix
a61af66fc99e Initial load
duke
parents:
diff changeset
239 void Union( uint a, uint b );
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // Test for edge in Squared-up matrix
a61af66fc99e Initial load
duke
parents:
diff changeset
241 int test_edge_sq( uint a, uint b ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Yank a Node and all connected edges from the IFG. Be prepared to
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // re-insert the yanked Node in reverse order of yanking. Return a
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // list of neighbors (edges) yanked.
a61af66fc99e Initial load
duke
parents:
diff changeset
245 IndexSet *remove_node( uint a );
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // Reinsert a yanked Node
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void re_insert( uint a );
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // Return set of neighbors
a61af66fc99e Initial load
duke
parents:
diff changeset
249 IndexSet *neighbors( uint a ) const { return &_adjs[a]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // Dump the IFG
a61af66fc99e Initial load
duke
parents:
diff changeset
253 void dump() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 void stats() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 void verify( const PhaseChaitin * ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 //--------------- Live Range Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
259 LRG &lrgs(uint idx) const { assert(idx < _maxlrg, "oob"); return _lrgs[idx]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // Compute and set effective degree. Might be folded into SquareUp().
a61af66fc99e Initial load
duke
parents:
diff changeset
262 void Compute_Effective_Degree();
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // Compute effective degree as the sum of neighbors' _sizes.
a61af66fc99e Initial load
duke
parents:
diff changeset
265 int effective_degree( uint lidx ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
266 };
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // TEMPORARILY REPLACED WITH COMMAND LINE FLAG
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 //// !!!!! Magic Constants need to move into ad file
a61af66fc99e Initial load
duke
parents:
diff changeset
271 #ifdef SPARC
a61af66fc99e Initial load
duke
parents:
diff changeset
272 //#define FLOAT_PRESSURE 30 /* SFLT_REG_mask.Size() - 1 */
a61af66fc99e Initial load
duke
parents:
diff changeset
273 //#define INT_PRESSURE 23 /* NOTEMP_I_REG_mask.Size() - 1 */
a61af66fc99e Initial load
duke
parents:
diff changeset
274 #define FLOAT_INCREMENT(regs) regs
a61af66fc99e Initial load
duke
parents:
diff changeset
275 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
276 //#define FLOAT_PRESSURE 6
a61af66fc99e Initial load
duke
parents:
diff changeset
277 //#define INT_PRESSURE 6
a61af66fc99e Initial load
duke
parents:
diff changeset
278 #define FLOAT_INCREMENT(regs) 1
a61af66fc99e Initial load
duke
parents:
diff changeset
279 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 //------------------------------Chaitin----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // Briggs-Chaitin style allocation, mostly.
a61af66fc99e Initial load
duke
parents:
diff changeset
283 class PhaseChaitin : public PhaseRegAlloc {
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 int _trip_cnt;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 int _alternate;
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 uint _maxlrg; // Max live range number
a61af66fc99e Initial load
duke
parents:
diff changeset
289 LRG &lrgs(uint idx) const { return _ifg->lrgs(idx); }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 PhaseLive *_live; // Liveness, used in the interference graph
a61af66fc99e Initial load
duke
parents:
diff changeset
291 PhaseIFG *_ifg; // Interference graph (for original chunk)
a61af66fc99e Initial load
duke
parents:
diff changeset
292 Node_List **_lrg_nodes; // Array of node; lists for lrgs which spill
a61af66fc99e Initial load
duke
parents:
diff changeset
293 VectorSet _spilled_once; // Nodes that have been spilled
a61af66fc99e Initial load
duke
parents:
diff changeset
294 VectorSet _spilled_twice; // Nodes that have been spilled twice
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 LRG_List _names; // Map from Nodes to Live RanGes
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // Union-find map. Declared as a short for speed.
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // Indexed by live-range number, it returns the compacted live-range number
a61af66fc99e Initial load
duke
parents:
diff changeset
300 LRG_List _uf_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // Reset the Union-Find map to identity
a61af66fc99e Initial load
duke
parents:
diff changeset
302 void reset_uf_map( uint maxlrg );
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // Remove the need for the Union-Find mapping
a61af66fc99e Initial load
duke
parents:
diff changeset
304 void compress_uf_map_for_nodes( );
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // Combine the Live Range Indices for these 2 Nodes into a single live
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // range. Future requests for any Node in either live range will
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // return the live range index for the combined live range.
a61af66fc99e Initial load
duke
parents:
diff changeset
309 void Union( const Node *src, const Node *dst );
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 void new_lrg( const Node *x, uint lrg );
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // Compact live ranges, removing unused ones. Return new maxlrg.
a61af66fc99e Initial load
duke
parents:
diff changeset
314 void compact();
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 uint _lo_degree; // Head of lo-degree LRGs list
a61af66fc99e Initial load
duke
parents:
diff changeset
317 uint _lo_stk_degree; // Head of lo-stk-degree LRGs list
a61af66fc99e Initial load
duke
parents:
diff changeset
318 uint _hi_degree; // Head of hi-degree LRGs list
a61af66fc99e Initial load
duke
parents:
diff changeset
319 uint _simplified; // Linked list head of simplified LRGs
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // Helper functions for Split()
a61af66fc99e Initial load
duke
parents:
diff changeset
322 uint split_DEF( Node *def, Block *b, int loc, uint max, Node **Reachblock, Node **debug_defs, GrowableArray<uint> splits, int slidx );
a61af66fc99e Initial load
duke
parents:
diff changeset
323 uint split_USE( Node *def, Block *b, Node *use, uint useidx, uint max, bool def_down, bool cisc_sp, GrowableArray<uint> splits, int slidx );
a61af66fc99e Initial load
duke
parents:
diff changeset
324 int clone_projs( Block *b, uint idx, Node *con, Node *copy, uint &maxlrg );
295
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 196
diff changeset
325 Node *split_Rematerialize(Node *def, Block *b, uint insidx, uint &maxlrg, GrowableArray<uint> splits,
ea18057223c4 6732194: Data corruption dependent on -server/-client/-Xbatch
never
parents: 196
diff changeset
326 int slidx, uint *lrg2reach, Node **Reachblock, bool walkThru);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // True if lidx is used before any real register is def'd in the block
a61af66fc99e Initial load
duke
parents:
diff changeset
328 bool prompt_use( Block *b, uint lidx );
a61af66fc99e Initial load
duke
parents:
diff changeset
329 Node *get_spillcopy_wide( Node *def, Node *use, uint uidx );
605
98cb887364d3 6810672: Comment typos
twisti
parents: 566
diff changeset
330 // Insert the spill at chosen location. Skip over any intervening Proj's or
0
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // Phis. Skip over a CatchNode and projs, inserting in the fall-through block
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // instead. Update high-pressure indices. Create a new live range.
a61af66fc99e Initial load
duke
parents:
diff changeset
333 void insert_proj( Block *b, uint i, Node *spill, uint maxlrg );
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 bool is_high_pressure( Block *b, LRG *lrg, uint insidx );
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 uint _oldphi; // Node index which separates pre-allocation nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 Block **_blks; // Array of blocks sorted by frequency for coalescing
a61af66fc99e Initial load
duke
parents:
diff changeset
340
673
fbc12e71c476 6810845: Performance regression in mpegaudio on x64
kvn
parents: 628
diff changeset
341 float _high_frequency_lrg; // Frequency at which LRG will be spilled for debug info
fbc12e71c476 6810845: Performance regression in mpegaudio on x64
kvn
parents: 628
diff changeset
342
0
a61af66fc99e Initial load
duke
parents:
diff changeset
343 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
344 bool _trace_spilling;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
348 PhaseChaitin( uint unique, PhaseCFG &cfg, Matcher &matcher );
a61af66fc99e Initial load
duke
parents:
diff changeset
349 ~PhaseChaitin() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Convert a Node into a Live Range Index - a lidx
a61af66fc99e Initial load
duke
parents:
diff changeset
352 uint Find( const Node *n ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 uint lidx = n2lidx(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
354 uint uf_lidx = _uf_map[lidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
355 return (uf_lidx == lidx) ? uf_lidx : Find_compress(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357 uint Find_const( uint lrg ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
358 uint Find_const( const Node *n ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // Do all the real work of allocate
a61af66fc99e Initial load
duke
parents:
diff changeset
361 void Register_Allocate();
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 uint n2lidx( const Node *n ) const { return _names[n->_idx]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
364
673
fbc12e71c476 6810845: Performance regression in mpegaudio on x64
kvn
parents: 628
diff changeset
365 float high_frequency_lrg() const { return _high_frequency_lrg; }
fbc12e71c476 6810845: Performance regression in mpegaudio on x64
kvn
parents: 628
diff changeset
366
0
a61af66fc99e Initial load
duke
parents:
diff changeset
367 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
368 bool trace_spilling() const { return _trace_spilling; }
a61af66fc99e Initial load
duke
parents:
diff changeset
369 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // De-SSA the world. Assign registers to Nodes. Use the same register for
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // all inputs to a PhiNode, effectively coalescing live ranges. Insert
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // copies as needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
375 void de_ssa();
a61af66fc99e Initial load
duke
parents:
diff changeset
376 uint Find_compress( const Node *n );
a61af66fc99e Initial load
duke
parents:
diff changeset
377 uint Find( uint lidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
378 uint uf_lidx = _uf_map[lidx];
a61af66fc99e Initial load
duke
parents:
diff changeset
379 return (uf_lidx == lidx) ? uf_lidx : Find_compress(lidx);
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381 uint Find_compress( uint lidx );
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 uint Find_id( const Node *n ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
384 uint retval = n2lidx(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
385 assert(retval == Find(n),"Invalid node to lidx mapping");
a61af66fc99e Initial load
duke
parents:
diff changeset
386 return retval;
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // Add edge between reg and everything in the vector.
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // Same as _ifg->add_vector(reg,live) EXCEPT use the RegMask
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // information to trim the set of interferences. Return the
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // count of edges added.
a61af66fc99e Initial load
duke
parents:
diff changeset
393 void interfere_with_live( uint reg, IndexSet *live );
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // Count register pressure for asserts
a61af66fc99e Initial load
duke
parents:
diff changeset
395 uint count_int_pressure( IndexSet *liveout );
a61af66fc99e Initial load
duke
parents:
diff changeset
396 uint count_float_pressure( IndexSet *liveout );
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // Build the interference graph using virtual registers only.
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // Used for aggressive coalescing.
a61af66fc99e Initial load
duke
parents:
diff changeset
400 void build_ifg_virtual( );
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 // Build the interference graph using physical registers when available.
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // That is, if 2 live ranges are simultaneously alive but in their
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // acceptable register sets do not overlap, then they do not interfere.
a61af66fc99e Initial load
duke
parents:
diff changeset
405 uint build_ifg_physical( ResourceArea *a );
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 // Gather LiveRanGe information, including register masks and base pointer/
a61af66fc99e Initial load
duke
parents:
diff changeset
408 // derived pointer relationships.
a61af66fc99e Initial load
duke
parents:
diff changeset
409 void gather_lrg_masks( bool mod_cisc_masks );
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // Force the bases of derived pointers to be alive at GC points.
a61af66fc99e Initial load
duke
parents:
diff changeset
412 bool stretch_base_pointer_live_ranges( ResourceArea *a );
a61af66fc99e Initial load
duke
parents:
diff changeset
413 // Helper to stretch above; recursively discover the base Node for
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // a given derived Node. Easy for AddP-related machine nodes, but
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // needs to be recursive for derived Phis.
a61af66fc99e Initial load
duke
parents:
diff changeset
416 Node *find_base_for_derived( Node **derived_base_map, Node *derived, uint &maxlrg );
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // Set the was-lo-degree bit. Conservative coalescing should not change the
a61af66fc99e Initial load
duke
parents:
diff changeset
419 // colorability of the graph. If any live range was of low-degree before
a61af66fc99e Initial load
duke
parents:
diff changeset
420 // coalescing, it should Simplify. This call sets the was-lo-degree bit.
a61af66fc99e Initial load
duke
parents:
diff changeset
421 void set_was_low();
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // Split live-ranges that must spill due to register conflicts (as opposed
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // to capacity spills). Typically these are things def'd in a register
a61af66fc99e Initial load
duke
parents:
diff changeset
425 // and used on the stack or vice-versa.
a61af66fc99e Initial load
duke
parents:
diff changeset
426 void pre_spill();
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // Init LRG caching of degree, numregs. Init lo_degree list.
a61af66fc99e Initial load
duke
parents:
diff changeset
429 void cache_lrg_info( );
a61af66fc99e Initial load
duke
parents:
diff changeset
430
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // Simplify the IFG by removing LRGs of low degree with no copies
a61af66fc99e Initial load
duke
parents:
diff changeset
432 void Pre_Simplify();
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 // Simplify the IFG by removing LRGs of low degree
a61af66fc99e Initial load
duke
parents:
diff changeset
435 void Simplify();
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 // Select colors by re-inserting edges into the IFG.
605
98cb887364d3 6810672: Comment typos
twisti
parents: 566
diff changeset
438 // Return TRUE if any spills occurred.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
439 uint Select( );
a61af66fc99e Initial load
duke
parents:
diff changeset
440 // Helper function for select which allows biased coloring
a61af66fc99e Initial load
duke
parents:
diff changeset
441 OptoReg::Name choose_color( LRG &lrg, int chunk );
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // Helper function which implements biasing heuristic
a61af66fc99e Initial load
duke
parents:
diff changeset
443 OptoReg::Name bias_color( LRG &lrg, int chunk );
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 // Split uncolorable live ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
446 // Return new number of live ranges
a61af66fc99e Initial load
duke
parents:
diff changeset
447 uint Split( uint maxlrg );
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // Copy 'was_spilled'-edness from one Node to another.
a61af66fc99e Initial load
duke
parents:
diff changeset
450 void copy_was_spilled( Node *src, Node *dst );
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // Set the 'spilled_once' or 'spilled_twice' flag on a node.
a61af66fc99e Initial load
duke
parents:
diff changeset
452 void set_was_spilled( Node *n );
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 // Convert ideal spill-nodes into machine loads & stores
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // Set C->failing when fixup spills could not complete, node limit exceeded.
a61af66fc99e Initial load
duke
parents:
diff changeset
456 void fixup_spills();
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // Post-Allocation peephole copy removal
a61af66fc99e Initial load
duke
parents:
diff changeset
459 void post_allocate_copy_removal();
a61af66fc99e Initial load
duke
parents:
diff changeset
460 Node *skip_copies( Node *c );
923
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
461 // Replace the old node with the current live version of that value
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
462 // and yank the old value if it's dead.
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
463 int replace_and_yank_if_dead( Node *old, OptoReg::Name nreg,
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
464 Block *current_block, Node_List& value, Node_List& regnd ) {
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
465 Node* v = regnd[nreg];
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
466 assert(v->outcnt() != 0, "no dead values");
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
467 old->replace_by(v);
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
468 return yank_if_dead(old, current_block, &value, &regnd);
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
469 }
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 673
diff changeset
470
0
a61af66fc99e Initial load
duke
parents:
diff changeset
471 int yank_if_dead( Node *old, Block *current_block, Node_List *value, Node_List *regnd );
a61af66fc99e Initial load
duke
parents:
diff changeset
472 int elide_copy( Node *n, int k, Block *current_block, Node_List &value, Node_List &regnd, bool can_change_regs );
a61af66fc99e Initial load
duke
parents:
diff changeset
473 int use_prior_register( Node *copy, uint idx, Node *def, Block *current_block, Node_List &value, Node_List &regnd );
a61af66fc99e Initial load
duke
parents:
diff changeset
474 bool may_be_copy_of_callee( Node *def ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // If nreg already contains the same constant as val then eliminate it
70
b683f557224b 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents: 0
diff changeset
477 bool eliminate_copy_of_constant(Node* val, Node* n,
b683f557224b 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents: 0
diff changeset
478 Block *current_block, Node_List& value, Node_List &regnd,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
479 OptoReg::Name nreg, OptoReg::Name nreg2);
a61af66fc99e Initial load
duke
parents:
diff changeset
480 // Extend the node to LRG mapping
a61af66fc99e Initial load
duke
parents:
diff changeset
481 void add_reference( const Node *node, const Node *old_node);
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 static int _final_loads, _final_stores, _final_copies, _final_memoves;
a61af66fc99e Initial load
duke
parents:
diff changeset
486 static double _final_load_cost, _final_store_cost, _final_copy_cost, _final_memove_cost;
a61af66fc99e Initial load
duke
parents:
diff changeset
487 static int _conserv_coalesce, _conserv_coalesce_pair;
a61af66fc99e Initial load
duke
parents:
diff changeset
488 static int _conserv_coalesce_trie, _conserv_coalesce_quad;
a61af66fc99e Initial load
duke
parents:
diff changeset
489 static int _post_alloc;
a61af66fc99e Initial load
duke
parents:
diff changeset
490 static int _lost_opp_pp_coalesce, _lost_opp_cflow_coalesce;
a61af66fc99e Initial load
duke
parents:
diff changeset
491 static int _used_cisc_instructions, _unused_cisc_instructions;
a61af66fc99e Initial load
duke
parents:
diff changeset
492 static int _allocator_attempts, _allocator_successes;
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
495 static uint _high_pressure, _low_pressure;
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 void dump() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
498 void dump( const Node *n ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
499 void dump( const Block * b ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
500 void dump_degree_lists() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
501 void dump_simplified() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
502 void dump_lrg( uint lidx ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
503 void dump_bb( uint pre_order ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // Verify that base pointers and derived pointers are still sane
a61af66fc99e Initial load
duke
parents:
diff changeset
506 void verify_base_ptrs( ResourceArea *a ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
507
566
91263420e1c6 6791852: assert(b->_nodes[insidx] == n,"got insidx set incorrectly")
kvn
parents: 295
diff changeset
508 void verify( ResourceArea *a, bool verify_ifg = false ) const;
91263420e1c6 6791852: assert(b->_nodes[insidx] == n,"got insidx set incorrectly")
kvn
parents: 295
diff changeset
509
0
a61af66fc99e Initial load
duke
parents:
diff changeset
510 void dump_for_spill_split_recycle() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
511
a61af66fc99e Initial load
duke
parents:
diff changeset
512 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
513 void dump_frame() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
514 char *dump_register( const Node *n, char *buf ) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
515 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
516 static void print_chaitin_statistics();
a61af66fc99e Initial load
duke
parents:
diff changeset
517 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
518 friend class PhaseCoalesce;
a61af66fc99e Initial load
duke
parents:
diff changeset
519 friend class PhaseAggressiveCoalesce;
a61af66fc99e Initial load
duke
parents:
diff changeset
520 friend class PhaseConservativeCoalesce;
a61af66fc99e Initial load
duke
parents:
diff changeset
521 };