OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ | 5 #ifndef V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ |
6 #define V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ | 6 #define V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ |
7 | 7 |
8 #include "src/identity-map.h" | 8 #include "src/identity-map.h" |
9 #include "src/interpreter/bytecodes.h" | 9 #include "src/interpreter/bytecodes.h" |
10 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 index_t AllocateIndex(Handle<Object> object); | 74 index_t AllocateIndex(Handle<Object> object); |
75 | 75 |
76 struct ConstantArraySlice final : public ZoneObject { | 76 struct ConstantArraySlice final : public ZoneObject { |
77 ConstantArraySlice(Zone* zone, size_t start_index, size_t capacity, | 77 ConstantArraySlice(Zone* zone, size_t start_index, size_t capacity, |
78 OperandSize operand_size); | 78 OperandSize operand_size); |
79 void Reserve(); | 79 void Reserve(); |
80 void Unreserve(); | 80 void Unreserve(); |
81 size_t Allocate(Handle<Object> object); | 81 size_t Allocate(Handle<Object> object); |
82 Handle<Object> At(size_t index) const; | 82 Handle<Object> At(size_t index) const; |
83 void InsertAt(size_t index, Handle<Object> object); | 83 void InsertAt(size_t index, Handle<Object> object); |
| 84 bool AllElementsAreUnique() const; |
84 | 85 |
85 inline size_t available() const { return capacity() - reserved() - size(); } | 86 inline size_t available() const { return capacity() - reserved() - size(); } |
86 inline size_t reserved() const { return reserved_; } | 87 inline size_t reserved() const { return reserved_; } |
87 inline size_t capacity() const { return capacity_; } | 88 inline size_t capacity() const { return capacity_; } |
88 inline size_t size() const { return constants_.size(); } | 89 inline size_t size() const { return constants_.size(); } |
89 inline size_t start_index() const { return start_index_; } | 90 inline size_t start_index() const { return start_index_; } |
90 inline size_t max_index() const { return start_index_ + capacity() - 1; } | 91 inline size_t max_index() const { return start_index_ + capacity() - 1; } |
91 inline OperandSize operand_size() const { return operand_size_; } | 92 inline OperandSize operand_size() const { return operand_size_; } |
92 | 93 |
93 private: | 94 private: |
94 const size_t start_index_; | 95 const size_t start_index_; |
95 const size_t capacity_; | 96 const size_t capacity_; |
96 size_t reserved_; | 97 size_t reserved_; |
97 OperandSize operand_size_; | 98 OperandSize operand_size_; |
98 ZoneVector<Handle<Object>> constants_; | 99 ZoneVector<Handle<Object>> constants_; |
99 | 100 |
100 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); | 101 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); |
101 }; | 102 }; |
102 | 103 |
103 ConstantArraySlice* IndexToSlice(size_t index) const; | 104 ConstantArraySlice* IndexToSlice(size_t index) const; |
104 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; | 105 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; |
105 | 106 |
106 IdentityMap<index_t>* constants_map() { return &constants_map_; } | |
107 | |
108 Isolate* isolate_; | 107 Isolate* isolate_; |
109 ConstantArraySlice* idx_slice_[3]; | 108 ConstantArraySlice* idx_slice_[3]; |
110 IdentityMap<index_t> constants_map_; | 109 ZoneMap<Address, index_t> constants_map_; |
111 }; | 110 }; |
112 | 111 |
113 } // namespace interpreter | 112 } // namespace interpreter |
114 } // namespace internal | 113 } // namespace internal |
115 } // namespace v8 | 114 } // namespace v8 |
116 | 115 |
117 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ | 116 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ |
OLD | NEW |