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

Side by Side Diff: src/lithium-allocator.h

Issue 24438006: Refactor register allocator a little bit (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: One more ASSERT Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/lithium-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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // Code relies on kStep being a power of two. 139 // Code relies on kStep being a power of two.
140 STATIC_ASSERT(IS_POWER_OF_TWO(kStep)); 140 STATIC_ASSERT(IS_POWER_OF_TWO(kStep));
141 141
142 explicit LifetimePosition(int value) : value_(value) { } 142 explicit LifetimePosition(int value) : value_(value) { }
143 143
144 int value_; 144 int value_;
145 }; 145 };
146 146
147 147
148 enum RegisterKind { 148 enum RegisterKind {
149 UNALLOCATED_REGISTERS,
149 GENERAL_REGISTERS, 150 GENERAL_REGISTERS,
150 DOUBLE_REGISTERS 151 DOUBLE_REGISTERS
151 }; 152 };
152 153
153 154
154 // A register-allocator view of a Lithium instruction. It contains the id of 155 // A register-allocator view of a Lithium instruction. It contains the id of
155 // the output operand and a list of input operand uses. 156 // the output operand and a list of input operand uses.
156 157
157 class LInstruction; 158 class LInstruction;
158 class LEnvironment; 159 class LEnvironment;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 LiveRange* parent() const { return parent_; } 284 LiveRange* parent() const { return parent_; }
284 LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; } 285 LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; }
285 LiveRange* next() const { return next_; } 286 LiveRange* next() const { return next_; }
286 bool IsChild() const { return parent() != NULL; } 287 bool IsChild() const { return parent() != NULL; }
287 int id() const { return id_; } 288 int id() const { return id_; }
288 bool IsFixed() const { return id_ < 0; } 289 bool IsFixed() const { return id_ < 0; }
289 bool IsEmpty() const { return first_interval() == NULL; } 290 bool IsEmpty() const { return first_interval() == NULL; }
290 LOperand* CreateAssignedOperand(Zone* zone); 291 LOperand* CreateAssignedOperand(Zone* zone);
291 int assigned_register() const { return assigned_register_; } 292 int assigned_register() const { return assigned_register_; }
292 int spill_start_index() const { return spill_start_index_; } 293 int spill_start_index() const { return spill_start_index_; }
293 void set_assigned_register(int reg, 294 void set_assigned_register(int reg, Zone* zone);
294 RegisterKind register_kind,
295 Zone* zone);
296 void MakeSpilled(Zone* zone); 295 void MakeSpilled(Zone* zone);
297 296
298 // Returns use position in this live range that follows both start 297 // Returns use position in this live range that follows both start
299 // and last processed use position. 298 // and last processed use position.
300 // Modifies internal state of live range! 299 // Modifies internal state of live range!
301 UsePosition* NextUsePosition(LifetimePosition start); 300 UsePosition* NextUsePosition(LifetimePosition start);
302 301
303 // Returns use position for which register is required in this live 302 // Returns use position for which register is required in this live
304 // range and which follows both start and last processed use position 303 // range and which follows both start and last processed use position
305 // Modifies internal state of live range! 304 // Modifies internal state of live range!
(...skipping 10 matching lines...) Expand all
316 315
317 // Can this live range be spilled at this position. 316 // Can this live range be spilled at this position.
318 bool CanBeSpilled(LifetimePosition pos); 317 bool CanBeSpilled(LifetimePosition pos);
319 318
320 // Split this live range at the given position which must follow the start of 319 // Split this live range at the given position which must follow the start of
321 // the range. 320 // the range.
322 // All uses following the given position will be moved from this 321 // All uses following the given position will be moved from this
323 // live range to the result live range. 322 // live range to the result live range.
324 void SplitAt(LifetimePosition position, LiveRange* result, Zone* zone); 323 void SplitAt(LifetimePosition position, LiveRange* result, Zone* zone);
325 324
326 bool IsDouble() const { return is_double_; } 325 RegisterKind Kind() const { return kind_; }
327 bool HasRegisterAssigned() const { 326 bool HasRegisterAssigned() const {
328 return assigned_register_ != kInvalidAssignment; 327 return assigned_register_ != kInvalidAssignment;
329 } 328 }
330 bool IsSpilled() const { return spilled_; } 329 bool IsSpilled() const { return spilled_; }
331 330
332 LOperand* current_hint_operand() const { 331 LOperand* current_hint_operand() const {
333 ASSERT(current_hint_operand_ == FirstHint()); 332 ASSERT(current_hint_operand_ == FirstHint());
334 return current_hint_operand_; 333 return current_hint_operand_;
335 } 334 }
336 LOperand* FirstHint() const { 335 LOperand* FirstHint() const {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 #endif 384 #endif
386 385
387 private: 386 private:
388 void ConvertOperands(Zone* zone); 387 void ConvertOperands(Zone* zone);
389 UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const; 388 UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const;
390 void AdvanceLastProcessedMarker(UseInterval* to_start_of, 389 void AdvanceLastProcessedMarker(UseInterval* to_start_of,
391 LifetimePosition but_not_past) const; 390 LifetimePosition but_not_past) const;
392 391
393 int id_; 392 int id_;
394 bool spilled_; 393 bool spilled_;
395 bool is_double_; 394 RegisterKind kind_;
396 int assigned_register_; 395 int assigned_register_;
397 UseInterval* last_interval_; 396 UseInterval* last_interval_;
398 UseInterval* first_interval_; 397 UseInterval* first_interval_;
399 UsePosition* first_pos_; 398 UsePosition* first_pos_;
400 LiveRange* parent_; 399 LiveRange* parent_;
401 LiveRange* next_; 400 LiveRange* next_;
402 // This is used as a cache, it doesn't affect correctness. 401 // This is used as a cache, it doesn't affect correctness.
403 mutable UseInterval* current_interval_; 402 mutable UseInterval* current_interval_;
404 UsePosition* last_processed_use_; 403 UsePosition* last_processed_use_;
405 // This is used as a cache, it's invalid outside of BuildLiveRanges. 404 // This is used as a cache, it's invalid outside of BuildLiveRanges.
406 LOperand* current_hint_operand_; 405 LOperand* current_hint_operand_;
407 LOperand* spill_operand_; 406 LOperand* spill_operand_;
408 int spill_start_index_; 407 int spill_start_index_;
408
409 friend class LAllocator; // Assigns to kind_.
409 }; 410 };
410 411
411 412
412 class LAllocator BASE_EMBEDDED { 413 class LAllocator BASE_EMBEDDED {
413 public: 414 public:
414 LAllocator(int first_virtual_register, HGraph* graph); 415 LAllocator(int first_virtual_register, HGraph* graph);
415 416
416 static void TraceAlloc(const char* msg, ...); 417 static void TraceAlloc(const char* msg, ...);
417 418
418 // Checks whether the value of a given virtual register is tagged. 419 // Checks whether the value of a given virtual register is tagged.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 LifetimePosition pos); 562 LifetimePosition pos);
562 563
563 void Spill(LiveRange* range); 564 void Spill(LiveRange* range);
564 bool IsBlockBoundary(LifetimePosition pos); 565 bool IsBlockBoundary(LifetimePosition pos);
565 566
566 // Helper methods for resolving control flow. 567 // Helper methods for resolving control flow.
567 void ResolveControlFlow(LiveRange* range, 568 void ResolveControlFlow(LiveRange* range,
568 HBasicBlock* block, 569 HBasicBlock* block,
569 HBasicBlock* pred); 570 HBasicBlock* pred);
570 571
571 inline void SetLiveRangeAssignedRegister(LiveRange* range, 572 inline void SetLiveRangeAssignedRegister(LiveRange* range, int reg);
572 int reg,
573 RegisterKind register_kind);
574 573
575 // Return parallel move that should be used to connect ranges split at the 574 // Return parallel move that should be used to connect ranges split at the
576 // given position. 575 // given position.
577 LParallelMove* GetConnectingParallelMove(LifetimePosition pos); 576 LParallelMove* GetConnectingParallelMove(LifetimePosition pos);
578 577
579 // Return the block which contains give lifetime position. 578 // Return the block which contains give lifetime position.
580 HBasicBlock* GetBlock(LifetimePosition pos); 579 HBasicBlock* GetBlock(LifetimePosition pos);
581 580
582 // Helper methods for the fixed registers. 581 // Helper methods for the fixed registers.
583 int RegisterCount() const; 582 int RegisterCount() const;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 LAllocator* allocator_; 652 LAllocator* allocator_;
654 unsigned allocator_zone_start_allocation_size_; 653 unsigned allocator_zone_start_allocation_size_;
655 654
656 DISALLOW_COPY_AND_ASSIGN(LAllocatorPhase); 655 DISALLOW_COPY_AND_ASSIGN(LAllocatorPhase);
657 }; 656 };
658 657
659 658
660 } } // namespace v8::internal 659 } } // namespace v8::internal
661 660
662 #endif // V8_LITHIUM_ALLOCATOR_H_ 661 #endif // V8_LITHIUM_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/lithium-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698