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

Unified Diff: src/objects.h

Issue 1441453002: Avoid manual object's body traversal in GC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 93f57333a150498810f73f264c74082e2147ff3b..0e9b1864a084a261b532699f5c21d801fa0fa6c7 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1562,6 +1562,7 @@ class HeapObject: public Object {
// first map pointer. The object type is given in the first
// parameter. This function does not access the map pointer in the
// object, and so is safe to call while the map pointer is modified.
+ void IterateBody(ObjectVisitor* v);
void IterateBody(InstanceType type, int object_size, ObjectVisitor* v);
// Returns the heap object's size in bytes
@@ -1639,19 +1640,29 @@ 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,
+ public:
+ template <typename ObjectVisitor>
+ static inline void IteratePointers(HeapObject* obj, int start_offset,
int end_offset, ObjectVisitor* v);
template <typename StaticVisitor>
- static inline void IterateBodyImpl(Heap* heap, HeapObject* obj,
+ static inline void IteratePointers(Heap* heap, HeapObject* obj,
int start_offset, int end_offset);
- static inline void IteratePointers(HeapObject* obj, int start_offset,
+ template <typename ObjectVisitor>
+ static inline void IteratePointer(HeapObject* obj, int offset,
+ ObjectVisitor* v);
+
+ template <typename StaticVisitor>
+ static inline void IteratePointer(Heap* heap, HeapObject* obj, int offset);
+
+ protected:
+ template <typename ObjectVisitor>
+ static inline void IterateBodyImpl(HeapObject* obj, int start_offset,
int end_offset, ObjectVisitor* v);
template <typename StaticVisitor>
- static inline void IteratePointers(Heap* heap, HeapObject* obj,
+ static inline void IterateBodyImpl(Heap* heap, HeapObject* obj,
int start_offset, int end_offset);
};
@@ -1666,6 +1677,7 @@ class FixedBodyDescriptor : public BodyDescriptorBase {
static const int kEndOffset = end_offset;
static const int kSize = size;
+ template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) {
IterateBodyImpl(obj, start_offset, end_offset, v);
}
@@ -1686,6 +1698,7 @@ class FlexibleBodyDescriptorBase : public BodyDescriptorBase {
public:
static const int kStartOffset = start_offset;
+ template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size,
ObjectVisitor* v) {
IterateBodyImpl(obj, start_offset, object_size, v);
@@ -4443,6 +4456,8 @@ class BytecodeArray : public FixedArrayBase {
// Maximal length of a single BytecodeArray.
static const int kMaxLength = kMaxSize - kHeaderSize;
+ class BodyDescriptor;
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray);
};
@@ -4508,11 +4523,6 @@ class FixedTypedArrayBase: public FixedArrayBase {
DECL_ACCESSORS(external_pointer, void)
// Dispatched behavior.
- inline void FixedTypedArrayBaseIterateBody(ObjectVisitor* v);
-
- template <typename StaticVisitor>
- inline void FixedTypedArrayBaseIterateBody();
-
DECLARE_CAST(FixedTypedArrayBase)
static const int kBasePointerOffset = FixedArrayBase::kHeaderSize;
@@ -4522,6 +4532,8 @@ class FixedTypedArrayBase: public FixedArrayBase {
static const int kDataOffset = kHeaderSize;
+ class BodyDescriptor;
+
inline int size();
static inline int TypedArraySize(InstanceType type, int length);
@@ -9886,6 +9898,8 @@ class JSWeakCollection: public JSObject {
static const int kNextOffset = kTableOffset + kPointerSize;
static const int kSize = kNextOffset + kPointerSize;
+ class BodyDescriptor;
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection);
};
@@ -9964,11 +9978,6 @@ class JSArrayBuffer: public JSObject {
DECLARE_VERIFIER(JSArrayBuffer)
static const int kByteLengthOffset = JSObject::kHeaderSize;
-
- // NOTE: GC will visit objects fields:
- // 1. From JSObject::BodyDescriptor::kStartOffset to kByteLengthOffset +
- // kPointerSize
- // 2. From start of the internal fields and up to the end of them
static const int kBackingStoreOffset = kByteLengthOffset + kPointerSize;
static const int kBitFieldSlot = kBackingStoreOffset + kPointerSize;
#if V8_TARGET_LITTLE_ENDIAN || !V8_HOST_ARCH_64_BIT
@@ -9981,11 +9990,9 @@ class JSArrayBuffer: public JSObject {
static const int kSizeWithInternalFields =
kSize + v8::ArrayBuffer::kInternalFieldCount * kPointerSize;
- template <typename StaticVisitor>
- static inline void JSArrayBufferIterateBody(Heap* heap, HeapObject* obj);
-
- static inline void JSArrayBufferIterateBody(HeapObject* obj,
- ObjectVisitor* v);
+ // Iterates all fields in the object including internal ones except
+ // kBackingStoreOffset and kBitFieldSlot.
+ class BodyDescriptor;
class IsExternal : public BitField<bool, 1, 1> {};
class IsNeuterable : public BitField<bool, 2, 1> {};
« src/heap/objects-visiting.h ('K') | « src/heap/store-buffer.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698