| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 // Inserts the given object into an allocated entry. | 55 // Inserts the given object into an allocated entry. |
| 56 void InsertAllocatedEntry(size_t index, Handle<Object> object); | 56 void InsertAllocatedEntry(size_t index, Handle<Object> object); |
| 57 | 57 |
| 58 // Creates a reserved entry in the constant pool and returns | 58 // Creates a reserved entry in the constant pool and returns |
| 59 // the size of the operand that'll be required to hold the entry | 59 // the size of the operand that'll be required to hold the entry |
| 60 // when committed. | 60 // when committed. |
| 61 OperandSize CreateReservedEntry(); | 61 OperandSize CreateReservedEntry(); |
| 62 | 62 |
| 63 // Commit reserved entry and returns the constant pool index for the | 63 // Commit reserved entry and returns the constant pool index for the |
| 64 // object. | 64 // SMI value. |
| 65 size_t CommitReservedEntry(OperandSize operand_size, Handle<Object> object); | 65 size_t CommitReservedEntry(OperandSize operand_size, Smi* value); |
| 66 | 66 |
| 67 // Discards constant pool reservation. | 67 // Discards constant pool reservation. |
| 68 void DiscardReservedEntry(OperandSize operand_size); | 68 void DiscardReservedEntry(OperandSize operand_size); |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 typedef uint32_t index_t; | 71 typedef uint32_t index_t; |
| 72 | 72 |
| 73 index_t AllocateEntry(Handle<Object> object); | 73 index_t AllocateEntry(Handle<Object> object); |
| 74 index_t AllocateIndex(Handle<Object> object); | 74 index_t AllocateIndex(Handle<Object> object); |
| 75 index_t AllocateReservedEntry(Smi* value); |
| 75 | 76 |
| 76 struct ConstantArraySlice final : public ZoneObject { | 77 struct ConstantArraySlice final : public ZoneObject { |
| 77 ConstantArraySlice(Zone* zone, size_t start_index, size_t capacity, | 78 ConstantArraySlice(Zone* zone, size_t start_index, size_t capacity, |
| 78 OperandSize operand_size); | 79 OperandSize operand_size); |
| 79 void Reserve(); | 80 void Reserve(); |
| 80 void Unreserve(); | 81 void Unreserve(); |
| 81 size_t Allocate(Handle<Object> object); | 82 size_t Allocate(Handle<Object> object); |
| 82 Handle<Object> At(size_t index) const; | 83 Handle<Object> At(size_t index) const; |
| 83 void InsertAt(size_t index, Handle<Object> object); | 84 void InsertAt(size_t index, Handle<Object> object); |
| 84 bool AllElementsAreUnique() const; | 85 bool AllElementsAreUnique() const; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 100 | 101 |
| 101 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); | 102 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); |
| 102 }; | 103 }; |
| 103 | 104 |
| 104 ConstantArraySlice* IndexToSlice(size_t index) const; | 105 ConstantArraySlice* IndexToSlice(size_t index) const; |
| 105 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; | 106 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; |
| 106 | 107 |
| 107 Isolate* isolate_; | 108 Isolate* isolate_; |
| 108 ConstantArraySlice* idx_slice_[3]; | 109 ConstantArraySlice* idx_slice_[3]; |
| 109 ZoneMap<Address, index_t> constants_map_; | 110 ZoneMap<Address, index_t> constants_map_; |
| 111 ZoneMap<Smi*, index_t> smi_map_; |
| 112 ZoneVector<std::pair<Smi*, index_t>> smi_pairs_; |
| 110 }; | 113 }; |
| 111 | 114 |
| 112 } // namespace interpreter | 115 } // namespace interpreter |
| 113 } // namespace internal | 116 } // namespace internal |
| 114 } // namespace v8 | 117 } // namespace v8 |
| 115 | 118 |
| 116 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ | 119 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ |
| OLD | NEW |