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_OBJECTS_BODY_DESCRIPTORS_H_ | 5 #ifndef V8_OBJECTS_BODY_DESCRIPTORS_H_ |
6 #define V8_OBJECTS_BODY_DESCRIPTORS_H_ | 6 #define V8_OBJECTS_BODY_DESCRIPTORS_H_ |
7 | 7 |
8 #include "src/objects.h" | 8 #include "src/objects.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 static const int kStartOffset = start_offset; | 75 static const int kStartOffset = start_offset; |
76 static const int kEndOffset = end_offset; | 76 static const int kEndOffset = end_offset; |
77 static const int kSize = size; | 77 static const int kSize = size; |
78 | 78 |
79 static bool IsValidSlot(HeapObject* obj, int offset) { | 79 static bool IsValidSlot(HeapObject* obj, int offset) { |
80 return offset >= kStartOffset && offset < kEndOffset; | 80 return offset >= kStartOffset && offset < kEndOffset; |
81 } | 81 } |
82 | 82 |
83 template <typename ObjectVisitor> | 83 template <typename ObjectVisitor> |
84 static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) { | 84 static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) { |
85 IterateBodyImpl(obj, start_offset, end_offset, v); | 85 IteratePointers(obj, start_offset, end_offset, v); |
86 } | 86 } |
87 | 87 |
88 template <typename ObjectVisitor> | 88 template <typename ObjectVisitor> |
89 static inline void IterateBody(HeapObject* obj, int object_size, | 89 static inline void IterateBody(HeapObject* obj, int object_size, |
90 ObjectVisitor* v) { | 90 ObjectVisitor* v) { |
91 IterateBody(obj, v); | 91 IterateBody(obj, v); |
92 } | 92 } |
93 | 93 |
94 template <typename StaticVisitor> | 94 template <typename StaticVisitor> |
95 static inline void IterateBody(HeapObject* obj) { | 95 static inline void IterateBody(HeapObject* obj) { |
96 Heap* heap = obj->GetHeap(); | 96 Heap* heap = obj->GetHeap(); |
97 IterateBodyImpl<StaticVisitor>(heap, obj, start_offset, end_offset); | 97 IteratePointers<StaticVisitor>(heap, obj, start_offset, end_offset); |
98 } | 98 } |
99 | 99 |
100 template <typename StaticVisitor> | 100 template <typename StaticVisitor> |
101 static inline void IterateBody(HeapObject* obj, int object_size) { | 101 static inline void IterateBody(HeapObject* obj, int object_size) { |
102 IterateBody(obj); | 102 IterateBody(obj); |
103 } | 103 } |
104 }; | 104 }; |
105 | 105 |
106 | 106 |
107 // This class describes a body of an object of a variable size | 107 // This class describes a body of an object of a variable size |
108 // in which all pointer fields are located in the [start_offset, object_size) | 108 // in which all pointer fields are located in the [start_offset, object_size) |
109 // interval. | 109 // interval. |
110 template <int start_offset> | 110 template <int start_offset> |
111 class FlexibleBodyDescriptor final : public BodyDescriptorBase { | 111 class FlexibleBodyDescriptor final : public BodyDescriptorBase { |
112 public: | 112 public: |
113 static const int kStartOffset = start_offset; | 113 static const int kStartOffset = start_offset; |
114 | 114 |
115 static bool IsValidSlot(HeapObject* obj, int offset) { | 115 static bool IsValidSlot(HeapObject* obj, int offset) { |
116 if (offset < kStartOffset) return false; | 116 return (offset >= kStartOffset); |
117 return IsValidSlotImpl(obj, offset); | |
118 } | 117 } |
119 | 118 |
120 template <typename ObjectVisitor> | 119 template <typename ObjectVisitor> |
121 static inline void IterateBody(HeapObject* obj, int object_size, | 120 static inline void IterateBody(HeapObject* obj, int object_size, |
122 ObjectVisitor* v) { | 121 ObjectVisitor* v) { |
123 IterateBodyImpl(obj, start_offset, object_size, v); | 122 IteratePointers(obj, start_offset, object_size, v); |
124 } | 123 } |
125 | 124 |
126 template <typename StaticVisitor> | 125 template <typename StaticVisitor> |
127 static inline void IterateBody(HeapObject* obj, int object_size) { | 126 static inline void IterateBody(HeapObject* obj, int object_size) { |
128 Heap* heap = obj->GetHeap(); | 127 Heap* heap = obj->GetHeap(); |
129 IterateBodyImpl<StaticVisitor>(heap, obj, start_offset, object_size); | 128 IteratePointers<StaticVisitor>(heap, obj, start_offset, object_size); |
130 } | 129 } |
131 | 130 |
132 static inline int SizeOf(Map* map, HeapObject* object); | 131 static inline int SizeOf(Map* map, HeapObject* object); |
133 }; | 132 }; |
134 | 133 |
135 | 134 |
136 typedef FlexibleBodyDescriptor<HeapObject::kHeaderSize> StructBodyDescriptor; | 135 typedef FlexibleBodyDescriptor<HeapObject::kHeaderSize> StructBodyDescriptor; |
137 | 136 |
138 } // namespace internal | 137 } // namespace internal |
139 } // namespace v8 | 138 } // namespace v8 |
140 | 139 |
141 #endif // V8_OBJECTS_BODY_DESCRIPTORS_H_ | 140 #endif // V8_OBJECTS_BODY_DESCRIPTORS_H_ |
OLD | NEW |