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"); |