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

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

Issue 1205173002: [turbofan] Greedy allocator refactoring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
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/zone-containers.h" 10 #include "src/zone-containers.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 const InstructionOperand& spill_op); 421 const InstructionOperand& spill_op);
422 void SetUseHints(int register_index); 422 void SetUseHints(int register_index);
423 void UnsetUseHints() { SetUseHints(kUnassignedRegister); } 423 void UnsetUseHints() { SetUseHints(kUnassignedRegister); }
424 424
425 struct SpillAtDefinitionList; 425 struct SpillAtDefinitionList;
426 426
427 SpillAtDefinitionList* spills_at_definition() const { 427 SpillAtDefinitionList* spills_at_definition() const {
428 return spills_at_definition_; 428 return spills_at_definition_;
429 } 429 }
430 430
431 // Used solely by the Greedy Allocator:
432 unsigned GetSize();
433 float weight() const { return weight_; }
434 void set_weight(float weight) { weight_ = weight; }
435
436 static const int kInvalidSize = -1;
437 static const float kInvalidWeight;
438 static const float kMaxWeight;
439
431 private: 440 private:
432 void set_spill_type(SpillType value) { 441 void set_spill_type(SpillType value) {
433 bits_ = SpillTypeField::update(bits_, value); 442 bits_ = SpillTypeField::update(bits_, value);
434 } 443 }
435 444
436 void set_spilled(bool value) { bits_ = SpilledField::update(bits_, value); } 445 void set_spilled(bool value) { bits_ = SpilledField::update(bits_, value); }
437 446
438 UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const; 447 UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const;
439 void AdvanceLastProcessedMarker(UseInterval* to_start_of, 448 void AdvanceLastProcessedMarker(UseInterval* to_start_of,
440 LifetimePosition but_not_past) const; 449 LifetimePosition but_not_past) const;
(...skipping 20 matching lines...) Expand all
461 SpillRange* spill_range_; 470 SpillRange* spill_range_;
462 }; 471 };
463 SpillAtDefinitionList* spills_at_definition_; 472 SpillAtDefinitionList* spills_at_definition_;
464 // This is used as a cache, it doesn't affect correctness. 473 // This is used as a cache, it doesn't affect correctness.
465 mutable UseInterval* current_interval_; 474 mutable UseInterval* current_interval_;
466 // This is used as a cache, it doesn't affect correctness. 475 // This is used as a cache, it doesn't affect correctness.
467 mutable UsePosition* last_processed_use_; 476 mutable UsePosition* last_processed_use_;
468 // This is used as a cache, it's invalid outside of BuildLiveRanges. 477 // This is used as a cache, it's invalid outside of BuildLiveRanges.
469 mutable UsePosition* current_hint_position_; 478 mutable UsePosition* current_hint_position_;
470 479
480 // Used solely by the Greedy Allocator:
481 int size_;
titzer 2015/06/29 11:17:57 Can you add a only liner explaining what "size" me
Mircea Trofin 2015/06/29 13:20:16 Done.
482 float weight_;
titzer 2015/06/29 11:17:57 Is this the spill weight or the priority for alloc
Mircea Trofin 2015/06/29 13:20:16 Done.
471 DISALLOW_COPY_AND_ASSIGN(LiveRange); 483 DISALLOW_COPY_AND_ASSIGN(LiveRange);
472 }; 484 };
473 485
474 486
475 struct PrintableLiveRange { 487 struct PrintableLiveRange {
476 const RegisterConfiguration* register_configuration_; 488 const RegisterConfiguration* register_configuration_;
477 const LiveRange* range_; 489 const LiveRange* range_;
478 }; 490 };
479 491
480 492
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 LifetimePosition end); 775 LifetimePosition end);
764 776
765 void Spill(LiveRange* range); 777 void Spill(LiveRange* range);
766 778
767 // If we are trying to spill a range inside the loop try to 779 // If we are trying to spill a range inside the loop try to
768 // hoist spill position out to the point just before the loop. 780 // hoist spill position out to the point just before the loop.
769 LifetimePosition FindOptimalSpillingPos(LiveRange* range, 781 LifetimePosition FindOptimalSpillingPos(LiveRange* range,
770 LifetimePosition pos); 782 LifetimePosition pos);
771 783
772 const ZoneVector<LiveRange*>& GetFixedRegisters() const; 784 const ZoneVector<LiveRange*>& GetFixedRegisters() const;
785 const char* RegisterName(int allocation_index) const;
773 786
774 private: 787 private:
775 RegisterAllocationData* const data_; 788 RegisterAllocationData* const data_;
776 const RegisterKind mode_; 789 const RegisterKind mode_;
777 const int num_registers_; 790 const int num_registers_;
778 791
779 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); 792 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator);
780 }; 793 };
781 794
782 795
783 class LinearScanAllocator final : public RegisterAllocator { 796 class LinearScanAllocator final : public RegisterAllocator {
784 public: 797 public:
785 LinearScanAllocator(RegisterAllocationData* data, RegisterKind kind, 798 LinearScanAllocator(RegisterAllocationData* data, RegisterKind kind,
786 Zone* local_zone); 799 Zone* local_zone);
787 800
788 // Phase 4: compute register assignments. 801 // Phase 4: compute register assignments.
789 void AllocateRegisters(); 802 void AllocateRegisters();
790 803
791 private: 804 private:
792 const char* RegisterName(int allocation_index) const;
793
794 ZoneVector<LiveRange*>& unhandled_live_ranges() { 805 ZoneVector<LiveRange*>& unhandled_live_ranges() {
795 return unhandled_live_ranges_; 806 return unhandled_live_ranges_;
796 } 807 }
797 ZoneVector<LiveRange*>& active_live_ranges() { return active_live_ranges_; } 808 ZoneVector<LiveRange*>& active_live_ranges() { return active_live_ranges_; }
798 ZoneVector<LiveRange*>& inactive_live_ranges() { 809 ZoneVector<LiveRange*>& inactive_live_ranges() {
799 return inactive_live_ranges_; 810 return inactive_live_ranges_;
800 } 811 }
801 812
802 void SetLiveRangeAssignedRegister(LiveRange* range, int reg); 813 void SetLiveRangeAssignedRegister(LiveRange* range, int reg);
803 814
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 RegisterAllocationData* const data_; 931 RegisterAllocationData* const data_;
921 932
922 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); 933 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector);
923 }; 934 };
924 935
925 } // namespace compiler 936 } // namespace compiler
926 } // namespace internal 937 } // namespace internal
927 } // namespace v8 938 } // namespace v8
928 939
929 #endif // V8_REGISTER_ALLOCATOR_H_ 940 #endif // V8_REGISTER_ALLOCATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698