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

Side by Side Diff: src/global-handles.h

Issue 6686053: Introduce one way dependencies into object grouping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Renaming Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 21 matching lines...) Expand all
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 // Structure for tracking global handles. 36 // Structure for tracking global handles.
37 // A single list keeps all the allocated global handles. 37 // A single list keeps all the allocated global handles.
38 // Destroyed handles stay in the list but is added to the free list. 38 // Destroyed handles stay in the list but is added to the free list.
39 // At GC the destroyed global handles are removed from the free list 39 // At GC the destroyed global handles are removed from the free list
40 // and deallocated. 40 // and deallocated.
41 41
42 // Callback function on handling weak global handles.
43 // typedef bool (*WeakSlotCallback)(Object** pointer);
44
45 // An object group is treated like a single JS object: if one of object in 42 // An object group is treated like a single JS object: if one of object in
46 // the group is alive, all objects in the same group are considered alive. 43 // the group is alive, all objects in the same group are considered alive.
47 // An object group is used to simulate object relationship in a DOM tree. 44 // An object group is used to simulate object relationship in a DOM tree.
48 class ObjectGroup : public Malloced { 45 class ObjectGroup : public Malloced {
49 public: 46 public:
50 ObjectGroup() : objects_(4) {} 47 ObjectGroup() : objects_(4) {}
51 ObjectGroup(size_t capacity, v8::RetainedObjectInfo* info) 48 ObjectGroup(size_t capacity, v8::RetainedObjectInfo* info)
52 : objects_(static_cast<int>(capacity)), 49 : objects_(static_cast<int>(capacity)),
53 info_(info) { } 50 info_(info) { }
54 ~ObjectGroup() { if (info_ != NULL) info_->Dispose(); } 51 ~ObjectGroup() { if (info_ != NULL) info_->Dispose(); }
55 52
56 List<Object**> objects_; 53 List<Object**> objects_;
57 v8::RetainedObjectInfo* info_; 54 v8::RetainedObjectInfo* info_;
58 55
59 private: 56 private:
60 DISALLOW_COPY_AND_ASSIGN(ObjectGroup); 57 DISALLOW_COPY_AND_ASSIGN(ObjectGroup);
61 }; 58 };
62 59
63 60
61 // An implicit references group consists of two parts: a parent object and
62 // a list of children objects. If the parent is alive, all the children
63 // are alive too.
64 class ImplicitRefGroup : public Malloced {
65 public:
66 ImplicitRefGroup() : children_(4) {}
67 ImplicitRefGroup(HeapObject* parent, size_t capacity)
68 : parent_(parent),
69 children_(static_cast<int>(capacity)) { }
70
71 HeapObject* parent_;
72 List<Object**> children_;
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(ImplicitRefGroup);
76 };
77
78
64 typedef void (*WeakReferenceGuest)(Object* object, void* parameter); 79 typedef void (*WeakReferenceGuest)(Object* object, void* parameter);
65 80
66 class GlobalHandles : public AllStatic { 81 class GlobalHandles : public AllStatic {
67 public: 82 public:
68 // Creates a new global handle that is alive until Destroy is called. 83 // Creates a new global handle that is alive until Destroy is called.
69 static Handle<Object> Create(Object* value); 84 static Handle<Object> Create(Object* value);
70 85
71 // Destroy a global handle. 86 // Destroy a global handle.
72 static void Destroy(Object** location); 87 static void Destroy(Object** location);
73 88
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 136
122 // Iterates over weak roots that are bound to a given callback. 137 // Iterates over weak roots that are bound to a given callback.
123 static void IterateWeakRoots(WeakReferenceGuest f, 138 static void IterateWeakRoots(WeakReferenceGuest f,
124 WeakReferenceCallback callback); 139 WeakReferenceCallback callback);
125 140
126 // Find all weak handles satisfying the callback predicate, mark 141 // Find all weak handles satisfying the callback predicate, mark
127 // them as pending. 142 // them as pending.
128 static void IdentifyWeakHandles(WeakSlotCallback f); 143 static void IdentifyWeakHandles(WeakSlotCallback f);
129 144
130 // Add an object group. 145 // Add an object group.
131 // Should only used in GC callback function before a collection. 146 // Should be only used in GC callback function before a collection.
132 // All groups are destroyed after a mark-compact collection. 147 // All groups are destroyed after a mark-compact collection.
133 static void AddGroup(Object*** handles, 148 static void AddObjectGroup(Object*** handles,
134 size_t length, 149 size_t length,
135 v8::RetainedObjectInfo* info); 150 v8::RetainedObjectInfo* info);
151
152 // Add an implicit references' group.
153 // Should be only used in GC callback function before a collection.
154 // All groups are destroyed after a mark-compact collection.
155 static void AddImplicitReferences(HeapObject* parent,
156 Object*** children,
157 size_t length);
136 158
137 // Returns the object groups. 159 // Returns the object groups.
138 static List<ObjectGroup*>* ObjectGroups(); 160 static List<ObjectGroup*>* ObjectGroups();
139 161
162 // Returns the implicit references' groups.
163 static List<ImplicitRefGroup*>* ImplicitRefGroups();
164
140 // Remove bags, this should only happen after GC. 165 // Remove bags, this should only happen after GC.
141 static void RemoveObjectGroups(); 166 static void RemoveObjectGroups();
167 static void RemoveImplicitRefGroups();
142 168
143 // Tear down the global handle structure. 169 // Tear down the global handle structure.
144 static void TearDown(); 170 static void TearDown();
145 171
146 #ifdef DEBUG 172 #ifdef DEBUG
147 static void PrintStats(); 173 static void PrintStats();
148 static void Print(); 174 static void Print();
149 #endif 175 #endif
150 class Pool; 176 class Pool;
151 private: 177 private:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 static Node* first_deallocated() { return first_deallocated_; } 211 static Node* first_deallocated() { return first_deallocated_; }
186 static void set_first_deallocated(Node* value) { 212 static void set_first_deallocated(Node* value) {
187 first_deallocated_ = value; 213 first_deallocated_ = value;
188 } 214 }
189 }; 215 };
190 216
191 217
192 } } // namespace v8::internal 218 } } // namespace v8::internal
193 219
194 #endif // V8_GLOBAL_HANDLES_H_ 220 #endif // V8_GLOBAL_HANDLES_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698