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

Unified Diff: src/objects.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/heap/objects-visiting.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index d5197056de2967060cea9e29518c4bf97a6f7881..b3192ccb96852103eacdb4f76127be3db7888d88 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1637,46 +1637,69 @@ class HeapObject: public Object {
};
+// This is the base class for object's body descriptors.
+class BodyDescriptorBase {
+ protected:
+ static inline void IterateBodyImpl(HeapObject* obj, int start_offset,
+ int end_offset, ObjectVisitor* v);
+
+ template <typename StaticVisitor>
+ static inline void IterateBodyImpl(HeapObject* obj, int start_offset,
+ int end_offset);
+};
+
+
// This class describes a body of an object of a fixed size
// in which all pointer fields are located in the [start_offset, end_offset)
// interval.
-template<int start_offset, int end_offset, int size>
-class FixedBodyDescriptor {
+template <int start_offset, int end_offset, int size>
+class FixedBodyDescriptor : public BodyDescriptorBase {
public:
static const int kStartOffset = start_offset;
static const int kEndOffset = end_offset;
static const int kSize = size;
- static inline void IterateBody(HeapObject* obj, ObjectVisitor* v);
+ static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) {
+ IterateBodyImpl(obj, start_offset, end_offset, v);
+ }
- template<typename StaticVisitor>
+ template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj) {
- StaticVisitor::VisitPointers(HeapObject::RawField(obj, start_offset),
- HeapObject::RawField(obj, end_offset));
+ IterateBodyImpl<StaticVisitor>(obj, start_offset, end_offset);
}
};
-// This class describes a body of an object of a variable size
+// This base class describes a body of an object of a variable size
// in which all pointer fields are located in the [start_offset, object_size)
// interval.
-template<int start_offset>
-class FlexibleBodyDescriptor {
+template <int start_offset>
+class FlexibleBodyDescriptorBase : public BodyDescriptorBase {
public:
static const int kStartOffset = start_offset;
- static inline void IterateBody(HeapObject* obj,
- int object_size,
- ObjectVisitor* v);
+ static inline void IterateBody(HeapObject* obj, int object_size,
+ ObjectVisitor* v) {
+ IterateBodyImpl(obj, start_offset, object_size, v);
+ }
- template<typename StaticVisitor>
+ template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj, int object_size) {
- StaticVisitor::VisitPointers(HeapObject::RawField(obj, start_offset),
- HeapObject::RawField(obj, object_size));
+ IterateBodyImpl<StaticVisitor>(obj, start_offset, object_size);
}
};
+// This class describes a body of an object of a variable size
+// in which all pointer fields are located in the [start_offset, object_size)
+// interval. The size of the object is taken from the map.
+template <int start_offset>
+class FlexibleBodyDescriptor : public FlexibleBodyDescriptorBase<start_offset> {
+ public:
+ static inline int SizeOf(Map* map, HeapObject* object);
+};
+
+
// The HeapNumber class describes heap allocated numbers that cannot be
// represented in a Smi (small integer)
class HeapNumber: public HeapObject {
@@ -2477,10 +2500,7 @@ class JSObject: public JSReceiver {
STATIC_ASSERT(kHeaderSize == Internals::kJSObjectHeaderSize);
- class BodyDescriptor : public FlexibleBodyDescriptor<kPropertiesOffset> {
- public:
- static inline int SizeOf(Map* map, HeapObject* object);
- };
+ typedef FlexibleBodyDescriptor<kPropertiesOffset> BodyDescriptor;
Context* GetCreationContext();
@@ -2659,7 +2679,7 @@ class FixedArray: public FixedArrayBase {
// object, the prefix of this array is sorted.
void SortPairs(FixedArray* numbers, uint32_t len);
- class BodyDescriptor : public FlexibleBodyDescriptor<kHeaderSize> {
+ class BodyDescriptor : public FlexibleBodyDescriptorBase<kHeaderSize> {
public:
static inline int SizeOf(Map* map, HeapObject* object);
};
@@ -10715,11 +10735,7 @@ class ObjectVisitor BASE_EMBEDDED {
};
-class StructBodyDescriptor : public
- FlexibleBodyDescriptor<HeapObject::kHeaderSize> {
- public:
- static inline int SizeOf(Map* map, HeapObject* object);
-};
+typedef FlexibleBodyDescriptor<HeapObject::kHeaderSize> StructBodyDescriptor;
// BooleanBit is a helper class for setting and getting a bit in an integer.
« no previous file with comments | « src/heap/objects-visiting.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698