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

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

Issue 904693002: [turbofan] Remove global InstructionOperand caches. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/zone-containers.h" 9 #include "src/zone-containers.h"
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 UsePosition* next_; 166 UsePosition* next_;
167 bool requires_reg_ : 1; 167 bool requires_reg_ : 1;
168 bool register_beneficial_ : 1; 168 bool register_beneficial_ : 1;
169 169
170 private: 170 private:
171 DISALLOW_COPY_AND_ASSIGN(UsePosition); 171 DISALLOW_COPY_AND_ASSIGN(UsePosition);
172 }; 172 };
173 173
174 class SpillRange; 174 class SpillRange;
175 175
176
177 // TODO(dcarney): remove this cache.
178 class InstructionOperandCache FINAL : public ZoneObject {
179 public:
180 InstructionOperandCache();
181
182 InstructionOperand* RegisterOperand(int index) {
183 DCHECK(index >= 0 &&
184 index < static_cast<int>(arraysize(general_register_operands_)));
185 return &general_register_operands_[index];
186 }
187 InstructionOperand* DoubleRegisterOperand(int index) {
188 DCHECK(index >= 0 &&
189 index < static_cast<int>(arraysize(double_register_operands_)));
190 return &double_register_operands_[index];
191 }
192
193 private:
194 InstructionOperand
195 general_register_operands_[RegisterConfiguration::kMaxGeneralRegisters];
196 InstructionOperand
197 double_register_operands_[RegisterConfiguration::kMaxDoubleRegisters];
198
199 DISALLOW_COPY_AND_ASSIGN(InstructionOperandCache);
200 };
201
202
176 // Representation of SSA values' live ranges as a collection of (continuous) 203 // Representation of SSA values' live ranges as a collection of (continuous)
177 // intervals over the instruction ordering. 204 // intervals over the instruction ordering.
178 class LiveRange FINAL : public ZoneObject { 205 class LiveRange FINAL : public ZoneObject {
179 public: 206 public:
180 static const int kInvalidAssignment = 0x7fffffff; 207 static const int kInvalidAssignment = 0x7fffffff;
181 208
182 LiveRange(int id, Zone* zone); 209 LiveRange(int id, Zone* zone);
183 210
184 UseInterval* first_interval() const { return first_interval_; } 211 UseInterval* first_interval() const { return first_interval_; }
185 UsePosition* first_pos() const { return first_pos_; } 212 UsePosition* first_pos() const { return first_pos_; }
186 LiveRange* parent() const { return parent_; } 213 LiveRange* parent() const { return parent_; }
187 LiveRange* TopLevel() { return (parent_ == nullptr) ? this : parent_; } 214 LiveRange* TopLevel() { return (parent_ == nullptr) ? this : parent_; }
188 const LiveRange* TopLevel() const { 215 const LiveRange* TopLevel() const {
189 return (parent_ == nullptr) ? this : parent_; 216 return (parent_ == nullptr) ? this : parent_;
190 } 217 }
191 LiveRange* next() const { return next_; } 218 LiveRange* next() const { return next_; }
192 bool IsChild() const { return parent() != nullptr; } 219 bool IsChild() const { return parent() != nullptr; }
193 int id() const { return id_; } 220 int id() const { return id_; }
194 bool IsFixed() const { return id_ < 0; } 221 bool IsFixed() const { return id_ < 0; }
195 bool IsEmpty() const { return first_interval() == nullptr; } 222 bool IsEmpty() const { return first_interval() == nullptr; }
196 InstructionOperand* CreateAssignedOperand(Zone* zone) const; 223 // TODO(dcarney): remove this.
224 InstructionOperand* GetAssignedOperand(InstructionOperandCache* cache) const;
225 InstructionOperand GetAssignedOperand() const;
197 int assigned_register() const { return assigned_register_; } 226 int assigned_register() const { return assigned_register_; }
198 int spill_start_index() const { return spill_start_index_; } 227 int spill_start_index() const { return spill_start_index_; }
199 void set_assigned_register(int reg, Zone* zone); 228 void set_assigned_register(int reg, InstructionOperandCache* cache);
200 void MakeSpilled(); 229 void MakeSpilled();
201 bool is_phi() const { return is_phi_; } 230 bool is_phi() const { return is_phi_; }
202 void set_is_phi(bool is_phi) { is_phi_ = is_phi; } 231 void set_is_phi(bool is_phi) { is_phi_ = is_phi; }
203 bool is_non_loop_phi() const { return is_non_loop_phi_; } 232 bool is_non_loop_phi() const { return is_non_loop_phi_; }
204 void set_is_non_loop_phi(bool is_non_loop_phi) { 233 void set_is_non_loop_phi(bool is_non_loop_phi) {
205 is_non_loop_phi_ = is_non_loop_phi; 234 is_non_loop_phi_ = is_non_loop_phi;
206 } 235 }
207 236
208 // Returns use position in this live range that follows both start 237 // Returns use position in this live range that follows both start
209 // and last processed use position. 238 // and last processed use position.
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 LiveRange* LiveRangeFor(int index); 580 LiveRange* LiveRangeFor(int index);
552 GapInstruction* GetLastGap(const InstructionBlock* block); 581 GapInstruction* GetLastGap(const InstructionBlock* block);
553 582
554 const char* RegisterName(int allocation_index); 583 const char* RegisterName(int allocation_index);
555 584
556 Instruction* InstructionAt(int index) { return code()->InstructionAt(index); } 585 Instruction* InstructionAt(int index) { return code()->InstructionAt(index); }
557 586
558 Frame* frame() const { return frame_; } 587 Frame* frame() const { return frame_; }
559 const char* debug_name() const { return debug_name_; } 588 const char* debug_name() const { return debug_name_; }
560 const RegisterConfiguration* config() const { return config_; } 589 const RegisterConfiguration* config() const { return config_; }
590 InstructionOperandCache* operand_cache() const { return operand_cache_; }
561 ZoneVector<LiveRange*>& live_ranges() { return live_ranges_; } 591 ZoneVector<LiveRange*>& live_ranges() { return live_ranges_; }
562 ZoneVector<LiveRange*>& fixed_live_ranges() { return fixed_live_ranges_; } 592 ZoneVector<LiveRange*>& fixed_live_ranges() { return fixed_live_ranges_; }
563 ZoneVector<LiveRange*>& fixed_double_live_ranges() { 593 ZoneVector<LiveRange*>& fixed_double_live_ranges() {
564 return fixed_double_live_ranges_; 594 return fixed_double_live_ranges_;
565 } 595 }
566 ZoneVector<LiveRange*>& unhandled_live_ranges() { 596 ZoneVector<LiveRange*>& unhandled_live_ranges() {
567 return unhandled_live_ranges_; 597 return unhandled_live_ranges_;
568 } 598 }
569 ZoneVector<LiveRange*>& active_live_ranges() { return active_live_ranges_; } 599 ZoneVector<LiveRange*>& active_live_ranges() { return active_live_ranges_; }
570 ZoneVector<LiveRange*>& inactive_live_ranges() { 600 ZoneVector<LiveRange*>& inactive_live_ranges() {
571 return inactive_live_ranges_; 601 return inactive_live_ranges_;
572 } 602 }
573 ZoneVector<LiveRange*>& reusable_slots() { return reusable_slots_; }
574 ZoneVector<SpillRange*>& spill_ranges() { return spill_ranges_; } 603 ZoneVector<SpillRange*>& spill_ranges() { return spill_ranges_; }
575 604
576 struct PhiMapValue { 605 struct PhiMapValue {
577 PhiMapValue(PhiInstruction* phi, const InstructionBlock* block) 606 PhiMapValue(PhiInstruction* phi, const InstructionBlock* block)
578 : phi(phi), block(block) {} 607 : phi(phi), block(block) {}
579 PhiInstruction* const phi; 608 PhiInstruction* const phi;
580 const InstructionBlock* const block; 609 const InstructionBlock* const block;
581 }; 610 };
582 typedef std::map<int, PhiMapValue, std::less<int>, 611 typedef std::map<int, PhiMapValue, std::less<int>,
583 zone_allocator<std::pair<int, PhiMapValue>>> PhiMap; 612 zone_allocator<std::pair<int, PhiMapValue>>> PhiMap;
584 613
585 Zone* const local_zone_; 614 Zone* const local_zone_;
586 Frame* const frame_; 615 Frame* const frame_;
587 InstructionSequence* const code_; 616 InstructionSequence* const code_;
588 const char* const debug_name_; 617 const char* const debug_name_;
589 618
590 const RegisterConfiguration* config_; 619 const RegisterConfiguration* config_;
591 620 InstructionOperandCache* const operand_cache_;
592 PhiMap phi_map_; 621 PhiMap phi_map_;
593 622
594 // During liveness analysis keep a mapping from block id to live_in sets 623 // During liveness analysis keep a mapping from block id to live_in sets
595 // for blocks already analyzed. 624 // for blocks already analyzed.
596 ZoneVector<BitVector*> live_in_sets_; 625 ZoneVector<BitVector*> live_in_sets_;
597 626
598 // Liveness analysis results. 627 // Liveness analysis results.
599 ZoneVector<LiveRange*> live_ranges_; 628 ZoneVector<LiveRange*> live_ranges_;
600 629
601 // Lists of live ranges 630 // Lists of live ranges
602 ZoneVector<LiveRange*> fixed_live_ranges_; 631 ZoneVector<LiveRange*> fixed_live_ranges_;
603 ZoneVector<LiveRange*> fixed_double_live_ranges_; 632 ZoneVector<LiveRange*> fixed_double_live_ranges_;
604 ZoneVector<LiveRange*> unhandled_live_ranges_; 633 ZoneVector<LiveRange*> unhandled_live_ranges_;
605 ZoneVector<LiveRange*> active_live_ranges_; 634 ZoneVector<LiveRange*> active_live_ranges_;
606 ZoneVector<LiveRange*> inactive_live_ranges_; 635 ZoneVector<LiveRange*> inactive_live_ranges_;
607 ZoneVector<LiveRange*> reusable_slots_;
608 ZoneVector<SpillRange*> spill_ranges_; 636 ZoneVector<SpillRange*> spill_ranges_;
609 637
610 RegisterKind mode_; 638 RegisterKind mode_;
611 int num_registers_; 639 int num_registers_;
612 640
613 BitVector* assigned_registers_; 641 BitVector* assigned_registers_;
614 BitVector* assigned_double_registers_; 642 BitVector* assigned_double_registers_;
615 643
616 #ifdef DEBUG 644 #ifdef DEBUG
617 LifetimePosition allocation_finger_; 645 LifetimePosition allocation_finger_;
618 #endif 646 #endif
619 647
620 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); 648 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator);
621 }; 649 };
622 650
623 } // namespace compiler 651 } // namespace compiler
624 } // namespace internal 652 } // namespace internal
625 } // namespace v8 653 } // namespace v8
626 654
627 #endif // V8_REGISTER_ALLOCATOR_H_ 655 #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