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

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

Issue 694473002: [turbofan] optimize hot loop in ResolveControlFlow (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler/register-allocator.cc » ('j') | src/compiler/register-allocator.cc » ('J')
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 class LiveRange FINAL : public ZoneObject { 179 class LiveRange FINAL : public ZoneObject {
180 public: 180 public:
181 static const int kInvalidAssignment = 0x7fffffff; 181 static const int kInvalidAssignment = 0x7fffffff;
182 182
183 LiveRange(int id, Zone* zone); 183 LiveRange(int id, Zone* zone);
184 184
185 UseInterval* first_interval() const { return first_interval_; } 185 UseInterval* first_interval() const { return first_interval_; }
186 UsePosition* first_pos() const { return first_pos_; } 186 UsePosition* first_pos() const { return first_pos_; }
187 LiveRange* parent() const { return parent_; } 187 LiveRange* parent() const { return parent_; }
188 LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; } 188 LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; }
189 const LiveRange* TopLevel() const {
190 return (parent_ == NULL) ? this : parent_;
191 }
189 LiveRange* next() const { return next_; } 192 LiveRange* next() const { return next_; }
190 bool IsChild() const { return parent() != NULL; } 193 bool IsChild() const { return parent() != NULL; }
191 int id() const { return id_; } 194 int id() const { return id_; }
192 bool IsFixed() const { return id_ < 0; } 195 bool IsFixed() const { return id_ < 0; }
193 bool IsEmpty() const { return first_interval() == NULL; } 196 bool IsEmpty() const { return first_interval() == NULL; }
194 InstructionOperand* CreateAssignedOperand(Zone* zone); 197 InstructionOperand* CreateAssignedOperand(Zone* zone) const;
195 int assigned_register() const { return assigned_register_; } 198 int assigned_register() const { return assigned_register_; }
196 int spill_start_index() const { return spill_start_index_; } 199 int spill_start_index() const { return spill_start_index_; }
197 void set_assigned_register(int reg, Zone* zone); 200 void set_assigned_register(int reg, Zone* zone);
198 void MakeSpilled(Zone* zone); 201 void MakeSpilled(Zone* zone);
199 bool is_phi() const { return is_phi_; } 202 bool is_phi() const { return is_phi_; }
200 void set_is_phi(bool is_phi) { is_phi_ = is_phi; } 203 void set_is_phi(bool is_phi) { is_phi_ = is_phi; }
201 bool is_non_loop_phi() const { return is_non_loop_phi_; } 204 bool is_non_loop_phi() const { return is_non_loop_phi_; }
202 void set_is_non_loop_phi(bool is_non_loop_phi) { 205 void set_is_non_loop_phi(bool is_non_loop_phi) {
203 is_non_loop_phi_ = is_non_loop_phi; 206 is_non_loop_phi_ = is_non_loop_phi;
204 } 207 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 BitVector* assigned_double_registers() { return assigned_double_registers_; } 333 BitVector* assigned_double_registers() { return assigned_double_registers_; }
331 334
332 const ZoneList<LiveRange*>& live_ranges() const { return live_ranges_; } 335 const ZoneList<LiveRange*>& live_ranges() const { return live_ranges_; }
333 const ZoneVector<LiveRange*>& fixed_live_ranges() const { 336 const ZoneVector<LiveRange*>& fixed_live_ranges() const {
334 return fixed_live_ranges_; 337 return fixed_live_ranges_;
335 } 338 }
336 const ZoneVector<LiveRange*>& fixed_double_live_ranges() const { 339 const ZoneVector<LiveRange*>& fixed_double_live_ranges() const {
337 return fixed_double_live_ranges_; 340 return fixed_double_live_ranges_;
338 } 341 }
339 InstructionSequence* code() const { return code_; } 342 InstructionSequence* code() const { return code_; }
343 // This zone is for datastructures only needed during register allocation.
344 Zone* local_zone() const { return local_zone_; }
340 345
341 private: 346 private:
342 int GetVirtualRegister() { 347 int GetVirtualRegister() {
343 int vreg = code()->NextVirtualRegister(); 348 int vreg = code()->NextVirtualRegister();
344 if (vreg >= UnallocatedOperand::kMaxVirtualRegisters) { 349 if (vreg >= UnallocatedOperand::kMaxVirtualRegisters) {
345 allocation_ok_ = false; 350 allocation_ok_ = false;
346 // Maintain the invariant that we return something below the maximum. 351 // Maintain the invariant that we return something below the maximum.
347 return 0; 352 return 0;
348 } 353 }
349 return vreg; 354 return vreg;
350 } 355 }
351 356
352 // Checks whether the value of a given virtual register is a reference. 357 // Checks whether the value of a given virtual register is a reference.
353 // TODO(titzer): rename this to IsReference. 358 // TODO(titzer): rename this to IsReference.
354 bool HasTaggedValue(int virtual_register) const; 359 bool HasTaggedValue(int virtual_register) const;
355 360
356 // Returns the register kind required by the given virtual register. 361 // Returns the register kind required by the given virtual register.
357 RegisterKind RequiredRegisterKind(int virtual_register) const; 362 RegisterKind RequiredRegisterKind(int virtual_register) const;
358 363
359 // This zone is for datastructures only needed during register allocation.
360 Zone* zone() const { return zone_; }
361
362 // This zone is for InstructionOperands and moves that live beyond register 364 // This zone is for InstructionOperands and moves that live beyond register
363 // allocation. 365 // allocation.
364 Zone* code_zone() const { return code()->zone(); } 366 Zone* code_zone() const { return code()->zone(); }
365 367
366 #ifdef DEBUG 368 #ifdef DEBUG
367 void Verify() const; 369 void Verify() const;
368 #endif 370 #endif
369 371
370 void MeetRegisterConstraints(); 372 void MeetRegisterConstraints();
371 void ResolvePhis(); 373 void ResolvePhis();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 460
459 // If we are trying to spill a range inside the loop try to 461 // If we are trying to spill a range inside the loop try to
460 // hoist spill position out to the point just before the loop. 462 // hoist spill position out to the point just before the loop.
461 LifetimePosition FindOptimalSpillingPos(LiveRange* range, 463 LifetimePosition FindOptimalSpillingPos(LiveRange* range,
462 LifetimePosition pos); 464 LifetimePosition pos);
463 465
464 void Spill(LiveRange* range); 466 void Spill(LiveRange* range);
465 bool IsBlockBoundary(LifetimePosition pos); 467 bool IsBlockBoundary(LifetimePosition pos);
466 468
467 // Helper methods for resolving control flow. 469 // Helper methods for resolving control flow.
468 void ResolveControlFlow(LiveRange* range, const InstructionBlock* block, 470 void ResolveControlFlow(const InstructionBlock* block,
469 const InstructionBlock* pred); 471 const LiveRange* cur_cover,
472 const InstructionBlock* pred,
473 const LiveRange* pred_cover);
470 474
471 void SetLiveRangeAssignedRegister(LiveRange* range, int reg); 475 void SetLiveRangeAssignedRegister(LiveRange* range, int reg);
472 476
473 // Return parallel move that should be used to connect ranges split at the 477 // Return parallel move that should be used to connect ranges split at the
474 // given position. 478 // given position.
475 ParallelMove* GetConnectingParallelMove(LifetimePosition pos); 479 ParallelMove* GetConnectingParallelMove(LifetimePosition pos);
476 480
477 // Return the block which contains give lifetime position. 481 // Return the block which contains give lifetime position.
478 const InstructionBlock* GetInstructionBlock(LifetimePosition pos); 482 const InstructionBlock* GetInstructionBlock(LifetimePosition pos);
479 483
480 // Helper methods for the fixed registers. 484 // Helper methods for the fixed registers.
481 int RegisterCount() const; 485 int RegisterCount() const;
482 static int FixedLiveRangeID(int index) { return -index - 1; } 486 static int FixedLiveRangeID(int index) { return -index - 1; }
483 int FixedDoubleLiveRangeID(int index); 487 int FixedDoubleLiveRangeID(int index);
484 LiveRange* FixedLiveRangeFor(int index); 488 LiveRange* FixedLiveRangeFor(int index);
485 LiveRange* FixedDoubleLiveRangeFor(int index); 489 LiveRange* FixedDoubleLiveRangeFor(int index);
486 LiveRange* LiveRangeFor(int index); 490 LiveRange* LiveRangeFor(int index);
487 GapInstruction* GetLastGap(const InstructionBlock* block); 491 GapInstruction* GetLastGap(const InstructionBlock* block);
488 492
489 const char* RegisterName(int allocation_index); 493 const char* RegisterName(int allocation_index);
490 494
491 Instruction* InstructionAt(int index) { return code()->InstructionAt(index); } 495 Instruction* InstructionAt(int index) { return code()->InstructionAt(index); }
492 496
493 Frame* frame() const { return frame_; } 497 Frame* frame() const { return frame_; }
494 const char* debug_name() const { return debug_name_; } 498 const char* debug_name() const { return debug_name_; }
495 const RegisterConfiguration* config() const { return config_; } 499 const RegisterConfiguration* config() const { return config_; }
496 500
497 Zone* const zone_; 501 Zone* const local_zone_;
498 Frame* const frame_; 502 Frame* const frame_;
499 InstructionSequence* const code_; 503 InstructionSequence* const code_;
500 const char* const debug_name_; 504 const char* const debug_name_;
501 505
502 const RegisterConfiguration* config_; 506 const RegisterConfiguration* config_;
503 507
504 // During liveness analysis keep a mapping from block id to live_in sets 508 // During liveness analysis keep a mapping from block id to live_in sets
505 // for blocks already analyzed. 509 // for blocks already analyzed.
506 ZoneList<BitVector*> live_in_sets_; 510 ZoneList<BitVector*> live_in_sets_;
507 511
(...skipping 22 matching lines...) Expand all
530 #endif 534 #endif
531 535
532 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); 536 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator);
533 }; 537 };
534 538
535 } 539 }
536 } 540 }
537 } // namespace v8::internal::compiler 541 } // namespace v8::internal::compiler
538 542
539 #endif // V8_REGISTER_ALLOCATOR_H_ 543 #endif // V8_REGISTER_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/register-allocator.cc » ('j') | src/compiler/register-allocator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698