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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 LiveRange* parent_; | 748 LiveRange* parent_; |
748 LiveRange* next_; | 749 LiveRange* next_; |
749 // This is used as a cache, it doesn't affect correctness. | 750 // This is used as a cache, it doesn't affect correctness. |
750 mutable UseInterval* current_interval_; | 751 mutable UseInterval* current_interval_; |
751 UsePosition* last_processed_use_; | 752 UsePosition* last_processed_use_; |
752 LOperand* spill_operand_; | 753 LOperand* spill_operand_; |
753 int spill_start_index_; | 754 int spill_start_index_; |
754 }; | 755 }; |
755 | 756 |
756 | 757 |
758 class FlexibleBitVector BASE_EMBEDDED { | |
Kevin Millikin (Chromium)
2011/01/03 16:44:46
Maybe GrowableBitVector is more descriptive? It n
| |
759 public: | |
760 FlexibleBitVector() : bits_(NULL) { } | |
761 | |
762 bool Contains(int value) const { | |
Kevin Millikin (Chromium)
2011/01/03 16:44:46
Maybe it's too cute, but you could make this class
| |
763 if (!InBitsRange(value)) return false; | |
764 return bits_->Contains(value); | |
765 } | |
766 | |
767 void Add(int value) { | |
768 EnsureCapacity(value); | |
769 bits_->Add(value); | |
770 } | |
771 | |
772 private: | |
773 static const int kInitialLength = 1024; | |
Kevin Millikin (Chromium)
2011/01/03 16:44:46
This seems like a big initial length.
| |
774 | |
775 bool InBitsRange(int value) const { | |
776 return bits_ != NULL && bits_->length() > value; | |
777 } | |
778 | |
779 void EnsureCapacity(int value) { | |
780 if (InBitsRange(value)) return; | |
781 int new_length = bits_ == NULL ? kInitialLength : bits_->length(); | |
782 while (new_length <= value) new_length *= 2; | |
783 BitVector* new_bits = new BitVector(new_length); | |
784 if (bits_ != NULL) new_bits->CopyFrom(*bits_); | |
785 bits_ = new_bits; | |
786 } | |
787 | |
788 BitVector* bits_; | |
789 }; | |
790 | |
791 | |
757 class LAllocator BASE_EMBEDDED { | 792 class LAllocator BASE_EMBEDDED { |
758 public: | 793 public: |
759 explicit LAllocator(int first_virtual_register, HGraph* graph) | 794 explicit LAllocator(int first_virtual_register, HGraph* graph) |
760 : chunk_(NULL), | 795 : chunk_(NULL), |
761 summaries_(0), | 796 summaries_(0), |
762 next_summary_(NULL), | 797 next_summary_(NULL), |
763 summary_stack_(2), | 798 summary_stack_(2), |
764 live_in_sets_(0), | 799 live_in_sets_(0), |
765 live_ranges_(16), | 800 live_ranges_(16), |
766 fixed_live_ranges_(8), | 801 fixed_live_ranges_(8), |
(...skipping 198 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_; | |
Kevin Millikin (Chromium)
2011/01/03 16:44:46
I'd be more comfortable with an initial value, eve
| |
1011 FlexibleBitVector 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 |