| 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 JSTypedArray { | 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. | 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 | |
| 95 static Handle<LayoutDescriptor> NewForTesting(Isolate* isolate, int length); | 92 static Handle<LayoutDescriptor> NewForTesting(Isolate* isolate, int length); |
| 96 LayoutDescriptor* SetTaggedForTesting(int field_index, bool tagged); | 93 LayoutDescriptor* SetTaggedForTesting(int field_index, bool tagged); |
| 97 | 94 |
| 98 private: | 95 private: |
| 99 static const int kNumberOfBits = 32; | 96 static const int kNumberOfBits = 32; |
| 100 | 97 |
| 101 V8_INLINE static Handle<LayoutDescriptor> New(Isolate* isolate, int length); | 98 V8_INLINE static Handle<LayoutDescriptor> New(Isolate* isolate, int length); |
| 102 V8_INLINE static LayoutDescriptor* FromSmi(Smi* smi); | 99 V8_INLINE static LayoutDescriptor* FromSmi(Smi* smi); |
| 103 | 100 |
| 104 V8_INLINE static bool InobjectUnboxedField(int inobject_properties, | 101 V8_INLINE static bool InobjectUnboxedField(int inobject_properties, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 152 |
| 156 private: | 153 private: |
| 157 bool all_fields_tagged_; | 154 bool all_fields_tagged_; |
| 158 int header_size_; | 155 int header_size_; |
| 159 LayoutDescriptor* layout_descriptor_; | 156 LayoutDescriptor* layout_descriptor_; |
| 160 }; | 157 }; |
| 161 } | 158 } |
| 162 } // namespace v8::internal | 159 } // namespace v8::internal |
| 163 | 160 |
| 164 #endif // V8_LAYOUT_DESCRIPTOR_H_ | 161 #endif // V8_LAYOUT_DESCRIPTOR_H_ |
| OLD | NEW |