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

Unified Diff: src/objects-inl.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 | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index b57e27bb40c6f3dfd6a07ddee6c7c087cf6aa2fe..8d6737b2eeb00e4919bf2ba50f9531beb4f340aa 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -7843,7 +7843,8 @@ Relocatable::~Relocatable() {
// static
-int JSObject::BodyDescriptor::SizeOf(Map* map, HeapObject* object) {
+template <int start_offset>
+int FlexibleBodyDescriptor<start_offset>::SizeOf(Map* map, HeapObject* object) {
return map->instance_size();
}
@@ -7854,12 +7855,6 @@ int FixedArray::BodyDescriptor::SizeOf(Map* map, HeapObject* object) {
}
-// static
-int StructBodyDescriptor::SizeOf(Map* map, HeapObject* object) {
- return map->instance_size();
-}
-
-
void Foreign::ForeignIterateBody(ObjectVisitor* v) {
v->VisitExternalReference(
reinterpret_cast<Address*>(FIELD_ADDR(this, kForeignAddressOffset)));
@@ -7916,48 +7911,54 @@ void ExternalTwoByteString::ExternalTwoByteStringIterateBody() {
}
-static inline void IterateBodyUsingLayoutDescriptor(HeapObject* object,
- int start_offset,
- int end_offset,
- ObjectVisitor* v) {
- 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; offset += kPointerSize) {
- // Visit all tagged fields.
- if (helper.IsTagged(offset)) {
- v->VisitPointer(HeapObject::RawField(object, offset));
- }
- }
-}
-
-
-template<int start_offset, int end_offset, int size>
-void FixedBodyDescriptor<start_offset, end_offset, size>::IterateBody(
- HeapObject* obj,
- ObjectVisitor* v) {
+void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset,
+ int end_offset, ObjectVisitor* v) {
if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) {
v->VisitPointers(HeapObject::RawField(obj, start_offset),
HeapObject::RawField(obj, end_offset));
} else {
- IterateBodyUsingLayoutDescriptor(obj, start_offset, end_offset, v);
+ DCHECK(FLAG_unbox_double_fields);
+ DCHECK(IsAligned(start_offset, kPointerSize) &&
+ IsAligned(end_offset, kPointerSize));
+
+ LayoutDescriptorHelper helper(obj->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)) {
+ v->VisitPointers(HeapObject::RawField(obj, offset),
+ HeapObject::RawField(obj, end_of_region_offset));
+ }
+ offset = end_of_region_offset;
+ }
}
}
-template<int start_offset>
-void FlexibleBodyDescriptor<start_offset>::IterateBody(HeapObject* obj,
- int object_size,
- ObjectVisitor* v) {
+template <typename StaticVisitor>
+void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset,
+ int end_offset) {
+ Heap* heap = obj->GetHeap();
if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) {
- v->VisitPointers(HeapObject::RawField(obj, start_offset),
- HeapObject::RawField(obj, object_size));
+ StaticVisitor::VisitPointers(heap, obj,
+ HeapObject::RawField(obj, start_offset),
+ HeapObject::RawField(obj, end_offset));
} else {
- IterateBodyUsingLayoutDescriptor(obj, start_offset, object_size, v);
+ DCHECK(FLAG_unbox_double_fields);
+ DCHECK(IsAligned(start_offset, kPointerSize) &&
+ IsAligned(end_offset, kPointerSize));
+
+ LayoutDescriptorHelper helper(obj->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)) {
+ StaticVisitor::VisitPointers(
+ heap, obj, HeapObject::RawField(obj, offset),
+ HeapObject::RawField(obj, end_of_region_offset));
+ }
+ offset = end_of_region_offset;
+ }
}
}
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698