Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/chaitin.hpp @ 14422:2b8e28fdf503
Merge
author | kvn |
---|---|
date | Tue, 05 Nov 2013 17:38:04 -0800 |
parents | d8a449d2f5b2 |
children | de6a9e811145 |
comparison
equal
deleted
inserted
replaced
14421:3068270ba476 | 14422:2b8e28fdf503 |
---|---|
50 //------------------------------LRG-------------------------------------------- | 50 //------------------------------LRG-------------------------------------------- |
51 // Live-RanGe structure. | 51 // Live-RanGe structure. |
52 class LRG : public ResourceObj { | 52 class LRG : public ResourceObj { |
53 friend class VMStructs; | 53 friend class VMStructs; |
54 public: | 54 public: |
55 static const uint AllStack_size = 0xFFFFF; // This mask size is used to tell that the mask of this LRG supports stack positions | |
55 enum { SPILL_REG=29999 }; // Register number of a spilled LRG | 56 enum { SPILL_REG=29999 }; // Register number of a spilled LRG |
56 | 57 |
57 double _cost; // 2 for loads/1 for stores times block freq | 58 double _cost; // 2 for loads/1 for stores times block freq |
58 double _area; // Sum of all simultaneously live values | 59 double _area; // Sum of all simultaneously live values |
59 double score() const; // Compute score from cost and area | 60 double score() const; // Compute score from cost and area |
78 void set_reg( OptoReg::Name r ) { _reg = r; } | 79 void set_reg( OptoReg::Name r ) { _reg = r; } |
79 | 80 |
80 private: | 81 private: |
81 uint _eff_degree; // Effective degree: Sum of neighbors _num_regs | 82 uint _eff_degree; // Effective degree: Sum of neighbors _num_regs |
82 public: | 83 public: |
83 int degree() const { assert( _degree_valid, "" ); return _eff_degree; } | 84 int degree() const { assert( _degree_valid , "" ); return _eff_degree; } |
84 // Degree starts not valid and any change to the IFG neighbor | 85 // Degree starts not valid and any change to the IFG neighbor |
85 // set makes it not valid. | 86 // set makes it not valid. |
86 void set_degree( uint degree ) { _eff_degree = degree; debug_only(_degree_valid = 1;) } | 87 void set_degree( uint degree ) { |
88 _eff_degree = degree; | |
89 debug_only(_degree_valid = 1;) | |
90 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"); | |
91 } | |
87 // Made a change that hammered degree | 92 // Made a change that hammered degree |
88 void invalid_degree() { debug_only(_degree_valid=0;) } | 93 void invalid_degree() { debug_only(_degree_valid=0;) } |
89 // Incrementally modify degree. If it was correct, it should remain correct | 94 // Incrementally modify degree. If it was correct, it should remain correct |
90 void inc_degree( uint mod ) { _eff_degree += mod; } | 95 void inc_degree( uint mod ) { |
96 _eff_degree += mod; | |
97 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"); | |
98 } | |
91 // Compute the degree between 2 live ranges | 99 // Compute the degree between 2 live ranges |
92 int compute_degree( LRG &l ) const; | 100 int compute_degree( LRG &l ) const; |
93 | 101 |
94 private: | 102 private: |
95 RegMask _mask; // Allowed registers for this LRG | 103 RegMask _mask; // Allowed registers for this LRG |
96 uint _mask_size; // cache of _mask.Size(); | 104 uint _mask_size; // cache of _mask.Size(); |
97 public: | 105 public: |
98 int compute_mask_size() const { return _mask.is_AllStack() ? 65535 : _mask.Size(); } | 106 int compute_mask_size() const { return _mask.is_AllStack() ? AllStack_size : _mask.Size(); } |
99 void set_mask_size( int size ) { | 107 void set_mask_size( int size ) { |
100 assert((size == 65535) || (size == (int)_mask.Size()), ""); | 108 assert((size == (int)AllStack_size) || (size == (int)_mask.Size()), ""); |
101 _mask_size = size; | 109 _mask_size = size; |
102 #ifdef ASSERT | 110 #ifdef ASSERT |
103 _msize_valid=1; | 111 _msize_valid=1; |
104 if (_is_vector) { | 112 if (_is_vector) { |
105 assert(!_fat_proj, "sanity"); | 113 assert(!_fat_proj, "sanity"); |
281 // Map from Nodes to live ranges | 289 // Map from Nodes to live ranges |
282 LRG_List _names; | 290 LRG_List _names; |
283 | 291 |
284 // Straight out of Tarjan's union-find algorithm | 292 // Straight out of Tarjan's union-find algorithm |
285 uint find_compress(const Node *node) { | 293 uint find_compress(const Node *node) { |
286 uint lrg_id = find_compress(_names[node->_idx]); | 294 uint lrg_id = find_compress(_names.at(node->_idx)); |
287 _names.map(node->_idx, lrg_id); | 295 _names.at_put(node->_idx, lrg_id); |
288 return lrg_id; | 296 return lrg_id; |
289 } | 297 } |
290 | 298 |
291 uint find_compress(uint lrg); | 299 uint find_compress(uint lrg); |
292 | 300 |
303 void set_max_lrg_id(uint max_lrg_id) { | 311 void set_max_lrg_id(uint max_lrg_id) { |
304 _max_lrg_id = max_lrg_id; | 312 _max_lrg_id = max_lrg_id; |
305 } | 313 } |
306 | 314 |
307 uint size() const { | 315 uint size() const { |
308 return _names.Size(); | 316 return _names.length(); |
309 } | 317 } |
310 | 318 |
311 uint live_range_id(uint idx) const { | 319 uint live_range_id(uint idx) const { |
312 return _names[idx]; | 320 return _names.at(idx); |
313 } | 321 } |
314 | 322 |
315 uint live_range_id(const Node *node) const { | 323 uint live_range_id(const Node *node) const { |
316 return _names[node->_idx]; | 324 return _names.at(node->_idx); |
317 } | 325 } |
318 | 326 |
319 uint uf_live_range_id(uint lrg_id) const { | 327 uint uf_live_range_id(uint lrg_id) const { |
320 return _uf_map[lrg_id]; | 328 return _uf_map.at(lrg_id); |
321 } | 329 } |
322 | 330 |
323 void map(uint idx, uint lrg_id) { | 331 void map(uint idx, uint lrg_id) { |
324 _names.map(idx, lrg_id); | 332 _names.at_put(idx, lrg_id); |
325 } | 333 } |
326 | 334 |
327 void uf_map(uint dst_lrg_id, uint src_lrg_id) { | 335 void uf_map(uint dst_lrg_id, uint src_lrg_id) { |
328 _uf_map.map(dst_lrg_id, src_lrg_id); | 336 _uf_map.at_put(dst_lrg_id, src_lrg_id); |
329 } | 337 } |
330 | 338 |
331 void extend(uint idx, uint lrg_id) { | 339 void extend(uint idx, uint lrg_id) { |
332 _names.extend(idx, lrg_id); | 340 _names.at_put_grow(idx, lrg_id); |
333 } | 341 } |
334 | 342 |
335 void uf_extend(uint dst_lrg_id, uint src_lrg_id) { | 343 void uf_extend(uint dst_lrg_id, uint src_lrg_id) { |
336 _uf_map.extend(dst_lrg_id, src_lrg_id); | 344 _uf_map.at_put_grow(dst_lrg_id, src_lrg_id); |
337 } | 345 } |
338 | 346 |
339 LiveRangeMap(uint unique) | 347 LiveRangeMap(Arena* arena, uint unique) |
340 : _names(unique) | 348 : _names(arena, unique, unique, 0) |
341 , _uf_map(unique) | 349 , _uf_map(arena, unique, unique, 0) |
342 , _max_lrg_id(0) {} | 350 , _max_lrg_id(0) {} |
343 | 351 |
344 uint find_id( const Node *n ) { | 352 uint find_id( const Node *n ) { |
345 uint retval = live_range_id(n); | 353 uint retval = live_range_id(n); |
346 assert(retval == find(n),"Invalid node to lidx mapping"); | 354 assert(retval == find(n),"Invalid node to lidx mapping"); |
353 // Make all Nodes map directly to their final live range; no need for | 361 // Make all Nodes map directly to their final live range; no need for |
354 // the Union-Find mapping after this call. | 362 // the Union-Find mapping after this call. |
355 void compress_uf_map_for_nodes(); | 363 void compress_uf_map_for_nodes(); |
356 | 364 |
357 uint find(uint lidx) { | 365 uint find(uint lidx) { |
358 uint uf_lidx = _uf_map[lidx]; | 366 uint uf_lidx = _uf_map.at(lidx); |
359 return (uf_lidx == lidx) ? uf_lidx : find_compress(lidx); | 367 return (uf_lidx == lidx) ? uf_lidx : find_compress(lidx); |
360 } | 368 } |
361 | 369 |
362 // Convert a Node into a Live Range Index - a lidx | 370 // Convert a Node into a Live Range Index - a lidx |
363 uint find(const Node *node) { | 371 uint find(const Node *node) { |
364 uint lidx = live_range_id(node); | 372 uint lidx = live_range_id(node); |
365 uint uf_lidx = _uf_map[lidx]; | 373 uint uf_lidx = _uf_map.at(lidx); |
366 return (uf_lidx == lidx) ? uf_lidx : find_compress(node); | 374 return (uf_lidx == lidx) ? uf_lidx : find_compress(node); |
367 } | 375 } |
368 | 376 |
369 // Like Find above, but no path compress, so bad asymptotic behavior | 377 // Like Find above, but no path compress, so bad asymptotic behavior |
370 uint find_const(uint lrg) const; | 378 uint find_const(uint lrg) const; |
371 | 379 |
372 // Like Find above, but no path compress, so bad asymptotic behavior | 380 // Like Find above, but no path compress, so bad asymptotic behavior |
373 uint find_const(const Node *node) const { | 381 uint find_const(const Node *node) const { |
374 if(node->_idx >= _names.Size()) { | 382 if(node->_idx >= (uint)_names.length()) { |
375 return 0; // not mapped, usual for debug dump | 383 return 0; // not mapped, usual for debug dump |
376 } | 384 } |
377 return find_const(_names[node->_idx]); | 385 return find_const(_names.at(node->_idx)); |
378 } | 386 } |
379 }; | 387 }; |
380 | 388 |
381 //------------------------------Chaitin---------------------------------------- | 389 //------------------------------Chaitin---------------------------------------- |
382 // Briggs-Chaitin style allocation, mostly. | 390 // Briggs-Chaitin style allocation, mostly. |