| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Tells whether global handle is weak. | 155 // Tells whether global handle is weak. |
| 156 static bool IsWeak(Object** location); | 156 static bool IsWeak(Object** location); |
| 157 | 157 |
| 158 // Process pending weak handles. | 158 // Process pending weak handles. |
| 159 // Returns true if next major GC is likely to collect more garbage. | 159 // Returns true if next major GC is likely to collect more garbage. |
| 160 bool PostGarbageCollectionProcessing(GarbageCollector collector); | 160 bool PostGarbageCollectionProcessing(GarbageCollector collector); |
| 161 | 161 |
| 162 // Iterates over all strong handles. | 162 // Iterates over all strong handles. |
| 163 void IterateStrongRoots(ObjectVisitor* v); | 163 void IterateStrongRoots(ObjectVisitor* v); |
| 164 | 164 |
| 165 // Iterates over all strong and dependent handles. | |
| 166 void IterateStrongAndDependentRoots(ObjectVisitor* v); | |
| 167 | |
| 168 // Iterates over all handles. | 165 // Iterates over all handles. |
| 169 void IterateAllRoots(ObjectVisitor* v); | 166 void IterateAllRoots(ObjectVisitor* v); |
| 170 | 167 |
| 171 // Iterates over all handles that have embedder-assigned class ID. | 168 // Iterates over all handles that have embedder-assigned class ID. |
| 172 void IterateAllRootsWithClassIds(ObjectVisitor* v); | 169 void IterateAllRootsWithClassIds(ObjectVisitor* v); |
| 173 | 170 |
| 174 // Iterates over all weak roots in heap. | 171 // Iterates over all weak roots in heap. |
| 175 void IterateWeakRoots(ObjectVisitor* v); | 172 void IterateWeakRoots(ObjectVisitor* v); |
| 176 | 173 |
| 177 // Iterates over all weak independent roots in heap. | |
| 178 void IterateWeakIndependentRoots(ObjectVisitor* v); | |
| 179 | |
| 180 // Iterates over weak roots that are bound to a given callback. | 174 // Iterates over weak roots that are bound to a given callback. |
| 181 void IterateWeakRoots(WeakReferenceGuest f, | 175 void IterateWeakRoots(WeakReferenceGuest f, |
| 182 WeakReferenceCallback callback); | 176 WeakReferenceCallback callback); |
| 183 | 177 |
| 184 // Find all weak handles satisfying the callback predicate, mark | 178 // Find all weak handles satisfying the callback predicate, mark |
| 185 // them as pending. | 179 // them as pending. |
| 186 void IdentifyWeakHandles(WeakSlotCallback f); | 180 void IdentifyWeakHandles(WeakSlotCallback f); |
| 187 | 181 |
| 188 // Find all weak independent handles satisfying the callback predicate, mark | 182 // NOTE: Three ...NewSpace... functions below are used during |
| 189 // them as pending. | 183 // scavenge collections and iterate over sets of handles that are |
| 190 void IdentifyWeakIndependentHandles(WeakSlotCallbackWithHeap f); | 184 // guaranteed to contain all handles holding new space objects (but |
| 185 // may also include old space objects). |
| 186 |
| 187 // Iterates over strong and dependent handles. See the node above. |
| 188 void IterateNewSpaceStrongAndDependentRoots(ObjectVisitor* v); |
| 189 |
| 190 // Finds weak independent handles satisfying the callback predicate |
| 191 // and marks them as pending. See the note above. |
| 192 void IdentifyNewSpaceWeakIndependentHandles(WeakSlotCallbackWithHeap f); |
| 193 |
| 194 // Iterates over weak independent handles. See the note above. |
| 195 void IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v); |
| 191 | 196 |
| 192 // Add an object group. | 197 // Add an object group. |
| 193 // Should be only used in GC callback function before a collection. | 198 // Should be only used in GC callback function before a collection. |
| 194 // All groups are destroyed after a mark-compact collection. | 199 // All groups are destroyed after a mark-compact collection. |
| 195 void AddObjectGroup(Object*** handles, | 200 void AddObjectGroup(Object*** handles, |
| 196 size_t length, | 201 size_t length, |
| 197 v8::RetainedObjectInfo* info); | 202 v8::RetainedObjectInfo* info); |
| 198 | 203 |
| 199 // Add an implicit references' group. | 204 // Add an implicit references' group. |
| 200 // Should be only used in GC callback function before a collection. | 205 // Should be only used in GC callback function before a collection. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 217 | 222 |
| 218 // Tear down the global handle structure. | 223 // Tear down the global handle structure. |
| 219 void TearDown(); | 224 void TearDown(); |
| 220 | 225 |
| 221 Isolate* isolate() { return isolate_; } | 226 Isolate* isolate() { return isolate_; } |
| 222 | 227 |
| 223 #ifdef DEBUG | 228 #ifdef DEBUG |
| 224 void PrintStats(); | 229 void PrintStats(); |
| 225 void Print(); | 230 void Print(); |
| 226 #endif | 231 #endif |
| 227 class Pool; | 232 |
| 228 private: | 233 private: |
| 229 explicit GlobalHandles(Isolate* isolate); | 234 explicit GlobalHandles(Isolate* isolate); |
| 230 | 235 |
| 231 // Internal node structure, one for each global handle. | 236 // Internal node structures. |
| 232 class Node; | 237 class Node; |
| 238 class NodeBlock; |
| 239 class NodeIterator; |
| 233 | 240 |
| 234 Isolate* isolate_; | 241 Isolate* isolate_; |
| 235 | 242 |
| 236 // Field always containing the number of weak and near-death handles. | 243 // Field always containing the number of weak and near-death handles. |
| 237 int number_of_weak_handles_; | 244 int number_of_weak_handles_; |
| 238 | 245 |
| 239 // Field always containing the number of weak and near-death handles | 246 // Field always containing the number of weak and near-death handles |
| 240 // to global objects. These objects are also included in | 247 // to global objects. These objects are also included in |
| 241 // number_of_weak_handles_. | 248 // number_of_weak_handles_. |
| 242 int number_of_global_object_weak_handles_; | 249 int number_of_global_object_weak_handles_; |
| 243 | 250 |
| 244 // Global handles are kept in a single linked list pointed to by head_. | 251 // List of all allocated node blocks. |
| 245 Node* head_; | 252 NodeBlock* first_block_; |
| 246 Node* head() { return head_; } | |
| 247 void set_head(Node* value) { head_ = value; } | |
| 248 | 253 |
| 249 // Free list for DESTROYED global handles not yet deallocated. | 254 // List of node blocks with used nodes. |
| 255 NodeBlock* first_used_block_; |
| 256 |
| 257 // Free list of nodes. |
| 250 Node* first_free_; | 258 Node* first_free_; |
| 251 Node* first_free() { return first_free_; } | |
| 252 void set_first_free(Node* value) { first_free_ = value; } | |
| 253 | 259 |
| 254 // List of deallocated nodes. | 260 // Contains all nodes holding new space objects. Note: when the list |
| 255 // Deallocated nodes form a prefix of all the nodes and | 261 // is accessed, some of the objects may have been promoted already. |
| 256 // |first_deallocated| points to last deallocated node before | 262 List<Node*> new_space_nodes_; |
| 257 // |head|. Those deallocated nodes are additionally linked | |
| 258 // by |next_free|: | |
| 259 // 1st deallocated head | |
| 260 // | | | |
| 261 // V V | |
| 262 // node node ... node node | |
| 263 // .next -> .next -> .next -> | |
| 264 // <- .next_free <- .next_free <- .next_free | |
| 265 Node* first_deallocated_; | |
| 266 Node* first_deallocated() { return first_deallocated_; } | |
| 267 void set_first_deallocated(Node* value) { | |
| 268 first_deallocated_ = value; | |
| 269 } | |
| 270 | 263 |
| 271 Pool* pool_; | |
| 272 int post_gc_processing_count_; | 264 int post_gc_processing_count_; |
| 265 |
| 273 List<ObjectGroup*> object_groups_; | 266 List<ObjectGroup*> object_groups_; |
| 274 List<ImplicitRefGroup*> implicit_ref_groups_; | 267 List<ImplicitRefGroup*> implicit_ref_groups_; |
| 275 | 268 |
| 276 friend class Isolate; | 269 friend class Isolate; |
| 277 | 270 |
| 278 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); | 271 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); |
| 279 }; | 272 }; |
| 280 | 273 |
| 281 | 274 |
| 282 } } // namespace v8::internal | 275 } } // namespace v8::internal |
| 283 | 276 |
| 284 #endif // V8_GLOBAL_HANDLES_H_ | 277 #endif // V8_GLOBAL_HANDLES_H_ |
| OLD | NEW |