Chromium Code Reviews| 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/inline-hash-map.h" | |
| 9 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
| 10 #include "src/zone-containers.h" | 11 #include "src/zone-containers.h" |
| 11 | 12 |
| 12 namespace v8 { | 13 namespace v8 { |
| 13 namespace internal { | 14 namespace internal { |
| 14 | 15 |
| 15 class Isolate; | 16 class Isolate; |
| 16 | 17 |
| 17 namespace interpreter { | 18 namespace interpreter { |
| 18 | 19 |
| 20 // Hashing function specifically for addresses | |
| 21 struct AddressHash { | |
| 22 size_t operator()(Address address) const { | |
| 23 // Divide by 8, then knuth multiplicative hash | |
|
rmcilroy
2016/09/12 14:17:31
Should we divide 8 or by kPointerSize?
| |
| 24 return (bit_cast<size_t>(address) >> 3) * 2654435761; | |
| 25 } | |
| 26 }; | |
| 27 | |
| 19 // A helper class for constructing constant arrays for the | 28 // A helper class for constructing constant arrays for the |
| 20 // interpreter. Each instance of this class is intended to be used to | 29 // interpreter. Each instance of this class is intended to be used to |
| 21 // generate exactly one FixedArray of constants via the ToFixedArray | 30 // generate exactly one FixedArray of constants via the ToFixedArray |
| 22 // method. | 31 // method. |
| 23 class ConstantArrayBuilder final BASE_EMBEDDED { | 32 class ConstantArrayBuilder final BASE_EMBEDDED { |
| 24 public: | 33 public: |
| 25 // Capacity of the 8-bit operand slice. | 34 // Capacity of the 8-bit operand slice. |
| 26 static const size_t k8BitCapacity = 1u << kBitsPerByte; | 35 static const size_t k8BitCapacity = 1u << kBitsPerByte; |
| 27 | 36 |
| 28 // Capacity of the 16-bit operand slice. | 37 // Capacity of the 16-bit operand slice. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 110 |
| 102 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); | 111 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); |
| 103 }; | 112 }; |
| 104 | 113 |
| 105 ConstantArraySlice* IndexToSlice(size_t index) const; | 114 ConstantArraySlice* IndexToSlice(size_t index) const; |
| 106 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; | 115 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; |
| 107 | 116 |
| 108 Handle<Object> the_hole_value() const { return the_hole_value_; } | 117 Handle<Object> the_hole_value() const { return the_hole_value_; } |
| 109 | 118 |
| 110 ConstantArraySlice* idx_slice_[3]; | 119 ConstantArraySlice* idx_slice_[3]; |
| 111 ZoneMap<Address, index_t> constants_map_; | 120 ZoneInlineHashMap<Address, index_t, AddressHash> constants_map_; |
| 112 ZoneMap<Smi*, index_t> smi_map_; | 121 ZoneMap<Smi*, index_t> smi_map_; |
| 113 ZoneVector<std::pair<Smi*, index_t>> smi_pairs_; | 122 ZoneVector<std::pair<Smi*, index_t>> smi_pairs_; |
| 114 Handle<Object> the_hole_value_; | 123 Handle<Object> the_hole_value_; |
| 115 }; | 124 }; |
| 116 | 125 |
| 117 } // namespace interpreter | 126 } // namespace interpreter |
| 118 } // namespace internal | 127 } // namespace internal |
| 119 } // namespace v8 | 128 } // namespace v8 |
| 120 | 129 |
| 121 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ | 130 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ |
| OLD | NEW |