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

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

Issue 1380863004: Revert of Reland: Remove register index/code indirection (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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"
11 #include "src/zone-containers.h" 10 #include "src/zone-containers.h"
12 11
13 namespace v8 { 12 namespace v8 {
14 namespace internal { 13 namespace internal {
15 namespace compiler { 14 namespace compiler {
16 15
17 enum RegisterKind { 16 enum RegisterKind {
18 GENERAL_REGISTERS, 17 GENERAL_REGISTERS,
19 DOUBLE_REGISTERS 18 DOUBLE_REGISTERS
20 }; 19 };
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 234 }
236 UsePositionType type() const { return TypeField::decode(flags_); } 235 UsePositionType type() const { return TypeField::decode(flags_); }
237 void set_type(UsePositionType type, bool register_beneficial); 236 void set_type(UsePositionType type, bool register_beneficial);
238 237
239 LifetimePosition pos() const { return pos_; } 238 LifetimePosition pos() const { return pos_; }
240 239
241 UsePosition* next() const { return next_; } 240 UsePosition* next() const { return next_; }
242 void set_next(UsePosition* next) { next_ = next; } 241 void set_next(UsePosition* next) { next_ = next; }
243 242
244 // For hinting only. 243 // For hinting only.
245 void set_assigned_register(int register_code) { 244 void set_assigned_register(int register_index) {
246 flags_ = AssignedRegisterField::update(flags_, register_code); 245 flags_ = AssignedRegisterField::update(flags_, register_index);
247 } 246 }
248 247
249 UsePositionHintType hint_type() const { 248 UsePositionHintType hint_type() const {
250 return HintTypeField::decode(flags_); 249 return HintTypeField::decode(flags_);
251 } 250 }
252 bool HasHint() const; 251 bool HasHint() const;
253 bool HintRegister(int* register_code) const; 252 bool HintRegister(int* register_index) const;
254 void ResolveHint(UsePosition* use_pos); 253 void ResolveHint(UsePosition* use_pos);
255 bool IsResolved() const { 254 bool IsResolved() const {
256 return hint_type() != UsePositionHintType::kUnresolved; 255 return hint_type() != UsePositionHintType::kUnresolved;
257 } 256 }
258 static UsePositionHintType HintTypeForOperand(const InstructionOperand& op); 257 static UsePositionHintType HintTypeForOperand(const InstructionOperand& op);
259 258
260 private: 259 private:
261 typedef BitField<UsePositionType, 0, 2> TypeField; 260 typedef BitField<UsePositionType, 0, 2> TypeField;
262 typedef BitField<UsePositionHintType, 2, 3> HintTypeField; 261 typedef BitField<UsePositionHintType, 2, 3> HintTypeField;
263 typedef BitField<bool, 5, 1> RegisterBeneficialField; 262 typedef BitField<bool, 5, 1> RegisterBeneficialField;
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 public: 659 public:
661 class PhiMapValue : public ZoneObject { 660 class PhiMapValue : public ZoneObject {
662 public: 661 public:
663 PhiMapValue(PhiInstruction* phi, const InstructionBlock* block, Zone* zone); 662 PhiMapValue(PhiInstruction* phi, const InstructionBlock* block, Zone* zone);
664 663
665 const PhiInstruction* phi() const { return phi_; } 664 const PhiInstruction* phi() const { return phi_; }
666 const InstructionBlock* block() const { return block_; } 665 const InstructionBlock* block() const { return block_; }
667 666
668 // For hinting. 667 // For hinting.
669 int assigned_register() const { return assigned_register_; } 668 int assigned_register() const { return assigned_register_; }
670 void set_assigned_register(int register_code) { 669 void set_assigned_register(int register_index) {
671 DCHECK_EQ(assigned_register_, kUnassignedRegister); 670 DCHECK_EQ(assigned_register_, kUnassignedRegister);
672 assigned_register_ = register_code; 671 assigned_register_ = register_index;
673 } 672 }
674 void UnsetAssignedRegister() { assigned_register_ = kUnassignedRegister; } 673 void UnsetAssignedRegister() { assigned_register_ = kUnassignedRegister; }
675 674
676 void AddOperand(InstructionOperand* operand); 675 void AddOperand(InstructionOperand* operand);
677 void CommitAssignment(const InstructionOperand& operand); 676 void CommitAssignment(const InstructionOperand& operand);
678 677
679 private: 678 private:
680 PhiInstruction* const phi_; 679 PhiInstruction* const phi_;
681 const InstructionBlock* const block_; 680 const InstructionBlock* const block_;
682 ZoneVector<InstructionOperand*> incoming_operands_; 681 ZoneVector<InstructionOperand*> incoming_operands_;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 762
764 private: 763 private:
765 int GetNextLiveRangeId(); 764 int GetNextLiveRangeId();
766 765
767 Zone* const allocation_zone_; 766 Zone* const allocation_zone_;
768 Frame* const frame_; 767 Frame* const frame_;
769 InstructionSequence* const code_; 768 InstructionSequence* const code_;
770 const char* const debug_name_; 769 const char* const debug_name_;
771 const RegisterConfiguration* const config_; 770 const RegisterConfiguration* const config_;
772 PhiMap phi_map_; 771 PhiMap phi_map_;
773 ZoneVector<int> allocatable_codes_;
774 ZoneVector<int> allocatable_double_codes_;
775 ZoneVector<BitVector*> live_in_sets_; 772 ZoneVector<BitVector*> live_in_sets_;
776 ZoneVector<BitVector*> live_out_sets_; 773 ZoneVector<BitVector*> live_out_sets_;
777 ZoneVector<TopLevelLiveRange*> live_ranges_; 774 ZoneVector<TopLevelLiveRange*> live_ranges_;
778 ZoneVector<TopLevelLiveRange*> fixed_live_ranges_; 775 ZoneVector<TopLevelLiveRange*> fixed_live_ranges_;
779 ZoneVector<TopLevelLiveRange*> fixed_double_live_ranges_; 776 ZoneVector<TopLevelLiveRange*> fixed_double_live_ranges_;
780 ZoneVector<SpillRange*> spill_ranges_; 777 ZoneVector<SpillRange*> spill_ranges_;
781 DelayedReferences delayed_references_; 778 DelayedReferences delayed_references_;
782 BitVector* assigned_registers_; 779 BitVector* assigned_registers_;
783 BitVector* assigned_double_registers_; 780 BitVector* assigned_double_registers_;
784 int virtual_register_count_; 781 int virtual_register_count_;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 879
883 class RegisterAllocator : public ZoneObject { 880 class RegisterAllocator : public ZoneObject {
884 public: 881 public:
885 explicit RegisterAllocator(RegisterAllocationData* data, RegisterKind kind); 882 explicit RegisterAllocator(RegisterAllocationData* data, RegisterKind kind);
886 883
887 protected: 884 protected:
888 RegisterAllocationData* data() const { return data_; } 885 RegisterAllocationData* data() const { return data_; }
889 InstructionSequence* code() const { return data()->code(); } 886 InstructionSequence* code() const { return data()->code(); }
890 RegisterKind mode() const { return mode_; } 887 RegisterKind mode() const { return mode_; }
891 int num_registers() const { return num_registers_; } 888 int num_registers() const { return num_registers_; }
892 int num_allocatable_registers() const { return num_allocatable_registers_; }
893 int allocatable_register_code(int allocatable_index) const {
894 return allocatable_register_codes_[allocatable_index];
895 }
896 889
897 Zone* allocation_zone() const { return data()->allocation_zone(); } 890 Zone* allocation_zone() const { return data()->allocation_zone(); }
898 891
899 // Split the given range at the given position. 892 // Split the given range at the given position.
900 // If range starts at or after the given position then the 893 // If range starts at or after the given position then the
901 // original range is returned. 894 // original range is returned.
902 // Otherwise returns the live range that starts at pos and contains 895 // Otherwise returns the live range that starts at pos and contains
903 // all uses from the original range that follow pos. Uses at pos will 896 // all uses from the original range that follow pos. Uses at pos will
904 // still be owned by the original range after splitting. 897 // still be owned by the original range after splitting.
905 LiveRange* SplitRangeAt(LiveRange* range, LifetimePosition pos); 898 LiveRange* SplitRangeAt(LiveRange* range, LifetimePosition pos);
(...skipping 15 matching lines...) Expand all
921 LifetimePosition FindOptimalSpillingPos(LiveRange* range, 914 LifetimePosition FindOptimalSpillingPos(LiveRange* range,
922 LifetimePosition pos); 915 LifetimePosition pos);
923 916
924 const ZoneVector<TopLevelLiveRange*>& GetFixedRegisters() const; 917 const ZoneVector<TopLevelLiveRange*>& GetFixedRegisters() const;
925 const char* RegisterName(int allocation_index) const; 918 const char* RegisterName(int allocation_index) const;
926 919
927 private: 920 private:
928 RegisterAllocationData* const data_; 921 RegisterAllocationData* const data_;
929 const RegisterKind mode_; 922 const RegisterKind mode_;
930 const int num_registers_; 923 const int num_registers_;
931 int num_allocatable_registers_;
932 const int* allocatable_register_codes_;
933 924
934 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); 925 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator);
935 }; 926 };
936 927
937 928
938 class LinearScanAllocator final : public RegisterAllocator { 929 class LinearScanAllocator final : public RegisterAllocator {
939 public: 930 public:
940 LinearScanAllocator(RegisterAllocationData* data, RegisterKind kind, 931 LinearScanAllocator(RegisterAllocationData* data, RegisterKind kind,
941 Zone* local_zone); 932 Zone* local_zone);
942 933
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 RegisterAllocationData* const data_; 1075 RegisterAllocationData* const data_;
1085 1076
1086 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); 1077 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector);
1087 }; 1078 };
1088 1079
1089 } // namespace compiler 1080 } // namespace compiler
1090 } // namespace internal 1081 } // namespace internal
1091 } // namespace v8 1082 } // namespace v8
1092 1083
1093 #endif // V8_REGISTER_ALLOCATOR_H_ 1084 #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