| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_FLOW_GRAPH_ALLOCATOR_H_ | 5 #ifndef VM_FLOW_GRAPH_ALLOCATOR_H_ |
| 6 #define VM_FLOW_GRAPH_ALLOCATOR_H_ | 6 #define VM_FLOW_GRAPH_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 | 10 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 bool blocked_cpu_regs_[kNumberOfCpuRegisters]; | 194 bool blocked_cpu_regs_[kNumberOfCpuRegisters]; |
| 195 | 195 |
| 196 DISALLOW_COPY_AND_ASSIGN(FlowGraphAllocator); | 196 DISALLOW_COPY_AND_ASSIGN(FlowGraphAllocator); |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 | 199 |
| 200 // UsePosition represents a single use of an SSA value by some instruction. | 200 // UsePosition represents a single use of an SSA value by some instruction. |
| 201 // It points to a location slot which either tells register allocator | 201 // It points to a location slot which either tells register allocator |
| 202 // where instruction expects the value (if slot contains a fixed location) or | 202 // where instruction expects the value (if slot contains a fixed location) or |
| 203 // asks register allocator to allocate storage (register or spill slot) for | 203 // asks register allocator to allocate storage (register or spill slot) for |
| 204 // this use with certain properties (if slot contain an unallocated location). | 204 // this use with certain properties (if slot contains an unallocated location). |
| 205 class UsePosition : public ZoneAllocated { | 205 class UsePosition : public ZoneAllocated { |
| 206 public: | 206 public: |
| 207 UsePosition(intptr_t pos, | 207 UsePosition(intptr_t pos, UsePosition* next, Location* location_slot) |
| 208 UsePosition* next, | 208 : pos_(pos), location_slot_(location_slot), next_(next) { } |
| 209 Location* location_slot) | |
| 210 : pos_(pos), | |
| 211 location_slot_(location_slot), | |
| 212 next_(next) { | |
| 213 } | |
| 214 | 209 |
| 215 Location* location_slot() const { return location_slot_; } | 210 Location* location_slot() const { return location_slot_; } |
| 216 void set_location_slot(Location* location_slot) { | 211 void set_location_slot(Location* location_slot) { |
| 217 location_slot_ = location_slot; | 212 location_slot_ = location_slot; |
| 218 } | 213 } |
| 219 | 214 |
| 220 void set_next(UsePosition* next) { next_ = next; } | 215 void set_next(UsePosition* next) { next_ = next; } |
| 221 UsePosition* next() const { return next_; } | 216 UsePosition* next() const { return next_; } |
| 222 | 217 |
| 223 intptr_t pos() const { return pos_; } | 218 intptr_t pos() const { return pos_; } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 272 |
| 278 DISALLOW_COPY_AND_ASSIGN(UseInterval); | 273 DISALLOW_COPY_AND_ASSIGN(UseInterval); |
| 279 }; | 274 }; |
| 280 | 275 |
| 281 | 276 |
| 282 // AllocationFinger is used to keep track of currently active position | 277 // AllocationFinger is used to keep track of currently active position |
| 283 // for the register allocator and cache lookup results. | 278 // for the register allocator and cache lookup results. |
| 284 class AllocationFinger : public ValueObject { | 279 class AllocationFinger : public ValueObject { |
| 285 public: | 280 public: |
| 286 AllocationFinger() | 281 AllocationFinger() |
| 287 : first_pending_use_interval_(NULL), | 282 : first_pending_use_interval_(NULL), |
| 288 first_register_use_(NULL), | 283 first_register_use_(NULL), |
| 289 first_register_beneficial_use_(NULL), | 284 first_register_beneficial_use_(NULL), |
| 290 first_hinted_use_(NULL) { | 285 first_hinted_use_(NULL) { |
| 291 } | 286 } |
| 292 | 287 |
| 293 void Initialize(LiveRange* range); | 288 void Initialize(LiveRange* range); |
| 294 bool Advance(intptr_t start); | 289 bool Advance(intptr_t start); |
| 295 | 290 |
| 296 UseInterval* first_pending_use_interval() const { | 291 UseInterval* first_pending_use_interval() const { |
| 297 return first_pending_use_interval_; | 292 return first_pending_use_interval_; |
| 298 } | 293 } |
| 299 | 294 |
| 300 Location FirstHint(); | 295 Location FirstHint(); |
| 301 UsePosition* FirstRegisterUse(intptr_t after_pos); | 296 UsePosition* FirstRegisterUse(intptr_t after_pos); |
| 302 UsePosition* FirstRegisterBeneficialUse(intptr_t after_pos); | 297 UsePosition* FirstRegisterBeneficialUse(intptr_t after_pos); |
| 303 | 298 |
| 304 private: | 299 private: |
| 305 UseInterval* first_pending_use_interval_; | 300 UseInterval* first_pending_use_interval_; |
| 306 UsePosition* first_register_use_; | 301 UsePosition* first_register_use_; |
| 307 UsePosition* first_register_beneficial_use_; | 302 UsePosition* first_register_beneficial_use_; |
| 308 UsePosition* first_hinted_use_; | 303 UsePosition* first_hinted_use_; |
| 309 | 304 |
| 310 DISALLOW_COPY_AND_ASSIGN(AllocationFinger); | 305 DISALLOW_COPY_AND_ASSIGN(AllocationFinger); |
| 311 }; | 306 }; |
| 312 | 307 |
| 313 | 308 |
| 314 // LiveRange represents a sequence of UseIntervals for a given SSA value. | 309 // LiveRange represents a sequence of UseIntervals for a given SSA value. |
| 315 class LiveRange : public ZoneAllocated { | 310 class LiveRange : public ZoneAllocated { |
| 316 public: | 311 public: |
| 317 explicit LiveRange(intptr_t vreg) | 312 explicit LiveRange(intptr_t vreg) |
| 318 : vreg_(vreg), | 313 : vreg_(vreg), |
| 314 assigned_location_(), |
| 319 uses_(NULL), | 315 uses_(NULL), |
| 320 first_use_interval_(NULL), | 316 first_use_interval_(NULL), |
| 321 last_use_interval_(NULL), | 317 last_use_interval_(NULL), |
| 322 next_sibling_(NULL), | 318 next_sibling_(NULL), |
| 323 finger_() { | 319 finger_() { |
| 324 } | 320 } |
| 325 | 321 |
| 326 static LiveRange* MakeTemp(intptr_t pos, Location* location_slot); | 322 static LiveRange* MakeTemp(intptr_t pos, Location* location_slot); |
| 327 | 323 |
| 328 intptr_t vreg() const { return vreg_; } | 324 intptr_t vreg() const { return vreg_; } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 356 return (Start() <= pos) && (pos < End()); | 352 return (Start() <= pos) && (pos < End()); |
| 357 } | 353 } |
| 358 | 354 |
| 359 private: | 355 private: |
| 360 LiveRange(intptr_t vreg, | 356 LiveRange(intptr_t vreg, |
| 361 UsePosition* uses, | 357 UsePosition* uses, |
| 362 UseInterval* first_use_interval, | 358 UseInterval* first_use_interval, |
| 363 UseInterval* last_use_interval, | 359 UseInterval* last_use_interval, |
| 364 LiveRange* next_sibling) | 360 LiveRange* next_sibling) |
| 365 : vreg_(vreg), | 361 : vreg_(vreg), |
| 362 assigned_location_(), |
| 366 uses_(uses), | 363 uses_(uses), |
| 367 first_use_interval_(first_use_interval), | 364 first_use_interval_(first_use_interval), |
| 368 last_use_interval_(last_use_interval), | 365 last_use_interval_(last_use_interval), |
| 369 next_sibling_(next_sibling), | 366 next_sibling_(next_sibling), |
| 370 finger_() { | 367 finger_() { |
| 371 } | 368 } |
| 372 | 369 |
| 373 const intptr_t vreg_; | 370 const intptr_t vreg_; |
| 374 Location assigned_location_; | 371 Location assigned_location_; |
| 375 | 372 |
| 376 UsePosition* uses_; | 373 UsePosition* uses_; |
| 377 UseInterval* first_use_interval_; | 374 UseInterval* first_use_interval_; |
| 378 UseInterval* last_use_interval_; | 375 UseInterval* last_use_interval_; |
| 379 | 376 |
| 380 LiveRange* next_sibling_; | 377 LiveRange* next_sibling_; |
| 381 | 378 |
| 382 AllocationFinger finger_; | 379 AllocationFinger finger_; |
| 383 | 380 |
| 384 DISALLOW_COPY_AND_ASSIGN(LiveRange); | 381 DISALLOW_COPY_AND_ASSIGN(LiveRange); |
| 385 }; | 382 }; |
| 386 | 383 |
| 387 | 384 |
| 388 } // namespace dart | 385 } // namespace dart |
| 389 | 386 |
| 390 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ | 387 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ |
| OLD | NEW |