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

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

Issue 2808093003: [heap] Introduce HeapVisitor interface. (Closed)
Patch Set: fix compile error Created 3 years, 8 months 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
Index: src/heap/objects-visiting-inl.h
diff --git a/src/heap/objects-visiting-inl.h b/src/heap/objects-visiting-inl.h
index 2b82c6b29ef0a7f4ddf9e0fa80ce920535723c70..df3bab76a14040191a0badde93b3666489d1b451 100644
--- a/src/heap/objects-visiting-inl.h
+++ b/src/heap/objects-visiting-inl.h
@@ -50,7 +50,7 @@ void StaticNewSpaceVisitor<StaticVisitor>::Initialize() {
table_.Register(kVisitFixedDoubleArray, &VisitFixedDoubleArray);
table_.Register(
- kVisitFixedTypedArray,
+ kVisitFixedTypedArrayBase,
&FlexibleBodyVisitor<StaticVisitor, FixedTypedArrayBase::BodyDescriptor,
int>::Visit);
@@ -136,7 +136,7 @@ void StaticMarkingVisitor<StaticVisitor>::Initialize() {
table_.Register(kVisitFixedDoubleArray, &DataObjectVisitor::Visit);
table_.Register(
- kVisitFixedTypedArray,
+ kVisitFixedTypedArrayBase,
&FlexibleBodyVisitor<StaticVisitor, FixedTypedArrayBase::BodyDescriptor,
void>::Visit);
@@ -628,7 +628,6 @@ void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionStrongCode(
JSFunctionStrongCodeBodyVisitor::Visit(map, object);
}
-
template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionWeakCode(
Map* map, HeapObject* object) {
@@ -637,6 +636,105 @@ void StaticMarkingVisitor<StaticVisitor>::VisitJSFunctionWeakCode(
JSFunctionWeakCodeBodyVisitor::Visit(map, object);
}
+template <typename ResultType, typename ConcreteVisitor>
+ResultType HeapVisitor<ResultType, ConcreteVisitor>::IterateBody(
+ HeapObject* object) {
+ Map* map = object->map();
+ ConcreteVisitor* visitor = static_cast<ConcreteVisitor*>(this);
+ switch (static_cast<VisitorId>(map->visitor_id())) {
+#define CASE(type) \
+ case kVisit##type: \
+ return visitor->Visit##type(map, type::cast(object));
+ TYPED_VISITOR_ID_LIST(CASE)
+#undef CASE
+ case kVisitShortcutCandidate:
+ return visitor->VisitShortcutCandidate(map, ConsString::cast(object));
+ case kVisitNativeContext:
+ return visitor->VisitNativeContext(map, Context::cast(object));
+ case kVisitDataObject:
+ return visitor->VisitDataObject(map, HeapObject::cast(object));
+ case kVisitJSObjectFast:
+ return visitor->VisitJSObjectFast(map, JSObject::cast(object));
+ case kVisitJSApiObject:
+ return visitor->VisitJSApiObject(map, JSObject::cast(object));
+ case kVisitStruct:
+ return visitor->VisitStruct(map, HeapObject::cast(object));
+ case kVisitFreeSpace:
+ return visitor->VisitFreeSpace(map, FreeSpace::cast(object));
+ case kVisitorIdCount:
+ UNREACHABLE();
+ }
+ UNREACHABLE();
+ // Make the compiler happy.
+ return ResultType();
+}
+
+#define VISIT(type) \
+ template <typename ResultType, typename ConcreteVisitor> \
+ ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit##type( \
+ Map* map, type* object) { \
+ int size = type::BodyDescriptor::SizeOf(map, object); \
+ type::BodyDescriptor::IterateBody(object, size, \
+ static_cast<ConcreteVisitor*>(this)); \
+ return static_cast<ResultType>(size); \
+ }
+TYPED_VISITOR_ID_LIST(VISIT)
+#undef VISIT
+
+template <typename ResultType, typename ConcreteVisitor>
+ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitShortcutCandidate(
+ Map* map, ConsString* object) {
+ int size = ConsString::BodyDescriptor::SizeOf(map, object);
+ ConsString::BodyDescriptor::IterateBody(object, size,
+ static_cast<ConcreteVisitor*>(this));
+ return static_cast<ResultType>(size);
+}
+
+template <typename ResultType, typename ConcreteVisitor>
+ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitNativeContext(
+ Map* map, Context* object) {
+ int size = Context::BodyDescriptor::SizeOf(map, object);
+ Context::BodyDescriptor::IterateBody(object, size,
+ static_cast<ConcreteVisitor*>(this));
+ return static_cast<ResultType>(size);
+}
+
+template <typename ResultType, typename ConcreteVisitor>
+ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitDataObject(
+ Map* map, HeapObject* object) {
+ int size = map->instance_size();
+ return static_cast<ResultType>(size);
+}
+
+template <typename ResultType, typename ConcreteVisitor>
+ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSObjectFast(
+ Map* map, JSObject* object) {
+ int size = JSObject::FastBodyDescriptor::SizeOf(map, object);
+ JSObject::FastBodyDescriptor::IterateBody(
+ object, size, static_cast<ConcreteVisitor*>(this));
+ return static_cast<ResultType>(size);
+}
+template <typename ResultType, typename ConcreteVisitor>
+ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitJSApiObject(
+ Map* map, JSObject* object) {
+ int size = JSObject::BodyDescriptor::SizeOf(map, object);
+ JSObject::BodyDescriptor::IterateBody(object, size,
+ static_cast<ConcreteVisitor*>(this));
+ return static_cast<ResultType>(size);
+}
+template <typename ResultType, typename ConcreteVisitor>
+ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitStruct(
+ Map* map, HeapObject* object) {
+ int size = map->instance_size();
+ StructBodyDescriptor::IterateBody(object, size,
+ static_cast<ConcreteVisitor*>(this));
+ return static_cast<ResultType>(size);
+}
+template <typename ResultType, typename ConcreteVisitor>
+ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitFreeSpace(
+ Map* map, FreeSpace* object) {
+ return static_cast<ResultType>(FreeSpace::cast(object)->size());
+}
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698