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" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 class Factory; | |
16 class Isolate; | 15 class Isolate; |
17 | 16 |
18 namespace interpreter { | 17 namespace interpreter { |
19 | 18 |
20 // A helper class for constructing constant arrays for the interpreter. | 19 // A helper class for constructing constant arrays for the interpreter. |
21 class ConstantArrayBuilder final : public ZoneObject { | 20 class ConstantArrayBuilder final : public ZoneObject { |
22 public: | 21 public: |
23 // Capacity of the 8-bit operand slice. | 22 // Capacity of the 8-bit operand slice. |
24 static const size_t kLowCapacity = 1u << kBitsPerByte; | 23 static const size_t kLowCapacity = 1u << kBitsPerByte; |
25 | 24 |
26 // Capacity of the combined 8-bit and 16-bit operand slices. | 25 // Capacity of the combined 8-bit and 16-bit operand slices. |
27 static const size_t kMaxCapacity = 1u << (2 * kBitsPerByte); | 26 static const size_t kMaxCapacity = 1u << (2 * kBitsPerByte); |
28 | 27 |
29 // Capacity of the 16-bit operand slice. | 28 // Capacity of the 16-bit operand slice. |
30 static const size_t kHighCapacity = kMaxCapacity - kLowCapacity; | 29 static const size_t kHighCapacity = kMaxCapacity - kLowCapacity; |
31 | 30 |
32 ConstantArrayBuilder(Isolate* isolate, Zone* zone); | 31 ConstantArrayBuilder(Isolate* isolate, Zone* zone); |
33 | 32 |
34 // Generate a fixed array of constants based on inserted objects. | 33 // Generate a fixed array of constants based on inserted objects. |
35 Handle<FixedArray> ToFixedArray(Factory* factory) const; | 34 Handle<FixedArray> ToFixedArray() const; |
36 | 35 |
37 // Returns the object in the constant pool array that at index | 36 // Returns the object in the constant pool array that at index |
38 // |index|. | 37 // |index|. |
39 Handle<Object> At(size_t index) const; | 38 Handle<Object> At(size_t index) const; |
40 | 39 |
41 // Returns the number of elements in the array. | 40 // Returns the number of elements in the array. |
42 size_t size() const; | 41 size_t size() const; |
43 | 42 |
44 // Insert an object into the constants array if it is not already | 43 // Insert an object into the constants array if it is not already |
45 // present. Returns the array index associated with the object. | 44 // present. Returns the array index associated with the object. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 ConstantArraySlice idx8_slice_; | 87 ConstantArraySlice idx8_slice_; |
89 ConstantArraySlice idx16_slice_; | 88 ConstantArraySlice idx16_slice_; |
90 IdentityMap<index_t> constants_map_; | 89 IdentityMap<index_t> constants_map_; |
91 }; | 90 }; |
92 | 91 |
93 } // namespace interpreter | 92 } // namespace interpreter |
94 } // namespace internal | 93 } // namespace internal |
95 } // namespace v8 | 94 } // namespace v8 |
96 | 95 |
97 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ | 96 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ |
OLD | NEW |