| 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 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_LITHIUM_ALLOCATOR_H_ | 28 #ifndef V8_LITHIUM_ALLOCATOR_H_ |
| 29 #define V8_LITHIUM_ALLOCATOR_H_ | 29 #define V8_LITHIUM_ALLOCATOR_H_ |
| 30 | 30 |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 | 32 |
| 33 #include "data-flow.h" |
| 33 #include "zone.h" | 34 #include "zone.h" |
| 34 | 35 |
| 35 namespace v8 { | 36 namespace v8 { |
| 36 namespace internal { | 37 namespace internal { |
| 37 | 38 |
| 38 // Forward declarations. | 39 // Forward declarations. |
| 39 class HBasicBlock; | 40 class HBasicBlock; |
| 40 class HGraph; | 41 class HGraph; |
| 41 class HInstruction; | 42 class HInstruction; |
| 42 class HPhi; | 43 class HPhi; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 public: | 198 public: |
| 198 enum Policy { | 199 enum Policy { |
| 199 NONE, | 200 NONE, |
| 200 ANY, | 201 ANY, |
| 201 FIXED_REGISTER, | 202 FIXED_REGISTER, |
| 202 FIXED_DOUBLE_REGISTER, | 203 FIXED_DOUBLE_REGISTER, |
| 203 FIXED_SLOT, | 204 FIXED_SLOT, |
| 204 MUST_HAVE_REGISTER, | 205 MUST_HAVE_REGISTER, |
| 205 WRITABLE_REGISTER, | 206 WRITABLE_REGISTER, |
| 206 SAME_AS_FIRST_INPUT, | 207 SAME_AS_FIRST_INPUT, |
| 207 SAME_AS_ANY_INPUT, | |
| 208 IGNORE | 208 IGNORE |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 // Lifetime of operand inside the instruction. | 211 // Lifetime of operand inside the instruction. |
| 212 enum Lifetime { | 212 enum Lifetime { |
| 213 // USED_AT_START operand is guaranteed to be live only at | 213 // USED_AT_START operand is guaranteed to be live only at |
| 214 // instruction start. Register allocator is free to assign the same register | 214 // instruction start. Register allocator is free to assign the same register |
| 215 // to some other operand used inside instruction (i.e. temporary or | 215 // to some other operand used inside instruction (i.e. temporary or |
| 216 // output). | 216 // output). |
| 217 USED_AT_START, | 217 USED_AT_START, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 bool HasFixedPolicy() const { | 269 bool HasFixedPolicy() const { |
| 270 return policy() == FIXED_REGISTER || | 270 return policy() == FIXED_REGISTER || |
| 271 policy() == FIXED_DOUBLE_REGISTER || | 271 policy() == FIXED_DOUBLE_REGISTER || |
| 272 policy() == FIXED_SLOT; | 272 policy() == FIXED_SLOT; |
| 273 } | 273 } |
| 274 bool HasRegisterPolicy() const { | 274 bool HasRegisterPolicy() const { |
| 275 return policy() == WRITABLE_REGISTER || policy() == MUST_HAVE_REGISTER; | 275 return policy() == WRITABLE_REGISTER || policy() == MUST_HAVE_REGISTER; |
| 276 } | 276 } |
| 277 bool HasSameAsInputPolicy() const { | 277 bool HasSameAsInputPolicy() const { |
| 278 return policy() == SAME_AS_FIRST_INPUT || policy() == SAME_AS_ANY_INPUT; | 278 return policy() == SAME_AS_FIRST_INPUT; |
| 279 } | 279 } |
| 280 Policy policy() const { return PolicyField::decode(value_); } | 280 Policy policy() const { return PolicyField::decode(value_); } |
| 281 void set_policy(Policy policy) { | 281 void set_policy(Policy policy) { |
| 282 value_ &= ~PolicyField::mask(); | 282 value_ &= ~PolicyField::mask(); |
| 283 value_ |= PolicyField::encode(policy); | 283 value_ |= PolicyField::encode(policy); |
| 284 } | 284 } |
| 285 int fixed_index() const { | 285 int fixed_index() const { |
| 286 return static_cast<int>(value_) >> kFixedIndexShift; | 286 return static_cast<int>(value_) >> kFixedIndexShift; |
| 287 } | 287 } |
| 288 | 288 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 LiveRange* parent_; | 747 LiveRange* parent_; |
| 748 LiveRange* next_; | 748 LiveRange* next_; |
| 749 // This is used as a cache, it doesn't affect correctness. | 749 // This is used as a cache, it doesn't affect correctness. |
| 750 mutable UseInterval* current_interval_; | 750 mutable UseInterval* current_interval_; |
| 751 UsePosition* last_processed_use_; | 751 UsePosition* last_processed_use_; |
| 752 LOperand* spill_operand_; | 752 LOperand* spill_operand_; |
| 753 int spill_start_index_; | 753 int spill_start_index_; |
| 754 }; | 754 }; |
| 755 | 755 |
| 756 | 756 |
| 757 class GrowableBitVector BASE_EMBEDDED { |
| 758 public: |
| 759 GrowableBitVector() : bits_(NULL) { } |
| 760 |
| 761 bool Contains(int value) const { |
| 762 if (!InBitsRange(value)) return false; |
| 763 return bits_->Contains(value); |
| 764 } |
| 765 |
| 766 void Add(int value) { |
| 767 EnsureCapacity(value); |
| 768 bits_->Add(value); |
| 769 } |
| 770 |
| 771 private: |
| 772 static const int kInitialLength = 1024; |
| 773 |
| 774 bool InBitsRange(int value) const { |
| 775 return bits_ != NULL && bits_->length() > value; |
| 776 } |
| 777 |
| 778 void EnsureCapacity(int value) { |
| 779 if (InBitsRange(value)) return; |
| 780 int new_length = bits_ == NULL ? kInitialLength : bits_->length(); |
| 781 while (new_length <= value) new_length *= 2; |
| 782 BitVector* new_bits = new BitVector(new_length); |
| 783 if (bits_ != NULL) new_bits->CopyFrom(*bits_); |
| 784 bits_ = new_bits; |
| 785 } |
| 786 |
| 787 BitVector* bits_; |
| 788 }; |
| 789 |
| 790 |
| 757 class LAllocator BASE_EMBEDDED { | 791 class LAllocator BASE_EMBEDDED { |
| 758 public: | 792 public: |
| 759 explicit LAllocator(int first_virtual_register, HGraph* graph) | 793 explicit LAllocator(int first_virtual_register, HGraph* graph) |
| 760 : chunk_(NULL), | 794 : chunk_(NULL), |
| 761 summaries_(0), | 795 summaries_(0), |
| 762 next_summary_(NULL), | 796 next_summary_(NULL), |
| 763 summary_stack_(2), | 797 summary_stack_(2), |
| 764 live_in_sets_(0), | 798 live_in_sets_(0), |
| 765 live_ranges_(16), | 799 live_ranges_(16), |
| 766 fixed_live_ranges_(8), | 800 fixed_live_ranges_(8), |
| 767 fixed_double_live_ranges_(8), | 801 fixed_double_live_ranges_(8), |
| 768 unhandled_live_ranges_(8), | 802 unhandled_live_ranges_(8), |
| 769 active_live_ranges_(8), | 803 active_live_ranges_(8), |
| 770 inactive_live_ranges_(8), | 804 inactive_live_ranges_(8), |
| 771 reusable_slots_(8), | 805 reusable_slots_(8), |
| 772 next_virtual_register_(first_virtual_register), | 806 next_virtual_register_(first_virtual_register), |
| 807 first_artificial_register_(first_virtual_register), |
| 773 mode_(NONE), | 808 mode_(NONE), |
| 774 num_registers_(-1), | 809 num_registers_(-1), |
| 775 graph_(graph), | 810 graph_(graph), |
| 776 has_osr_entry_(false) {} | 811 has_osr_entry_(false) {} |
| 777 | 812 |
| 778 static void Setup(); | 813 static void Setup(); |
| 779 static void TraceAlloc(const char* msg, ...); | 814 static void TraceAlloc(const char* msg, ...); |
| 780 | 815 |
| 781 // Lithium translation support. | 816 // Lithium translation support. |
| 782 // Record a use of an input operand in the current instruction. | 817 // Record a use of an input operand in the current instruction. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 // Lists of live ranges | 1000 // Lists of live ranges |
| 966 ZoneList<LiveRange*> fixed_live_ranges_; | 1001 ZoneList<LiveRange*> fixed_live_ranges_; |
| 967 ZoneList<LiveRange*> fixed_double_live_ranges_; | 1002 ZoneList<LiveRange*> fixed_double_live_ranges_; |
| 968 ZoneList<LiveRange*> unhandled_live_ranges_; | 1003 ZoneList<LiveRange*> unhandled_live_ranges_; |
| 969 ZoneList<LiveRange*> active_live_ranges_; | 1004 ZoneList<LiveRange*> active_live_ranges_; |
| 970 ZoneList<LiveRange*> inactive_live_ranges_; | 1005 ZoneList<LiveRange*> inactive_live_ranges_; |
| 971 ZoneList<LiveRange*> reusable_slots_; | 1006 ZoneList<LiveRange*> reusable_slots_; |
| 972 | 1007 |
| 973 // Next virtual register number to be assigned to temporaries. | 1008 // Next virtual register number to be assigned to temporaries. |
| 974 int next_virtual_register_; | 1009 int next_virtual_register_; |
| 1010 int first_artificial_register_; |
| 1011 GrowableBitVector double_artificial_registers_; |
| 975 | 1012 |
| 976 RegisterKind mode_; | 1013 RegisterKind mode_; |
| 977 int num_registers_; | 1014 int num_registers_; |
| 978 | 1015 |
| 979 HGraph* graph_; | 1016 HGraph* graph_; |
| 980 | 1017 |
| 981 bool has_osr_entry_; | 1018 bool has_osr_entry_; |
| 982 | 1019 |
| 983 DISALLOW_COPY_AND_ASSIGN(LAllocator); | 1020 DISALLOW_COPY_AND_ASSIGN(LAllocator); |
| 984 }; | 1021 }; |
| 985 | 1022 |
| 986 | 1023 |
| 987 } } // namespace v8::internal | 1024 } } // namespace v8::internal |
| 988 | 1025 |
| 989 #endif // V8_LITHIUM_ALLOCATOR_H_ | 1026 #endif // V8_LITHIUM_ALLOCATOR_H_ |
| OLD | NEW |