| 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 14 matching lines...) Expand all Loading... |
| 25 // Capacity of the 8-bit operand slice. | 25 // Capacity of the 8-bit operand slice. |
| 26 static const size_t k8BitCapacity = 1u << kBitsPerByte; | 26 static const size_t k8BitCapacity = 1u << kBitsPerByte; |
| 27 | 27 |
| 28 // Capacity of the 16-bit operand slice. | 28 // Capacity of the 16-bit operand slice. |
| 29 static const size_t k16BitCapacity = (1u << 2 * kBitsPerByte) - k8BitCapacity; | 29 static const size_t k16BitCapacity = (1u << 2 * kBitsPerByte) - k8BitCapacity; |
| 30 | 30 |
| 31 // Capacity of the 32-bit operand slice. | 31 // Capacity of the 32-bit operand slice. |
| 32 static const size_t k32BitCapacity = | 32 static const size_t k32BitCapacity = |
| 33 kMaxUInt32 - k16BitCapacity - k8BitCapacity + 1; | 33 kMaxUInt32 - k16BitCapacity - k8BitCapacity + 1; |
| 34 | 34 |
| 35 ConstantArrayBuilder(Isolate* isolate, Zone* zone); | 35 ConstantArrayBuilder(Zone* zone, Handle<Object> the_hole_value); |
| 36 | 36 |
| 37 // Generate a fixed array of constants based on inserted objects. | 37 // Generate a fixed array of constants based on inserted objects. |
| 38 Handle<FixedArray> ToFixedArray(); | 38 Handle<FixedArray> ToFixedArray(Isolate* isolate); |
| 39 | 39 |
| 40 // Returns the object in the constant pool array that at index | 40 // Returns the object in the constant pool array that at index |
| 41 // |index|. | 41 // |index|. |
| 42 Handle<Object> At(size_t index) const; | 42 Handle<Object> At(size_t index) const; |
| 43 | 43 |
| 44 // Returns the number of elements in the array. | 44 // Returns the number of elements in the array. |
| 45 size_t size() const; | 45 size_t size() const; |
| 46 | 46 |
| 47 // Insert an object into the constants array if it is not already | 47 // Insert an object into the constants array if it is not already |
| 48 // present. Returns the array index associated with the object. | 48 // present. Returns the array index associated with the object. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 size_t reserved_; | 98 size_t reserved_; |
| 99 OperandSize operand_size_; | 99 OperandSize operand_size_; |
| 100 ZoneVector<Handle<Object>> constants_; | 100 ZoneVector<Handle<Object>> constants_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); | 102 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 ConstantArraySlice* IndexToSlice(size_t index) const; | 105 ConstantArraySlice* IndexToSlice(size_t index) const; |
| 106 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; | 106 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; |
| 107 | 107 |
| 108 Isolate* isolate_; | 108 Handle<Object> the_hole_value() const { return the_hole_value_; } |
| 109 |
| 109 ConstantArraySlice* idx_slice_[3]; | 110 ConstantArraySlice* idx_slice_[3]; |
| 110 ZoneMap<Address, index_t> constants_map_; | 111 ZoneMap<Address, index_t> constants_map_; |
| 111 ZoneMap<Smi*, index_t> smi_map_; | 112 ZoneMap<Smi*, index_t> smi_map_; |
| 112 ZoneVector<std::pair<Smi*, index_t>> smi_pairs_; | 113 ZoneVector<std::pair<Smi*, index_t>> smi_pairs_; |
| 114 Handle<Object> the_hole_value_; |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 } // namespace interpreter | 117 } // namespace interpreter |
| 116 } // namespace internal | 118 } // namespace internal |
| 117 } // namespace v8 | 119 } // namespace v8 |
| 118 | 120 |
| 119 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ | 121 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ |
| OLD | NEW |