| 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 FixedTypedArray<Uint32ArrayTraits> { |
| 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. |
| 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|. |
| 32 // If the sequence is longer than |max_sequence_length| then |
| 33 // |out_sequence_length| is set to |max_sequence_length|. |
| 34 bool IsTagged(int field_index, int max_sequence_length, |
| 35 int* out_sequence_length); |
| 36 |
| 29 // Returns true if this is a layout of the object having only tagged fields. | 37 // Returns true if this is a layout of the object having only tagged fields. |
| 30 V8_INLINE bool IsFastPointerLayout(); | 38 V8_INLINE bool IsFastPointerLayout(); |
| 31 V8_INLINE static bool IsFastPointerLayout(Object* layout_descriptor); | 39 V8_INLINE static bool IsFastPointerLayout(Object* layout_descriptor); |
| 32 | 40 |
| 33 // Returns true if the layout descriptor is in non-Smi form. | 41 // Returns true if the layout descriptor is in non-Smi form. |
| 34 V8_INLINE bool IsSlowLayout(); | 42 V8_INLINE bool IsSlowLayout(); |
| 35 | 43 |
| 36 V8_INLINE static LayoutDescriptor* cast(Object* object); | 44 V8_INLINE static LayoutDescriptor* cast(Object* object); |
| 37 V8_INLINE static const LayoutDescriptor* cast(const Object* object); | 45 V8_INLINE static const LayoutDescriptor* cast(const Object* object); |
| 38 | 46 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 69 #ifdef OBJECT_PRINT | 77 #ifdef OBJECT_PRINT |
| 70 // For our gdb macros, we should perhaps change these in the future. | 78 // For our gdb macros, we should perhaps change these in the future. |
| 71 void Print(); | 79 void Print(); |
| 72 | 80 |
| 73 void Print(std::ostream& os); // NOLINT | 81 void Print(std::ostream& os); // NOLINT |
| 74 #endif | 82 #endif |
| 75 | 83 |
| 76 // Capacity of layout descriptors in bits. | 84 // Capacity of layout descriptors in bits. |
| 77 V8_INLINE int capacity(); | 85 V8_INLINE int capacity(); |
| 78 | 86 |
| 79 V8_INLINE LayoutDescriptor* SetTaggedForTesting(int field_index, | 87 static Handle<LayoutDescriptor> NewForTesting(Isolate* isolate, int length); |
| 80 bool tagged) { | 88 LayoutDescriptor* SetTaggedForTesting(int field_index, bool tagged); |
| 81 return SetTagged(field_index, tagged); | |
| 82 } | |
| 83 | 89 |
| 84 private: | 90 private: |
| 85 static const int kNumberOfBits = 32; | 91 static const int kNumberOfBits = 32; |
| 86 | 92 |
| 87 V8_INLINE static Handle<LayoutDescriptor> New(Isolate* isolate, int length); | 93 V8_INLINE static Handle<LayoutDescriptor> New(Isolate* isolate, int length); |
| 88 V8_INLINE static LayoutDescriptor* FromSmi(Smi* smi); | 94 V8_INLINE static LayoutDescriptor* FromSmi(Smi* smi); |
| 89 | 95 |
| 90 V8_INLINE static bool InobjectUnboxedField(int inobject_properties, | 96 V8_INLINE static bool InobjectUnboxedField(int inobject_properties, |
| 91 PropertyDetails details); | 97 PropertyDetails details); |
| 92 | 98 |
| 93 static Handle<LayoutDescriptor> EnsureCapacity( | 99 static Handle<LayoutDescriptor> EnsureCapacity( |
| 94 Isolate* isolate, Handle<LayoutDescriptor> layout_descriptor, | 100 Isolate* isolate, Handle<LayoutDescriptor> layout_descriptor, |
| 95 int new_capacity); | 101 int new_capacity); |
| 96 | 102 |
| 97 // Returns false if requested field_index is out of bounds. | 103 // Returns false if requested field_index is out of bounds. |
| 98 V8_INLINE bool GetIndexes(int field_index, int* layout_word_index, | 104 V8_INLINE bool GetIndexes(int field_index, int* layout_word_index, |
| 99 uint32_t* layout_mask); | 105 int* layout_bit_index); |
| 100 | 106 |
| 101 V8_INLINE MUST_USE_RESULT LayoutDescriptor* SetRawData(int field_index) { | 107 V8_INLINE MUST_USE_RESULT LayoutDescriptor* SetRawData(int field_index) { |
| 102 return SetTagged(field_index, false); | 108 return SetTagged(field_index, false); |
| 103 } | 109 } |
| 104 | 110 |
| 105 V8_INLINE MUST_USE_RESULT LayoutDescriptor* SetTagged(int field_index, | 111 V8_INLINE MUST_USE_RESULT LayoutDescriptor* SetTagged(int field_index, |
| 106 bool tagged); | 112 bool tagged); |
| 107 }; | 113 }; |
| 108 | 114 |
| 109 | 115 |
| 110 // InobjectPropertiesHelper is a helper class for querying layout descriptor | 116 // LayoutDescriptorHelper is a helper class for querying layout descriptor |
| 111 // about whether the field at given offset is tagged or not. | 117 // about whether the field at given offset is tagged or not. |
| 112 class InobjectPropertiesHelper { | 118 class LayoutDescriptorHelper { |
| 113 public: | 119 public: |
| 114 inline explicit InobjectPropertiesHelper(Map* map); | 120 inline explicit LayoutDescriptorHelper(Map* map); |
| 115 | 121 |
| 116 bool all_fields_tagged() { return all_fields_tagged_; } | 122 bool all_fields_tagged() { return all_fields_tagged_; } |
| 117 inline bool IsTagged(int offset_in_bytes); | 123 inline bool IsTagged(int offset_in_bytes); |
| 118 | 124 |
| 125 // Queries the contiguous region of fields that are either tagged or not. |
| 126 // Returns true if fields starting at |offset_in_bytes| are tagged or false |
| 127 // otherwise and writes the offset of the end of the contiguous region to |
| 128 // |out_end_of_contiguous_region_offset|. The |end_offset| value is the |
| 129 // upper bound for |out_end_of_contiguous_region_offset|. |
| 130 bool IsTagged(int offset_in_bytes, int end_offset, |
| 131 int* out_end_of_contiguous_region_offset); |
| 132 |
| 119 private: | 133 private: |
| 120 bool all_fields_tagged_; | 134 bool all_fields_tagged_; |
| 121 int header_size_; | 135 int header_size_; |
| 122 LayoutDescriptor* layout_descriptor_; | 136 LayoutDescriptor* layout_descriptor_; |
| 123 }; | 137 }; |
| 124 } | 138 } |
| 125 } // namespace v8::internal | 139 } // namespace v8::internal |
| 126 | 140 |
| 127 #endif // V8_LAYOUT_DESCRIPTOR_H_ | 141 #endif // V8_LAYOUT_DESCRIPTOR_H_ |
| OLD | NEW |