OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_LAYOUT_DESCRIPTOR_H_ | 5 #ifndef V8_LAYOUT_DESCRIPTOR_H_ |
6 #define V8_LAYOUT_DESCRIPTOR_H_ | 6 #define V8_LAYOUT_DESCRIPTOR_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 // LayoutDescriptor is a bit vector defining which fields contain non-tagged | 15 // LayoutDescriptor is a bit vector defining which fields contain non-tagged |
16 // values. It could either be a fixed typed array (slow form) or a Smi | 16 // values. It could either be a fixed typed array (slow form) or a Smi |
17 // if the length fits (fast form). | 17 // if the length fits (fast form). |
18 // Each bit in the layout represents a FIELD. The bits are referenced by | 18 // Each bit in the layout represents a FIELD. The bits are referenced by |
19 // field_index which is a field number. If the bit is set then the corresponding | 19 // field_index which is a field number. If the bit is set then the corresponding |
20 // field contains a non-tagged value and therefore must be skipped by GC. | 20 // field contains a non-tagged value and therefore must be skipped by GC. |
21 // Otherwise the field is considered tagged. If the queried bit lays "outside" | 21 // Otherwise the field is considered tagged. If the queried bit lays "outside" |
22 // of the descriptor then the field is also considered tagged. | 22 // of the descriptor then the field is also considered tagged. |
23 // Once a layout descriptor is created it is allowed only to append properties | 23 // Once a layout descriptor is created it is allowed only to append properties |
24 // to it. | 24 // to it. |
25 class LayoutDescriptor : public FixedTypedArray<Uint32ArrayTraits> { | 25 class LayoutDescriptor : public JSTypedArray { |
26 public: | 26 public: |
27 V8_INLINE bool IsTagged(int field_index); | 27 V8_INLINE bool IsTagged(int field_index); |
28 | 28 |
29 // Queries the contiguous region of fields that are either tagged or not. | 29 // Queries the contiguous region of fields that are either tagged or not. |
30 // Returns true if the given field is tagged or false otherwise and writes | 30 // Returns true if the given field is tagged or false otherwise and writes |
31 // the length of the contiguous region to |out_sequence_length|. | 31 // the length of the contiguous region to |out_sequence_length|. |
32 // If the sequence is longer than |max_sequence_length| then | 32 // If the sequence is longer than |max_sequence_length| then |
33 // |out_sequence_length| is set to |max_sequence_length|. | 33 // |out_sequence_length| is set to |max_sequence_length|. |
34 bool IsTagged(int field_index, int max_sequence_length, | 34 bool IsTagged(int field_index, int max_sequence_length, |
35 int* out_sequence_length); | 35 int* out_sequence_length); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 #ifdef OBJECT_PRINT | 82 #ifdef OBJECT_PRINT |
83 // For our gdb macros, we should perhaps change these in the future. | 83 // For our gdb macros, we should perhaps change these in the future. |
84 void Print(); | 84 void Print(); |
85 | 85 |
86 void Print(std::ostream& os); // NOLINT | 86 void Print(std::ostream& os); // NOLINT |
87 #endif | 87 #endif |
88 | 88 |
89 // Capacity of layout descriptors in bits. | 89 // Capacity of layout descriptors in bits. |
90 V8_INLINE int capacity(); | 90 V8_INLINE int capacity(); |
91 | 91 |
| 92 V8_INLINE uint32_t get_scalar(int index); |
| 93 V8_INLINE void set(int index, uint32_t value); |
| 94 |
92 static Handle<LayoutDescriptor> NewForTesting(Isolate* isolate, int length); | 95 static Handle<LayoutDescriptor> NewForTesting(Isolate* isolate, int length); |
93 LayoutDescriptor* SetTaggedForTesting(int field_index, bool tagged); | 96 LayoutDescriptor* SetTaggedForTesting(int field_index, bool tagged); |
94 | 97 |
95 private: | 98 private: |
96 static const int kNumberOfBits = 32; | 99 static const int kNumberOfBits = 32; |
97 | 100 |
| 101 V8_INLINE FixedTypedArray<Uint32ArrayTraits>* GcSafeElements(); |
| 102 |
98 V8_INLINE static Handle<LayoutDescriptor> New(Isolate* isolate, int length); | 103 V8_INLINE static Handle<LayoutDescriptor> New(Isolate* isolate, int length); |
99 V8_INLINE static LayoutDescriptor* FromSmi(Smi* smi); | 104 V8_INLINE static LayoutDescriptor* FromSmi(Smi* smi); |
100 | 105 |
101 V8_INLINE static bool InobjectUnboxedField(int inobject_properties, | 106 V8_INLINE static bool InobjectUnboxedField(int inobject_properties, |
102 PropertyDetails details); | 107 PropertyDetails details); |
103 | 108 |
104 // Calculates minimal layout descriptor capacity required for given | 109 // Calculates minimal layout descriptor capacity required for given |
105 // |map|, |descriptors| and |num_descriptors|. | 110 // |map|, |descriptors| and |num_descriptors|. |
106 V8_INLINE static int CalculateCapacity(Map* map, DescriptorArray* descriptors, | 111 V8_INLINE static int CalculateCapacity(Map* map, DescriptorArray* descriptors, |
107 int num_descriptors); | 112 int num_descriptors); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 157 |
153 private: | 158 private: |
154 bool all_fields_tagged_; | 159 bool all_fields_tagged_; |
155 int header_size_; | 160 int header_size_; |
156 LayoutDescriptor* layout_descriptor_; | 161 LayoutDescriptor* layout_descriptor_; |
157 }; | 162 }; |
158 } | 163 } |
159 } // namespace v8::internal | 164 } // namespace v8::internal |
160 | 165 |
161 #endif // V8_LAYOUT_DESCRIPTOR_H_ | 166 #endif // V8_LAYOUT_DESCRIPTOR_H_ |
OLD | NEW |