Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Side by Side Diff: src/compiler/register-allocator.h

Issue 2060673002: [turbofan] Retiring Greedy Allocator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/pipeline.cc ('k') | src/compiler/register-allocator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_REGISTER_ALLOCATOR_H_ 5 #ifndef V8_REGISTER_ALLOCATOR_H_
6 #define V8_REGISTER_ALLOCATOR_H_ 6 #define V8_REGISTER_ALLOCATOR_H_
7 7
8 #include "src/compiler/instruction.h" 8 #include "src/compiler/instruction.h"
9 #include "src/ostreams.h" 9 #include "src/ostreams.h"
10 #include "src/register-configuration.h" 10 #include "src/register-configuration.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 void VerifyChildStructure() const { 405 void VerifyChildStructure() const {
406 VerifyIntervals(); 406 VerifyIntervals();
407 VerifyPositions(); 407 VerifyPositions();
408 } 408 }
409 409
410 void ConvertUsesToOperand(const InstructionOperand& op, 410 void ConvertUsesToOperand(const InstructionOperand& op,
411 const InstructionOperand& spill_op); 411 const InstructionOperand& spill_op);
412 void SetUseHints(int register_index); 412 void SetUseHints(int register_index);
413 void UnsetUseHints() { SetUseHints(kUnassignedRegister); } 413 void UnsetUseHints() { SetUseHints(kUnassignedRegister); }
414 414
415 // Used solely by the Greedy Allocator:
416 unsigned GetSize();
417 float weight() const { return weight_; }
418 void set_weight(float weight) { weight_ = weight; }
419 LiveRangeGroup* group() const { return group_; }
420 void set_group(LiveRangeGroup* group) { group_ = group; }
421 void Print(const RegisterConfiguration* config, bool with_children) const; 415 void Print(const RegisterConfiguration* config, bool with_children) const;
422 void Print(bool with_children) const; 416 void Print(bool with_children) const;
423 417
424 static const int kInvalidSize = -1;
425 static const float kInvalidWeight;
426 static const float kMaxWeight;
427
428 private: 418 private:
429 friend class TopLevelLiveRange; 419 friend class TopLevelLiveRange;
430 explicit LiveRange(int relative_id, MachineRepresentation rep, 420 explicit LiveRange(int relative_id, MachineRepresentation rep,
431 TopLevelLiveRange* top_level); 421 TopLevelLiveRange* top_level);
432 422
433 void UpdateParentForAllChildren(TopLevelLiveRange* new_top_level); 423 void UpdateParentForAllChildren(TopLevelLiveRange* new_top_level);
434 424
435 void set_spilled(bool value) { bits_ = SpilledField::update(bits_, value); } 425 void set_spilled(bool value) { bits_ = SpilledField::update(bits_, value); }
436 426
437 UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const; 427 UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const;
(...skipping 16 matching lines...) Expand all
454 TopLevelLiveRange* top_level_; 444 TopLevelLiveRange* top_level_;
455 LiveRange* next_; 445 LiveRange* next_;
456 // This is used as a cache, it doesn't affect correctness. 446 // This is used as a cache, it doesn't affect correctness.
457 mutable UseInterval* current_interval_; 447 mutable UseInterval* current_interval_;
458 // This is used as a cache, it doesn't affect correctness. 448 // This is used as a cache, it doesn't affect correctness.
459 mutable UsePosition* last_processed_use_; 449 mutable UsePosition* last_processed_use_;
460 // This is used as a cache, it's invalid outside of BuildLiveRanges. 450 // This is used as a cache, it's invalid outside of BuildLiveRanges.
461 mutable UsePosition* current_hint_position_; 451 mutable UsePosition* current_hint_position_;
462 // Cache the last position splintering stopped at. 452 // Cache the last position splintering stopped at.
463 mutable UsePosition* splitting_pointer_; 453 mutable UsePosition* splitting_pointer_;
464 // greedy: the number of LifetimePositions covered by this range. Used to
465 // prioritize selecting live ranges for register assignment, as well as
466 // in weight calculations.
467 int size_;
468
469 // greedy: a metric for resolving conflicts between ranges with an assigned
470 // register and ranges that intersect them and need a register.
471 float weight_;
472
473 // greedy: groupping
474 LiveRangeGroup* group_;
475 454
476 DISALLOW_COPY_AND_ASSIGN(LiveRange); 455 DISALLOW_COPY_AND_ASSIGN(LiveRange);
477 }; 456 };
478 457
479 458
480 class LiveRangeGroup final : public ZoneObject { 459 class LiveRangeGroup final : public ZoneObject {
481 public: 460 public:
482 explicit LiveRangeGroup(Zone* zone) : ranges_(zone) {} 461 explicit LiveRangeGroup(Zone* zone) : ranges_(zone) {}
483 ZoneVector<LiveRange*>& ranges() { return ranges_; } 462 ZoneVector<LiveRange*>& ranges() { return ranges_; }
484 const ZoneVector<LiveRange*>& ranges() const { return ranges_; } 463 const ZoneVector<LiveRange*>& ranges() const { return ranges_; }
485 464
486 // TODO(mtrofin): populate assigned register and use in weight calculation.
487 int assigned_register() const { return assigned_register_; } 465 int assigned_register() const { return assigned_register_; }
488 void set_assigned_register(int reg) { assigned_register_ = reg; } 466 void set_assigned_register(int reg) { assigned_register_ = reg; }
489 467
490 private: 468 private:
491 ZoneVector<LiveRange*> ranges_; 469 ZoneVector<LiveRange*> ranges_;
492 int assigned_register_; 470 int assigned_register_;
493 DISALLOW_COPY_AND_ASSIGN(LiveRangeGroup); 471 DISALLOW_COPY_AND_ASSIGN(LiveRangeGroup);
494 }; 472 };
495 473
496 474
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 RegisterAllocationData* const data_; 1167 RegisterAllocationData* const data_;
1190 1168
1191 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); 1169 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector);
1192 }; 1170 };
1193 1171
1194 } // namespace compiler 1172 } // namespace compiler
1195 } // namespace internal 1173 } // namespace internal
1196 } // namespace v8 1174 } // namespace v8
1197 1175
1198 #endif // V8_REGISTER_ALLOCATOR_H_ 1176 #endif // V8_REGISTER_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « src/compiler/pipeline.cc ('k') | src/compiler/register-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698