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

Unified Diff: src/objects.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-inl.h ('k') | src/objects.cc » ('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 682715cb52026b4ddf77e856ef7a0282d88df053..af44af2b11ce21af6228123c05b29be50418f194 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1644,8 +1644,15 @@ class BodyDescriptorBase {
int end_offset, ObjectVisitor* v);
template <typename StaticVisitor>
- static inline void IterateBodyImpl(HeapObject* obj, int start_offset,
- int end_offset);
+ static inline void IterateBodyImpl(Heap* heap, HeapObject* obj,
+ int start_offset, int end_offset);
+
+ static inline void IteratePointers(HeapObject* obj, int start_offset,
+ int end_offset, ObjectVisitor* v);
+
+ template <typename StaticVisitor>
+ static inline void IteratePointers(Heap* heap, HeapObject* obj,
+ int start_offset, int end_offset);
};
@@ -1665,7 +1672,8 @@ class FixedBodyDescriptor : public BodyDescriptorBase {
template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj) {
- IterateBodyImpl<StaticVisitor>(obj, start_offset, end_offset);
+ Heap* heap = obj->GetHeap();
+ IterateBodyImpl<StaticVisitor>(heap, obj, start_offset, end_offset);
}
};
@@ -1685,7 +1693,8 @@ class FlexibleBodyDescriptorBase : public BodyDescriptorBase {
template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj, int object_size) {
- IterateBodyImpl<StaticVisitor>(obj, start_offset, object_size);
+ Heap* heap = obj->GetHeap();
+ IterateBodyImpl<StaticVisitor>(heap, obj, start_offset, object_size);
}
};
@@ -7399,9 +7408,26 @@ class JSFunction: public JSObject {
int* instance_size,
int* in_object_properties);
- // Iterates the objects, including code objects indirectly referenced
- // through pointers to the first instruction in the code object.
- void JSFunctionIterateBody(int object_size, ObjectVisitor* v);
+ // Visiting policy flags define whether the code entry or next function
+ // should be visited or not.
+ enum BodyVisitingPolicy {
+ kVisitCodeEntry = 1 << 0,
+ kVisitNextFunction = 1 << 1,
+
+ kSkipCodeEntryAndNextFunction = 0,
+ kVisitCodeEntryAndNextFunction = kVisitCodeEntry | kVisitNextFunction
+ };
+ // Iterates the function object according to the visiting policy.
+ template <BodyVisitingPolicy>
+ class BodyDescriptorImpl;
+
+ // Visit the whole object.
+ typedef BodyDescriptorImpl<kVisitCodeEntryAndNextFunction> BodyDescriptor;
+
+ // Don't visit next function.
+ typedef BodyDescriptorImpl<kVisitCodeEntry> BodyDescriptorStrongCode;
+ typedef BodyDescriptorImpl<kSkipCodeEntryAndNextFunction>
+ BodyDescriptorWeakCode;
// Dispatched behavior.
DECLARE_PRINTER(JSFunction)
@@ -7419,15 +7445,14 @@ class JSFunction: public JSObject {
// Layout descriptors. The last property (from kNonWeakFieldsEndOffset to
// kSize) is weak and has special handling during garbage collection.
- static const int kCodeEntryOffset = JSObject::kHeaderSize;
- static const int kPrototypeOrInitialMapOffset =
- kCodeEntryOffset + kPointerSize;
+ static const int kPrototypeOrInitialMapOffset = JSObject::kHeaderSize;
static const int kSharedFunctionInfoOffset =
kPrototypeOrInitialMapOffset + kPointerSize;
static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize;
static const int kLiteralsOffset = kContextOffset + kPointerSize;
static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize;
- static const int kNextFunctionLinkOffset = kNonWeakFieldsEndOffset;
+ static const int kCodeEntryOffset = kNonWeakFieldsEndOffset;
+ static const int kNextFunctionLinkOffset = kCodeEntryOffset + kPointerSize;
static const int kSize = kNextFunctionLinkOffset + kPointerSize;
private:
« no previous file with comments | « src/heap/objects-visiting-inl.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698