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

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

Issue 1422773007: Make JSFunction::BodyDescriptor the only single place that knows how to iterate JSFunction's body. (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/heap/objects-visiting.cc ('k') | 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-inl.h
diff --git a/src/heap/objects-visiting-inl.h b/src/heap/objects-visiting-inl.h
index 86f6d01940a0c7b9126e439a8b1392ca71ae51da..c4ce232c6024e3272093c6d67fa4bd7637e8090c 100644
--- a/src/heap/objects-visiting-inl.h
+++ b/src/heap/objects-visiting-inl.h
@@ -63,7 +63,11 @@ void StaticNewSpaceVisitor<StaticVisitor>::Initialize() {
table_.Register(kVisitSeqTwoByteString, &VisitSeqTwoByteString);
- table_.Register(kVisitJSFunction, &VisitJSFunction);
+ // Don't visit code entry. We are using this visitor only during scavenges.
+ table_.Register(
+ kVisitJSFunction,
+ &FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode,
+ int>::Visit);
table_.Register(kVisitJSArrayBuffer, &VisitJSArrayBuffer);
@@ -507,7 +511,7 @@ void StaticMarkingVisitor<StaticVisitor>::VisitJSFunction(Map* map,
VisitSharedFunctionInfoWeakCode(heap, shared);
}
// Treat the reference to the code object weakly.
- VisitJSFunctionWeakCode(heap, object);
+ VisitJSFunctionWeakCode(map, object);
return;
} else {
// Visit all unoptimized code objects to prevent flushing them.
@@ -517,7 +521,7 @@ void StaticMarkingVisitor<StaticVisitor>::VisitJSFunction(Map* map,
}
}
}
- VisitJSFunctionStrongCode(heap, object);
+ VisitJSFunctionStrongCode(map, object);
}
@@ -802,42 +806,20 @@ void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoWeakCode(
template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionStrongCode(
- Heap* heap, HeapObject* object) {
- Object** start_slot =
- HeapObject::RawField(object, JSFunction::kPropertiesOffset);
- Object** end_slot =
- HeapObject::RawField(object, JSFunction::kCodeEntryOffset);
- StaticVisitor::VisitPointers(heap, object, start_slot, end_slot);
-
- VisitCodeEntry(heap, object,
- object->address() + JSFunction::kCodeEntryOffset);
- STATIC_ASSERT(JSFunction::kCodeEntryOffset + kPointerSize ==
- JSFunction::kPrototypeOrInitialMapOffset);
-
- start_slot =
- HeapObject::RawField(object, JSFunction::kPrototypeOrInitialMapOffset);
- end_slot = HeapObject::RawField(object, JSFunction::kNonWeakFieldsEndOffset);
- StaticVisitor::VisitPointers(heap, object, start_slot, end_slot);
+ Map* map, HeapObject* object) {
+ typedef FlexibleBodyVisitor<StaticVisitor,
+ JSFunction::BodyDescriptorStrongCode,
+ void> JSFunctionStrongCodeBodyVisitor;
+ JSFunctionStrongCodeBodyVisitor::Visit(map, object);
}
template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionWeakCode(
- Heap* heap, HeapObject* object) {
- Object** start_slot =
- HeapObject::RawField(object, JSFunction::kPropertiesOffset);
- Object** end_slot =
- HeapObject::RawField(object, JSFunction::kCodeEntryOffset);
- StaticVisitor::VisitPointers(heap, object, start_slot, end_slot);
-
- // Skip visiting kCodeEntryOffset as it is treated weakly here.
- STATIC_ASSERT(JSFunction::kCodeEntryOffset + kPointerSize ==
- JSFunction::kPrototypeOrInitialMapOffset);
-
- start_slot =
- HeapObject::RawField(object, JSFunction::kPrototypeOrInitialMapOffset);
- end_slot = HeapObject::RawField(object, JSFunction::kNonWeakFieldsEndOffset);
- StaticVisitor::VisitPointers(heap, object, start_slot, end_slot);
+ Map* map, HeapObject* object) {
+ typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode,
+ void> JSFunctionWeakCodeBodyVisitor;
+ JSFunctionWeakCodeBodyVisitor::Visit(map, object);
}
« no previous file with comments | « src/heap/objects-visiting.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698