| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 static const int kInvalidAssignment = 0x7fffffff; | 279 static const int kInvalidAssignment = 0x7fffffff; |
| 280 | 280 |
| 281 explicit LiveRange(int id); | 281 explicit LiveRange(int id); |
| 282 | 282 |
| 283 UseInterval* first_interval() const { return first_interval_; } | 283 UseInterval* first_interval() const { return first_interval_; } |
| 284 UsePosition* first_pos() const { return first_pos_; } | 284 UsePosition* first_pos() const { return first_pos_; } |
| 285 LiveRange* parent() const { return parent_; } | 285 LiveRange* parent() const { return parent_; } |
| 286 LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; } | 286 LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; } |
| 287 LiveRange* next() const { return next_; } | 287 LiveRange* next() const { return next_; } |
| 288 bool IsChild() const { return parent() != NULL; } | 288 bool IsChild() const { return parent() != NULL; } |
| 289 bool IsParent() const { return parent() == NULL; } | |
| 290 int id() const { return id_; } | 289 int id() const { return id_; } |
| 291 bool IsFixed() const { return id_ < 0; } | 290 bool IsFixed() const { return id_ < 0; } |
| 292 bool IsEmpty() const { return first_interval() == NULL; } | 291 bool IsEmpty() const { return first_interval() == NULL; } |
| 293 LOperand* CreateAssignedOperand(); | 292 LOperand* CreateAssignedOperand(); |
| 294 int assigned_register() const { return assigned_register_; } | 293 int assigned_register() const { return assigned_register_; } |
| 295 int spill_start_index() const { return spill_start_index_; } | 294 int spill_start_index() const { return spill_start_index_; } |
| 296 void set_assigned_register(int reg, RegisterKind register_kind); | 295 void set_assigned_register(int reg, RegisterKind register_kind); |
| 297 void MakeSpilled(); | 296 void MakeSpilled(); |
| 298 | 297 |
| 299 // Returns use position in this live range that follows both start | 298 // Returns use position in this live range that follows both start |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 352 |
| 354 bool ShouldBeAllocatedBefore(const LiveRange* other) const; | 353 bool ShouldBeAllocatedBefore(const LiveRange* other) const; |
| 355 bool CanCover(LifetimePosition position) const; | 354 bool CanCover(LifetimePosition position) const; |
| 356 bool Covers(LifetimePosition position); | 355 bool Covers(LifetimePosition position); |
| 357 LifetimePosition FirstIntersection(LiveRange* other); | 356 LifetimePosition FirstIntersection(LiveRange* other); |
| 358 | 357 |
| 359 // Add a new interval or a new use position to this live range. | 358 // Add a new interval or a new use position to this live range. |
| 360 void EnsureInterval(LifetimePosition start, LifetimePosition end); | 359 void EnsureInterval(LifetimePosition start, LifetimePosition end); |
| 361 void AddUseInterval(LifetimePosition start, LifetimePosition end); | 360 void AddUseInterval(LifetimePosition start, LifetimePosition end); |
| 362 UsePosition* AddUsePosition(LifetimePosition pos, LOperand* operand); | 361 UsePosition* AddUsePosition(LifetimePosition pos, LOperand* operand); |
| 363 UsePosition* AddUsePosition(LifetimePosition pos); | |
| 364 | 362 |
| 365 // Shorten the most recently added interval by setting a new start. | 363 // Shorten the most recently added interval by setting a new start. |
| 366 void ShortenTo(LifetimePosition start); | 364 void ShortenTo(LifetimePosition start); |
| 367 | 365 |
| 368 #ifdef DEBUG | 366 #ifdef DEBUG |
| 369 // True if target overlaps an existing interval. | 367 // True if target overlaps an existing interval. |
| 370 bool HasOverlap(UseInterval* target) const; | 368 bool HasOverlap(UseInterval* target) const; |
| 371 void Verify() const; | 369 void Verify() const; |
| 372 #endif | 370 #endif |
| 373 | 371 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 if (bits_ != NULL) new_bits->CopyFrom(*bits_); | 421 if (bits_ != NULL) new_bits->CopyFrom(*bits_); |
| 424 bits_ = new_bits; | 422 bits_ = new_bits; |
| 425 } | 423 } |
| 426 | 424 |
| 427 BitVector* bits_; | 425 BitVector* bits_; |
| 428 }; | 426 }; |
| 429 | 427 |
| 430 | 428 |
| 431 class LAllocator BASE_EMBEDDED { | 429 class LAllocator BASE_EMBEDDED { |
| 432 public: | 430 public: |
| 433 explicit LAllocator(int first_virtual_register, HGraph* graph) | 431 LAllocator(int first_virtual_register, HGraph* graph); |
| 434 : chunk_(NULL), | |
| 435 live_in_sets_(0), | |
| 436 live_ranges_(16), | |
| 437 fixed_live_ranges_(8), | |
| 438 fixed_double_live_ranges_(8), | |
| 439 unhandled_live_ranges_(8), | |
| 440 active_live_ranges_(8), | |
| 441 inactive_live_ranges_(8), | |
| 442 reusable_slots_(8), | |
| 443 next_virtual_register_(first_virtual_register), | |
| 444 first_artificial_register_(first_virtual_register), | |
| 445 mode_(NONE), | |
| 446 num_registers_(-1), | |
| 447 graph_(graph), | |
| 448 has_osr_entry_(false) {} | |
| 449 | 432 |
| 450 static void Setup(); | 433 static void Setup(); |
| 451 static void TraceAlloc(const char* msg, ...); | 434 static void TraceAlloc(const char* msg, ...); |
| 452 | 435 |
| 453 // Lithium translation support. | 436 // Lithium translation support. |
| 454 // Record a use of an input operand in the current instruction. | 437 // Record a use of an input operand in the current instruction. |
| 455 void RecordUse(HValue* value, LUnallocated* operand); | 438 void RecordUse(HValue* value, LUnallocated* operand); |
| 456 // Record the definition of the output operand. | 439 // Record the definition of the output operand. |
| 457 void RecordDefinition(HInstruction* instr, LUnallocated* operand); | 440 void RecordDefinition(HInstruction* instr, LUnallocated* operand); |
| 458 // Record a temporary operand. | 441 // Record a temporary operand. |
| 459 void RecordTemporary(LUnallocated* operand); | 442 void RecordTemporary(LUnallocated* operand); |
| 460 | 443 |
| 461 // Checks whether the value of a given virtual register is tagged. | 444 // Checks whether the value of a given virtual register is tagged. |
| 462 bool HasTaggedValue(int virtual_register) const; | 445 bool HasTaggedValue(int virtual_register) const; |
| 463 | 446 |
| 464 // Returns the register kind required by the given virtual register. | 447 // Returns the register kind required by the given virtual register. |
| 465 RegisterKind RequiredRegisterKind(int virtual_register) const; | 448 RegisterKind RequiredRegisterKind(int virtual_register) const; |
| 466 | 449 |
| 467 // Control max function size. | 450 // Control max function size. |
| 468 static int max_initial_value_ids(); | 451 static int max_initial_value_ids(); |
| 469 | 452 |
| 470 void Allocate(LChunk* chunk); | 453 void Allocate(LChunk* chunk); |
| 471 | 454 |
| 472 const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } | 455 const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } |
| 473 const ZoneList<LiveRange*>* fixed_live_ranges() const { | 456 const Vector<LiveRange*>* fixed_live_ranges() const { |
| 474 return &fixed_live_ranges_; | 457 return &fixed_live_ranges_; |
| 475 } | 458 } |
| 476 const ZoneList<LiveRange*>* fixed_double_live_ranges() const { | 459 const Vector<LiveRange*>* fixed_double_live_ranges() const { |
| 477 return &fixed_double_live_ranges_; | 460 return &fixed_double_live_ranges_; |
| 478 } | 461 } |
| 479 | 462 |
| 480 LChunk* chunk() const { return chunk_; } | 463 LChunk* chunk() const { return chunk_; } |
| 481 HGraph* graph() const { return graph_; } | 464 HGraph* graph() const { return graph_; } |
| 482 | 465 |
| 483 void MarkAsOsrEntry() { | 466 void MarkAsOsrEntry() { |
| 484 // There can be only one. | 467 // There can be only one. |
| 485 ASSERT(!has_osr_entry_); | 468 ASSERT(!has_osr_entry_); |
| 486 // Simply set a flag to find and process instruction later. | 469 // Simply set a flag to find and process instruction later. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 LChunk* chunk_; | 594 LChunk* chunk_; |
| 612 | 595 |
| 613 // During liveness analysis keep a mapping from block id to live_in sets | 596 // During liveness analysis keep a mapping from block id to live_in sets |
| 614 // for blocks already analyzed. | 597 // for blocks already analyzed. |
| 615 ZoneList<BitVector*> live_in_sets_; | 598 ZoneList<BitVector*> live_in_sets_; |
| 616 | 599 |
| 617 // Liveness analysis results. | 600 // Liveness analysis results. |
| 618 ZoneList<LiveRange*> live_ranges_; | 601 ZoneList<LiveRange*> live_ranges_; |
| 619 | 602 |
| 620 // Lists of live ranges | 603 // Lists of live ranges |
| 621 ZoneList<LiveRange*> fixed_live_ranges_; | 604 EmbeddedVector<LiveRange*, Register::kNumAllocatableRegisters> |
| 622 ZoneList<LiveRange*> fixed_double_live_ranges_; | 605 fixed_live_ranges_; |
| 606 EmbeddedVector<LiveRange*, DoubleRegister::kNumAllocatableRegisters> |
| 607 fixed_double_live_ranges_; |
| 623 ZoneList<LiveRange*> unhandled_live_ranges_; | 608 ZoneList<LiveRange*> unhandled_live_ranges_; |
| 624 ZoneList<LiveRange*> active_live_ranges_; | 609 ZoneList<LiveRange*> active_live_ranges_; |
| 625 ZoneList<LiveRange*> inactive_live_ranges_; | 610 ZoneList<LiveRange*> inactive_live_ranges_; |
| 626 ZoneList<LiveRange*> reusable_slots_; | 611 ZoneList<LiveRange*> reusable_slots_; |
| 627 | 612 |
| 628 // Next virtual register number to be assigned to temporaries. | 613 // Next virtual register number to be assigned to temporaries. |
| 629 int next_virtual_register_; | 614 int next_virtual_register_; |
| 630 int first_artificial_register_; | 615 int first_artificial_register_; |
| 631 GrowableBitVector double_artificial_registers_; | 616 GrowableBitVector double_artificial_registers_; |
| 632 | 617 |
| 633 RegisterKind mode_; | 618 RegisterKind mode_; |
| 634 int num_registers_; | 619 int num_registers_; |
| 635 | 620 |
| 636 HGraph* graph_; | 621 HGraph* graph_; |
| 637 | 622 |
| 638 bool has_osr_entry_; | 623 bool has_osr_entry_; |
| 639 | 624 |
| 640 DISALLOW_COPY_AND_ASSIGN(LAllocator); | 625 DISALLOW_COPY_AND_ASSIGN(LAllocator); |
| 641 }; | 626 }; |
| 642 | 627 |
| 643 | 628 |
| 644 } } // namespace v8::internal | 629 } } // namespace v8::internal |
| 645 | 630 |
| 646 #endif // V8_LITHIUM_ALLOCATOR_H_ | 631 #endif // V8_LITHIUM_ALLOCATOR_H_ |
| OLD | NEW |