Chromium Code Reviews| 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. | 165 // Iterates over all strong and dependent handles. |
|
antonm
2011/06/06 15:44:40
nit: comment requires an update
| |
| 166 void IterateStrongAndDependentRoots(ObjectVisitor* v); | 166 void IterateNewSpaceStrongAndDependentRoots(ObjectVisitor* v); |
| 167 | 167 |
| 168 // Iterates over all handles. | 168 // Iterates over all handles. |
| 169 void IterateAllRoots(ObjectVisitor* v); | 169 void IterateAllRoots(ObjectVisitor* v); |
| 170 | 170 |
| 171 // Iterates over all handles that have embedder-assigned class ID. | 171 // Iterates over all handles that have embedder-assigned class ID. |
| 172 void IterateAllRootsWithClassIds(ObjectVisitor* v); | 172 void IterateAllRootsWithClassIds(ObjectVisitor* v); |
| 173 | 173 |
| 174 // Iterates over all weak roots in heap. | 174 // Iterates over all weak roots in heap. |
| 175 void IterateWeakRoots(ObjectVisitor* v); | 175 void IterateWeakRoots(ObjectVisitor* v); |
| 176 | 176 |
| 177 // Iterates over all weak independent roots in heap. | 177 // Iterates over all weak independent roots in heap. |
|
antonm
2011/06/06 15:44:40
ditto
| |
| 178 void IterateWeakIndependentRoots(ObjectVisitor* v); | 178 void IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v); |
| 179 | 179 |
| 180 // Iterates over weak roots that are bound to a given callback. | 180 // Iterates over weak roots that are bound to a given callback. |
| 181 void IterateWeakRoots(WeakReferenceGuest f, | 181 void IterateWeakRoots(WeakReferenceGuest f, |
| 182 WeakReferenceCallback callback); | 182 WeakReferenceCallback callback); |
| 183 | 183 |
| 184 // Find all weak handles satisfying the callback predicate, mark | 184 // Find all weak handles satisfying the callback predicate, mark |
| 185 // them as pending. | 185 // them as pending. |
| 186 void IdentifyWeakHandles(WeakSlotCallback f); | 186 void IdentifyWeakHandles(WeakSlotCallback f); |
| 187 | 187 |
| 188 // Find all weak independent handles satisfying the callback predicate, mark | 188 // Find all weak independent handles satisfying the callback predicate, mark |
| 189 // them as pending. | 189 // them as pending. |
| 190 void IdentifyWeakIndependentHandles(WeakSlotCallbackWithHeap f); | 190 void IdentifyNewSpaceWeakIndependentHandles(WeakSlotCallbackWithHeap f); |
| 191 | 191 |
| 192 // Add an object group. | 192 // Add an object group. |
| 193 // Should be only used in GC callback function before a collection. | 193 // Should be only used in GC callback function before a collection. |
| 194 // All groups are destroyed after a mark-compact collection. | 194 // All groups are destroyed after a mark-compact collection. |
| 195 void AddObjectGroup(Object*** handles, | 195 void AddObjectGroup(Object*** handles, |
| 196 size_t length, | 196 size_t length, |
| 197 v8::RetainedObjectInfo* info); | 197 v8::RetainedObjectInfo* info); |
| 198 | 198 |
| 199 // Add an implicit references' group. | 199 // Add an implicit references' group. |
| 200 // Should be only used in GC callback function before a collection. | 200 // Should be only used in GC callback function before a collection. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 217 | 217 |
| 218 // Tear down the global handle structure. | 218 // Tear down the global handle structure. |
| 219 void TearDown(); | 219 void TearDown(); |
| 220 | 220 |
| 221 Isolate* isolate() { return isolate_; } | 221 Isolate* isolate() { return isolate_; } |
| 222 | 222 |
| 223 #ifdef DEBUG | 223 #ifdef DEBUG |
| 224 void PrintStats(); | 224 void PrintStats(); |
| 225 void Print(); | 225 void Print(); |
| 226 #endif | 226 #endif |
| 227 class Pool; | 227 |
| 228 private: | 228 private: |
| 229 explicit GlobalHandles(Isolate* isolate); | 229 explicit GlobalHandles(Isolate* isolate); |
| 230 | 230 |
| 231 // Internal node structure, one for each global handle. | 231 // Internal node structures. |
| 232 class Node; | 232 class Node; |
| 233 class NodeBlock; | |
| 234 class NodeIterator; | |
| 233 | 235 |
| 234 Isolate* isolate_; | 236 Isolate* isolate_; |
| 235 | 237 |
| 236 // Field always containing the number of weak and near-death handles. | 238 // Field always containing the number of weak and near-death handles. |
| 237 int number_of_weak_handles_; | 239 int number_of_weak_handles_; |
| 238 | 240 |
| 239 // Field always containing the number of weak and near-death handles | 241 // Field always containing the number of weak and near-death handles |
| 240 // to global objects. These objects are also included in | 242 // to global objects. These objects are also included in |
| 241 // number_of_weak_handles_. | 243 // number_of_weak_handles_. |
| 242 int number_of_global_object_weak_handles_; | 244 int number_of_global_object_weak_handles_; |
| 243 | 245 |
| 244 // Global handles are kept in a single linked list pointed to by head_. | 246 // List of all allocated node blocks. |
| 245 Node* head_; | 247 NodeBlock* first_block_; |
| 246 Node* head() { return head_; } | |
| 247 void set_head(Node* value) { head_ = value; } | |
| 248 | 248 |
| 249 // Free list for DESTROYED global handles not yet deallocated. | 249 // List of node blocks with used nodes. |
| 250 NodeBlock* first_used_block_; | |
| 251 | |
| 252 // Free list of nodes. | |
| 250 Node* first_free_; | 253 Node* first_free_; |
| 251 Node* first_free() { return first_free_; } | |
| 252 void set_first_free(Node* value) { first_free_ = value; } | |
| 253 | 254 |
| 254 // List of deallocated nodes. | 255 // Contains all nodes holding new space objects. Note: when the list |
| 255 // Deallocated nodes form a prefix of all the nodes and | 256 // is accessed, some of the objects may have been promoted already. |
| 256 // |first_deallocated| points to last deallocated node before | 257 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 | 258 |
| 271 Pool* pool_; | |
| 272 int post_gc_processing_count_; | 259 int post_gc_processing_count_; |
| 260 | |
| 273 List<ObjectGroup*> object_groups_; | 261 List<ObjectGroup*> object_groups_; |
| 274 List<ImplicitRefGroup*> implicit_ref_groups_; | 262 List<ImplicitRefGroup*> implicit_ref_groups_; |
| 275 | 263 |
| 276 friend class Isolate; | 264 friend class Isolate; |
| 277 | 265 |
| 278 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); | 266 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); |
| 279 }; | 267 }; |
| 280 | 268 |
| 281 | 269 |
| 282 } } // namespace v8::internal | 270 } } // namespace v8::internal |
| 283 | 271 |
| 284 #endif // V8_GLOBAL_HANDLES_H_ | 272 #endif // V8_GLOBAL_HANDLES_H_ |
| OLD | NEW |