Index: src/heap/objects-visiting.h |
diff --git a/src/heap/objects-visiting.h b/src/heap/objects-visiting.h |
index e9cd16c0a33591f030fc8f4a1d72dacc09706d8d..95cc80753a9daef391ec8d36211a13e81d751240 100644 |
--- a/src/heap/objects-visiting.h |
+++ b/src/heap/objects-visiting.h |
@@ -188,79 +188,34 @@ class VisitorDispatchTable { |
}; |
-template <typename StaticVisitor> |
-class BodyVisitorBase : public AllStatic { |
- public: |
- INLINE(static void IteratePointers(Heap* heap, HeapObject* object, |
- int start_offset, int end_offset)) { |
- DCHECK(!FLAG_unbox_double_fields || object->map()->HasFastPointerLayout()); |
- IterateRawPointers(heap, object, start_offset, end_offset); |
- } |
- |
- INLINE(static void IterateBody(Heap* heap, HeapObject* object, |
- int start_offset, int end_offset)) { |
- if (!FLAG_unbox_double_fields || object->map()->HasFastPointerLayout()) { |
- IterateRawPointers(heap, object, start_offset, end_offset); |
- } else { |
- IterateBodyUsingLayoutDescriptor(heap, object, start_offset, end_offset); |
- } |
- } |
- |
- private: |
- INLINE(static void IterateRawPointers(Heap* heap, HeapObject* object, |
- int start_offset, int end_offset)) { |
- StaticVisitor::VisitPointers(heap, object, |
- HeapObject::RawField(object, start_offset), |
- HeapObject::RawField(object, end_offset)); |
- } |
- |
- static void IterateBodyUsingLayoutDescriptor(Heap* heap, HeapObject* object, |
- int start_offset, |
- int end_offset) { |
- DCHECK(FLAG_unbox_double_fields); |
- DCHECK(IsAligned(start_offset, kPointerSize) && |
- IsAligned(end_offset, kPointerSize)); |
- |
- LayoutDescriptorHelper helper(object->map()); |
- DCHECK(!helper.all_fields_tagged()); |
- for (int offset = start_offset; offset < end_offset;) { |
- int end_of_region_offset; |
- if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { |
- IterateRawPointers(heap, object, offset, end_of_region_offset); |
- } |
- offset = end_of_region_offset; |
- } |
- } |
-}; |
- |
- |
template <typename StaticVisitor, typename BodyDescriptor, typename ReturnType> |
-class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> { |
+class FlexibleBodyVisitor : public AllStatic { |
public: |
INLINE(static ReturnType Visit(Map* map, HeapObject* object)) { |
int object_size = BodyDescriptor::SizeOf(map, object); |
- BodyVisitorBase<StaticVisitor>::IterateBody( |
- map->GetHeap(), object, BodyDescriptor::kStartOffset, object_size); |
+ BodyDescriptor::template IterateBody<StaticVisitor>(object, object_size); |
return static_cast<ReturnType>(object_size); |
} |
+ // This specialization is only suitable for objects containing pointer fields. |
template <int object_size> |
static inline ReturnType VisitSpecialized(Map* map, HeapObject* object) { |
DCHECK(BodyDescriptor::SizeOf(map, object) == object_size); |
- BodyVisitorBase<StaticVisitor>::IteratePointers( |
- map->GetHeap(), object, BodyDescriptor::kStartOffset, object_size); |
+ DCHECK(!FLAG_unbox_double_fields || map->HasFastPointerLayout()); |
+ StaticVisitor::VisitPointers( |
+ object->GetHeap(), object, |
+ HeapObject::RawField(object, BodyDescriptor::kStartOffset), |
+ HeapObject::RawField(object, object_size)); |
return static_cast<ReturnType>(object_size); |
} |
}; |
template <typename StaticVisitor, typename BodyDescriptor, typename ReturnType> |
-class FixedBodyVisitor : public BodyVisitorBase<StaticVisitor> { |
+class FixedBodyVisitor : public AllStatic { |
public: |
INLINE(static ReturnType Visit(Map* map, HeapObject* object)) { |
- BodyVisitorBase<StaticVisitor>::IterateBody(map->GetHeap(), object, |
- BodyDescriptor::kStartOffset, |
- BodyDescriptor::kEndOffset); |
+ BodyDescriptor::template IterateBody<StaticVisitor>(object); |
return static_cast<ReturnType>(BodyDescriptor::kSize); |
} |
}; |