OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 static inline LifetimePosition Min(LifetimePosition a, LifetimePosition b) { | 64 static inline LifetimePosition Min(LifetimePosition a, LifetimePosition b) { |
65 return a.Value() < b.Value() ? a : b; | 65 return a.Value() < b.Value() ? a : b; |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 static inline LifetimePosition Max(LifetimePosition a, LifetimePosition b) { | 69 static inline LifetimePosition Max(LifetimePosition a, LifetimePosition b) { |
70 return a.Value() > b.Value() ? a : b; | 70 return a.Value() > b.Value() ? a : b; |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 void LOperand::PrintTo(StringStream* stream) { | 74 UsePosition::UsePosition(LifetimePosition pos, LOperand* operand) |
75 LUnallocated* unalloc = NULL; | 75 : operand_(operand), |
76 switch (kind()) { | 76 hint_(NULL), |
77 case INVALID: | 77 pos_(pos), |
78 break; | 78 next_(NULL), |
79 case UNALLOCATED: | 79 requires_reg_(false), |
80 unalloc = LUnallocated::cast(this); | 80 register_beneficial_(true) { |
81 stream->Add("v%d", unalloc->virtual_register()); | 81 if (operand_ != NULL && operand_->IsUnallocated()) { |
82 switch (unalloc->policy()) { | 82 LUnallocated* unalloc = LUnallocated::cast(operand_); |
83 case LUnallocated::NONE: | 83 requires_reg_ = unalloc->HasRegisterPolicy(); |
84 break; | 84 register_beneficial_ = !unalloc->HasAnyPolicy(); |
85 case LUnallocated::FIXED_REGISTER: { | |
86 const char* register_name = | |
87 Register::AllocationIndexToString(unalloc->fixed_index()); | |
88 stream->Add("(=%s)", register_name); | |
89 break; | |
90 } | |
91 case LUnallocated::FIXED_DOUBLE_REGISTER: { | |
92 const char* double_register_name = | |
93 DoubleRegister::AllocationIndexToString(unalloc->fixed_index()); | |
94 stream->Add("(=%s)", double_register_name); | |
95 break; | |
96 } | |
97 case LUnallocated::FIXED_SLOT: | |
98 stream->Add("(=%dS)", unalloc->fixed_index()); | |
99 break; | |
100 case LUnallocated::MUST_HAVE_REGISTER: | |
101 stream->Add("(R)"); | |
102 break; | |
103 case LUnallocated::WRITABLE_REGISTER: | |
104 stream->Add("(WR)"); | |
105 break; | |
106 case LUnallocated::SAME_AS_FIRST_INPUT: | |
107 stream->Add("(1)"); | |
108 break; | |
109 case LUnallocated::ANY: | |
110 stream->Add("(-)"); | |
111 break; | |
112 case LUnallocated::IGNORE: | |
113 stream->Add("(0)"); | |
114 break; | |
115 } | |
116 break; | |
117 case CONSTANT_OPERAND: | |
118 stream->Add("[constant:%d]", index()); | |
119 break; | |
120 case STACK_SLOT: | |
121 stream->Add("[stack:%d]", index()); | |
122 break; | |
123 case DOUBLE_STACK_SLOT: | |
124 stream->Add("[double_stack:%d]", index()); | |
125 break; | |
126 case REGISTER: | |
127 stream->Add("[%s|R]", Register::AllocationIndexToString(index())); | |
128 break; | |
129 case DOUBLE_REGISTER: | |
130 stream->Add("[%s|R]", DoubleRegister::AllocationIndexToString(index())); | |
131 break; | |
132 case ARGUMENT: | |
133 stream->Add("[arg:%d]", index()); | |
134 break; | |
135 } | 85 } |
136 } | 86 ASSERT(pos_.IsValid()); |
137 | |
138 int LOperand::VirtualRegister() { | |
139 LUnallocated* unalloc = LUnallocated::cast(this); | |
140 return unalloc->virtual_register(); | |
141 } | 87 } |
142 | 88 |
143 | 89 |
| 90 bool UsePosition::HasHint() const { |
| 91 return hint_ != NULL && !hint_->IsUnallocated(); |
| 92 } |
| 93 |
| 94 |
144 bool UsePosition::RequiresRegister() const { | 95 bool UsePosition::RequiresRegister() const { |
145 return requires_reg_; | 96 return requires_reg_; |
146 } | 97 } |
147 | 98 |
148 | 99 |
149 bool UsePosition::RegisterIsBeneficial() const { | 100 bool UsePosition::RegisterIsBeneficial() const { |
150 return register_beneficial_; | 101 return register_beneficial_; |
151 } | 102 } |
152 | 103 |
153 | 104 |
(...skipping 29 matching lines...) Expand all Loading... |
183 } | 134 } |
184 current_interval = current_interval->next(); | 135 current_interval = current_interval->next(); |
185 } | 136 } |
186 return false; | 137 return false; |
187 } | 138 } |
188 | 139 |
189 | 140 |
190 #endif | 141 #endif |
191 | 142 |
192 | 143 |
| 144 LiveRange::LiveRange(int id) |
| 145 : id_(id), |
| 146 spilled_(false), |
| 147 assigned_register_(kInvalidAssignment), |
| 148 assigned_register_kind_(NONE), |
| 149 last_interval_(NULL), |
| 150 first_interval_(NULL), |
| 151 first_pos_(NULL), |
| 152 parent_(NULL), |
| 153 next_(NULL), |
| 154 current_interval_(NULL), |
| 155 last_processed_use_(NULL), |
| 156 spill_start_index_(kMaxInt) { |
| 157 spill_operand_ = new LUnallocated(LUnallocated::IGNORE); |
| 158 } |
| 159 |
| 160 |
| 161 void LiveRange::set_assigned_register(int reg, RegisterKind register_kind) { |
| 162 ASSERT(!HasRegisterAssigned() && !IsSpilled()); |
| 163 assigned_register_ = reg; |
| 164 assigned_register_kind_ = register_kind; |
| 165 ConvertOperands(); |
| 166 } |
| 167 |
| 168 |
| 169 void LiveRange::MakeSpilled() { |
| 170 ASSERT(!IsSpilled()); |
| 171 ASSERT(TopLevel()->HasAllocatedSpillOperand()); |
| 172 spilled_ = true; |
| 173 assigned_register_ = kInvalidAssignment; |
| 174 ConvertOperands(); |
| 175 } |
| 176 |
| 177 |
| 178 bool LiveRange::HasAllocatedSpillOperand() const { |
| 179 return spill_operand_ != NULL && !spill_operand_->IsUnallocated(); |
| 180 } |
| 181 |
| 182 |
| 183 void LiveRange::SetSpillOperand(LOperand* operand) { |
| 184 ASSERT(!operand->IsUnallocated()); |
| 185 ASSERT(spill_operand_ != NULL); |
| 186 ASSERT(spill_operand_->IsUnallocated()); |
| 187 spill_operand_->ConvertTo(operand->kind(), operand->index()); |
| 188 } |
| 189 |
| 190 |
193 UsePosition* LiveRange::NextUsePosition(LifetimePosition start) { | 191 UsePosition* LiveRange::NextUsePosition(LifetimePosition start) { |
194 UsePosition* use_pos = last_processed_use_; | 192 UsePosition* use_pos = last_processed_use_; |
195 if (use_pos == NULL) use_pos = first_pos(); | 193 if (use_pos == NULL) use_pos = first_pos(); |
196 while (use_pos != NULL && use_pos->pos().Value() < start.Value()) { | 194 while (use_pos != NULL && use_pos->pos().Value() < start.Value()) { |
197 use_pos = use_pos->next(); | 195 use_pos = use_pos->next(); |
198 } | 196 } |
199 last_processed_use_ = use_pos; | 197 last_processed_use_ = use_pos; |
200 return use_pos; | 198 return use_pos; |
201 } | 199 } |
202 | 200 |
(...skipping 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2148 LiveRange* current = live_ranges()->at(i); | 2146 LiveRange* current = live_ranges()->at(i); |
2149 if (current != NULL) current->Verify(); | 2147 if (current != NULL) current->Verify(); |
2150 } | 2148 } |
2151 } | 2149 } |
2152 | 2150 |
2153 | 2151 |
2154 #endif | 2152 #endif |
2155 | 2153 |
2156 | 2154 |
2157 } } // namespace v8::internal | 2155 } } // namespace v8::internal |
OLD | NEW |