Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index f28cdc78e9805c7d0c27f38e920d0d8c702c923d..42d66718518279d8bf012b893e921cc44583a090 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -7912,8 +7912,7 @@ void ExternalTwoByteString::ExternalTwoByteStringIterateBody() { |
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)); |
+ IteratePointers(obj, start_offset, end_offset, v); |
} else { |
DCHECK(FLAG_unbox_double_fields); |
DCHECK(IsAligned(start_offset, kPointerSize) && |
@@ -7924,8 +7923,7 @@ void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, |
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)); |
+ IteratePointers(obj, offset, end_of_region_offset, v); |
} |
offset = end_of_region_offset; |
} |
@@ -7934,13 +7932,10 @@ void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, |
template <typename StaticVisitor> |
-void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, |
- int end_offset) { |
- Heap* heap = obj->GetHeap(); |
+void BodyDescriptorBase::IterateBodyImpl(Heap* heap, HeapObject* obj, |
+ int start_offset, int end_offset) { |
if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { |
- StaticVisitor::VisitPointers(heap, obj, |
- HeapObject::RawField(obj, start_offset), |
- HeapObject::RawField(obj, end_offset)); |
+ IteratePointers<StaticVisitor>(heap, obj, start_offset, end_offset); |
} else { |
DCHECK(FLAG_unbox_double_fields); |
DCHECK(IsAligned(start_offset, kPointerSize) && |
@@ -7951,9 +7946,7 @@ void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, |
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)); |
+ IteratePointers<StaticVisitor>(heap, obj, offset, end_of_region_offset); |
} |
offset = end_of_region_offset; |
} |
@@ -7961,6 +7954,75 @@ void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset, |
} |
+void BodyDescriptorBase::IteratePointers(HeapObject* obj, int start_offset, |
+ int end_offset, ObjectVisitor* v) { |
+ v->VisitPointers(HeapObject::RawField(obj, start_offset), |
+ HeapObject::RawField(obj, end_offset)); |
+} |
+ |
+ |
+template <typename StaticVisitor> |
+void BodyDescriptorBase::IteratePointers(Heap* heap, HeapObject* obj, |
+ int start_offset, int end_offset) { |
+ StaticVisitor::VisitPointers(heap, obj, |
+ HeapObject::RawField(obj, start_offset), |
+ HeapObject::RawField(obj, end_offset)); |
+} |
+ |
+ |
+// Iterates the function object according to the visiting policy. |
+template <JSFunction::BodyVisitingPolicy body_visiting_policy> |
+class JSFunction::BodyDescriptorImpl : public BodyDescriptorBase { |
+ public: |
+ STATIC_ASSERT(kNonWeakFieldsEndOffset == kCodeEntryOffset); |
+ STATIC_ASSERT(kCodeEntryOffset + kPointerSize == kNextFunctionLinkOffset); |
+ STATIC_ASSERT(kNextFunctionLinkOffset + kPointerSize == kSize); |
+ |
+ static inline void IterateBody(HeapObject* obj, int object_size, |
+ ObjectVisitor* v) { |
+ IteratePointers(obj, kPropertiesOffset, kNonWeakFieldsEndOffset, v); |
+ |
+ if (body_visiting_policy & kVisitCodeEntry) { |
+ v->VisitCodeEntry(obj->address() + kCodeEntryOffset); |
+ } |
+ |
+ if (body_visiting_policy & kVisitNextFunction) { |
+ IteratePointers(obj, kNextFunctionLinkOffset, kSize, v); |
+ } |
+ |
+ // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object |
+ // properties |
+ // IterateBodyImpl(obj, kSize, object_size, v); |
+ } |
+ |
+ template <typename StaticVisitor> |
+ static inline void IterateBody(HeapObject* obj, int object_size) { |
+ Heap* heap = obj->GetHeap(); |
+ IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, |
+ kNonWeakFieldsEndOffset); |
+ |
+ if (body_visiting_policy & kVisitCodeEntry) { |
+ StaticVisitor::VisitCodeEntry(heap, obj, |
+ obj->address() + kCodeEntryOffset); |
+ } |
+ |
+ if (body_visiting_policy & kVisitNextFunction) { |
+ IteratePointers<StaticVisitor>(heap, obj, kNextFunctionLinkOffset, kSize); |
+ } |
+ |
+ // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object |
+ // properties |
+ // IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); |
+ } |
+ |
+ static inline int SizeOf(Map* map, HeapObject* object) { |
+ // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object |
+ // properties |
+ return JSFunction::kSize; |
+ } |
+}; |
+ |
+ |
template<class Derived, class TableType> |
Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() { |
TableType* table(TableType::cast(this->table())); |