| OLD | NEW |
| 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 #include "src/base/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/compiler/linkage.h" | 6 #include "src/compiler/linkage.h" |
| 7 #include "src/compiler/register-allocator.h" | 7 #include "src/compiler/register-allocator.h" |
| 8 #include "src/string-stream.h" | 8 #include "src/string-stream.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 os << 'i'; | 406 os << 'i'; |
| 407 } | 407 } |
| 408 if (pos.IsStart()) { | 408 if (pos.IsStart()) { |
| 409 os << 's'; | 409 os << 's'; |
| 410 } else { | 410 } else { |
| 411 os << 'e'; | 411 os << 'e'; |
| 412 } | 412 } |
| 413 return os; | 413 return os; |
| 414 } | 414 } |
| 415 | 415 |
| 416 | |
| 417 const float LiveRange::kInvalidWeight = -1; | |
| 418 const float LiveRange::kMaxWeight = std::numeric_limits<float>::max(); | |
| 419 | |
| 420 | |
| 421 LiveRange::LiveRange(int relative_id, MachineRepresentation rep, | 416 LiveRange::LiveRange(int relative_id, MachineRepresentation rep, |
| 422 TopLevelLiveRange* top_level) | 417 TopLevelLiveRange* top_level) |
| 423 : relative_id_(relative_id), | 418 : relative_id_(relative_id), |
| 424 bits_(0), | 419 bits_(0), |
| 425 last_interval_(nullptr), | 420 last_interval_(nullptr), |
| 426 first_interval_(nullptr), | 421 first_interval_(nullptr), |
| 427 first_pos_(nullptr), | 422 first_pos_(nullptr), |
| 428 top_level_(top_level), | 423 top_level_(top_level), |
| 429 next_(nullptr), | 424 next_(nullptr), |
| 430 current_interval_(nullptr), | 425 current_interval_(nullptr), |
| 431 last_processed_use_(nullptr), | 426 last_processed_use_(nullptr), |
| 432 current_hint_position_(nullptr), | 427 current_hint_position_(nullptr), |
| 433 splitting_pointer_(nullptr), | 428 splitting_pointer_(nullptr) { |
| 434 size_(kInvalidSize), | |
| 435 weight_(kInvalidWeight), | |
| 436 group_(nullptr) { | |
| 437 DCHECK(AllocatedOperand::IsSupportedRepresentation(rep)); | 429 DCHECK(AllocatedOperand::IsSupportedRepresentation(rep)); |
| 438 bits_ = AssignedRegisterField::encode(kUnassignedRegister) | | 430 bits_ = AssignedRegisterField::encode(kUnassignedRegister) | |
| 439 RepresentationField::encode(rep); | 431 RepresentationField::encode(rep); |
| 440 } | 432 } |
| 441 | 433 |
| 442 | 434 |
| 443 void LiveRange::VerifyPositions() const { | 435 void LiveRange::VerifyPositions() const { |
| 444 // Walk the positions, verifying that each is in an interval. | 436 // Walk the positions, verifying that each is in an interval. |
| 445 UseInterval* interval = first_interval_; | 437 UseInterval* interval = first_interval_; |
| 446 for (UsePosition* pos = first_pos_; pos != nullptr; pos = pos->next()) { | 438 for (UsePosition* pos = first_pos_; pos != nullptr; pos = pos->next()) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 } else { | 684 } else { |
| 693 first_pos_ = nullptr; | 685 first_pos_ = nullptr; |
| 694 } | 686 } |
| 695 result->first_pos_ = use_after; | 687 result->first_pos_ = use_after; |
| 696 | 688 |
| 697 // Discard cached iteration state. It might be pointing | 689 // Discard cached iteration state. It might be pointing |
| 698 // to the use that no longer belongs to this live range. | 690 // to the use that no longer belongs to this live range. |
| 699 last_processed_use_ = nullptr; | 691 last_processed_use_ = nullptr; |
| 700 current_interval_ = nullptr; | 692 current_interval_ = nullptr; |
| 701 | 693 |
| 702 // Invalidate size and weight of this range. The child range has them | |
| 703 // invalid at construction. | |
| 704 size_ = kInvalidSize; | |
| 705 weight_ = kInvalidWeight; | |
| 706 #ifdef DEBUG | 694 #ifdef DEBUG |
| 707 VerifyChildStructure(); | 695 VerifyChildStructure(); |
| 708 result->VerifyChildStructure(); | 696 result->VerifyChildStructure(); |
| 709 #endif | 697 #endif |
| 710 return use_before; | 698 return use_before; |
| 711 } | 699 } |
| 712 | 700 |
| 713 | 701 |
| 714 void LiveRange::UpdateParentForAllChildren(TopLevelLiveRange* new_top_level) { | 702 void LiveRange::UpdateParentForAllChildren(TopLevelLiveRange* new_top_level) { |
| 715 LiveRange* child = this; | 703 LiveRange* child = this; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 a = a->next(); | 799 a = a->next(); |
| 812 if (a == nullptr || a->start() > other->End()) break; | 800 if (a == nullptr || a->start() > other->End()) break; |
| 813 AdvanceLastProcessedMarker(a, advance_last_processed_up_to); | 801 AdvanceLastProcessedMarker(a, advance_last_processed_up_to); |
| 814 } else { | 802 } else { |
| 815 b = b->next(); | 803 b = b->next(); |
| 816 } | 804 } |
| 817 } | 805 } |
| 818 return LifetimePosition::Invalid(); | 806 return LifetimePosition::Invalid(); |
| 819 } | 807 } |
| 820 | 808 |
| 821 | |
| 822 unsigned LiveRange::GetSize() { | |
| 823 if (size_ == kInvalidSize) { | |
| 824 size_ = 0; | |
| 825 for (const UseInterval* interval = first_interval(); interval != nullptr; | |
| 826 interval = interval->next()) { | |
| 827 size_ += (interval->end().value() - interval->start().value()); | |
| 828 } | |
| 829 } | |
| 830 | |
| 831 return static_cast<unsigned>(size_); | |
| 832 } | |
| 833 | |
| 834 | |
| 835 void LiveRange::Print(const RegisterConfiguration* config, | 809 void LiveRange::Print(const RegisterConfiguration* config, |
| 836 bool with_children) const { | 810 bool with_children) const { |
| 837 OFStream os(stdout); | 811 OFStream os(stdout); |
| 838 PrintableLiveRange wrapper; | 812 PrintableLiveRange wrapper; |
| 839 wrapper.register_configuration_ = config; | 813 wrapper.register_configuration_ = config; |
| 840 for (const LiveRange* i = this; i != nullptr; i = i->next()) { | 814 for (const LiveRange* i = this; i != nullptr; i = i->next()) { |
| 841 wrapper.range_ = i; | 815 wrapper.range_ = i; |
| 842 os << wrapper << std::endl; | 816 os << wrapper << std::endl; |
| 843 if (!with_children) break; | 817 if (!with_children) break; |
| 844 } | 818 } |
| (...skipping 2813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3658 } | 3632 } |
| 3659 } | 3633 } |
| 3660 } | 3634 } |
| 3661 } | 3635 } |
| 3662 } | 3636 } |
| 3663 | 3637 |
| 3664 | 3638 |
| 3665 } // namespace compiler | 3639 } // namespace compiler |
| 3666 } // namespace internal | 3640 } // namespace internal |
| 3667 } // namespace v8 | 3641 } // namespace v8 |
| OLD | NEW |