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" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Otherwise the |full_layout_descriptor| is returned. | 63 // Otherwise the |full_layout_descriptor| is returned. |
64 static Handle<LayoutDescriptor> AppendIfFastOrUseFull( | 64 static Handle<LayoutDescriptor> AppendIfFastOrUseFull( |
65 Handle<Map> map, PropertyDetails details, | 65 Handle<Map> map, PropertyDetails details, |
66 Handle<LayoutDescriptor> full_layout_descriptor); | 66 Handle<LayoutDescriptor> full_layout_descriptor); |
67 | 67 |
68 // Layout descriptor that corresponds to an object all fields of which are | 68 // Layout descriptor that corresponds to an object all fields of which are |
69 // tagged (FastPointerLayout). | 69 // tagged (FastPointerLayout). |
70 V8_INLINE static LayoutDescriptor* FastPointerLayout(); | 70 V8_INLINE static LayoutDescriptor* FastPointerLayout(); |
71 | 71 |
72 // Check that this layout descriptor corresponds to given map. | 72 // Check that this layout descriptor corresponds to given map. |
73 bool IsConsistentWithMap(Map* map); | 73 bool IsConsistentWithMap(Map* map, bool check_tail = false); |
| 74 |
| 75 // Trims this layout descriptor to given number of descriptors. This happens |
| 76 // only when corresponding descriptors array is trimmed. |
| 77 // The layout descriptor could be trimmed if it was slow or it could |
| 78 // become fast. |
| 79 LayoutDescriptor* Trim(Heap* heap, Map* map, DescriptorArray* descriptors, |
| 80 int num_descriptors); |
74 | 81 |
75 #ifdef OBJECT_PRINT | 82 #ifdef OBJECT_PRINT |
76 // 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. |
77 void Print(); | 84 void Print(); |
78 | 85 |
79 void Print(std::ostream& os); // NOLINT | 86 void Print(std::ostream& os); // NOLINT |
80 #endif | 87 #endif |
81 | 88 |
82 // Capacity of layout descriptors in bits. | 89 // Capacity of layout descriptors in bits. |
83 V8_INLINE int capacity(); | 90 V8_INLINE int capacity(); |
84 | 91 |
85 static Handle<LayoutDescriptor> NewForTesting(Isolate* isolate, int length); | 92 static Handle<LayoutDescriptor> NewForTesting(Isolate* isolate, int length); |
86 LayoutDescriptor* SetTaggedForTesting(int field_index, bool tagged); | 93 LayoutDescriptor* SetTaggedForTesting(int field_index, bool tagged); |
87 | 94 |
88 private: | 95 private: |
89 static const int kNumberOfBits = 32; | 96 static const int kNumberOfBits = 32; |
90 | 97 |
91 V8_INLINE static Handle<LayoutDescriptor> New(Isolate* isolate, int length); | 98 V8_INLINE static Handle<LayoutDescriptor> New(Isolate* isolate, int length); |
92 V8_INLINE static LayoutDescriptor* FromSmi(Smi* smi); | 99 V8_INLINE static LayoutDescriptor* FromSmi(Smi* smi); |
93 | 100 |
94 V8_INLINE static bool InobjectUnboxedField(int inobject_properties, | 101 V8_INLINE static bool InobjectUnboxedField(int inobject_properties, |
95 PropertyDetails details); | 102 PropertyDetails details); |
96 | 103 |
| 104 // Calculates minimal layout descriptor capacity required for given |
| 105 // |map|, |descriptors| and |num_descriptors|. |
| 106 V8_INLINE static int CalculateCapacity(Map* map, DescriptorArray* descriptors, |
| 107 int num_descriptors); |
| 108 |
| 109 // Fills in clean |layout_descriptor| according to given |map|, |descriptors| |
| 110 // and |num_descriptors|. |
| 111 V8_INLINE static LayoutDescriptor* Initialize( |
| 112 LayoutDescriptor* layout_descriptor, Map* map, |
| 113 DescriptorArray* descriptors, int num_descriptors); |
| 114 |
97 static Handle<LayoutDescriptor> EnsureCapacity( | 115 static Handle<LayoutDescriptor> EnsureCapacity( |
98 Isolate* isolate, Handle<LayoutDescriptor> layout_descriptor, | 116 Isolate* isolate, Handle<LayoutDescriptor> layout_descriptor, |
99 int new_capacity); | 117 int new_capacity); |
100 | 118 |
101 // Returns false if requested field_index is out of bounds. | 119 // Returns false if requested field_index is out of bounds. |
102 V8_INLINE bool GetIndexes(int field_index, int* layout_word_index, | 120 V8_INLINE bool GetIndexes(int field_index, int* layout_word_index, |
103 int* layout_bit_index); | 121 int* layout_bit_index); |
104 | 122 |
105 V8_INLINE MUST_USE_RESULT LayoutDescriptor* SetRawData(int field_index) { | 123 V8_INLINE MUST_USE_RESULT LayoutDescriptor* SetRawData(int field_index) { |
106 return SetTagged(field_index, false); | 124 return SetTagged(field_index, false); |
(...skipping 23 matching lines...) Expand all Loading... |
130 | 148 |
131 private: | 149 private: |
132 bool all_fields_tagged_; | 150 bool all_fields_tagged_; |
133 int header_size_; | 151 int header_size_; |
134 LayoutDescriptor* layout_descriptor_; | 152 LayoutDescriptor* layout_descriptor_; |
135 }; | 153 }; |
136 } | 154 } |
137 } // namespace v8::internal | 155 } // namespace v8::internal |
138 | 156 |
139 #endif // V8_LAYOUT_DESCRIPTOR_H_ | 157 #endif // V8_LAYOUT_DESCRIPTOR_H_ |
OLD | NEW |