Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Unified Diff: src/heap/objects-visiting.h

Issue 1416243009: Move both dynamic and static object body visiting logic to BodyDescriptorBase class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
};
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698