| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 // Type of functions to process non-live objects. | 80 // Type of functions to process non-live objects. |
| 81 typedef void (*ProcessNonLiveFunction)(HeapObject* object); | 81 typedef void (*ProcessNonLiveFunction)(HeapObject* object); |
| 82 | 82 |
| 83 // Set the global force_compaction flag, it must be called before Prepare | 83 // Set the global force_compaction flag, it must be called before Prepare |
| 84 // to take effect. | 84 // to take effect. |
| 85 static void SetForceCompaction(bool value) { | 85 static void SetForceCompaction(bool value) { |
| 86 force_compaction_ = value; | 86 force_compaction_ = value; |
| 87 } | 87 } |
| 88 | 88 |
| 89 |
| 90 static void Initialize(); |
| 91 |
| 89 // Prepares for GC by resetting relocation info in old and map spaces and | 92 // Prepares for GC by resetting relocation info in old and map spaces and |
| 90 // choosing spaces to compact. | 93 // choosing spaces to compact. |
| 91 static void Prepare(GCTracer* tracer); | 94 static void Prepare(GCTracer* tracer); |
| 92 | 95 |
| 93 // Performs a global garbage collection. | 96 // Performs a global garbage collection. |
| 94 static void CollectGarbage(); | 97 static void CollectGarbage(); |
| 95 | 98 |
| 96 // True if the last full GC performed heap compaction. | 99 // True if the last full GC performed heap compaction. |
| 97 static bool HasCompacted() { return compacting_collection_; } | 100 static bool HasCompacted() { return compacting_collection_; } |
| 98 | 101 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // | 167 // |
| 165 // Before: The heap has been prepared for garbage collection by | 168 // Before: The heap has been prepared for garbage collection by |
| 166 // MarkCompactCollector::Prepare() and is otherwise in its | 169 // MarkCompactCollector::Prepare() and is otherwise in its |
| 167 // normal state. | 170 // normal state. |
| 168 // | 171 // |
| 169 // After: Live objects are marked and non-live objects are unmarked. | 172 // After: Live objects are marked and non-live objects are unmarked. |
| 170 | 173 |
| 171 | 174 |
| 172 friend class RootMarkingVisitor; | 175 friend class RootMarkingVisitor; |
| 173 friend class MarkingVisitor; | 176 friend class MarkingVisitor; |
| 177 friend class StaticMarkingVisitor; |
| 174 | 178 |
| 175 // Marking operations for objects reachable from roots. | 179 // Marking operations for objects reachable from roots. |
| 176 static void MarkLiveObjects(); | 180 static void MarkLiveObjects(); |
| 177 | 181 |
| 178 static void MarkUnmarkedObject(HeapObject* obj); | 182 static void MarkUnmarkedObject(HeapObject* obj); |
| 179 | 183 |
| 180 static inline void MarkObject(HeapObject* obj) { | 184 static inline void MarkObject(HeapObject* obj) { |
| 181 if (!obj->IsMarked()) MarkUnmarkedObject(obj); | 185 if (!obj->IsMarked()) MarkUnmarkedObject(obj); |
| 182 } | 186 } |
| 183 | 187 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 207 // symbol table are weak. | 211 // symbol table are weak. |
| 208 static void MarkSymbolTable(); | 212 static void MarkSymbolTable(); |
| 209 | 213 |
| 210 // Mark objects in object groups that have at least one object in the | 214 // Mark objects in object groups that have at least one object in the |
| 211 // group marked. | 215 // group marked. |
| 212 static void MarkObjectGroups(); | 216 static void MarkObjectGroups(); |
| 213 | 217 |
| 214 // Mark all objects in an object group with at least one marked | 218 // Mark all objects in an object group with at least one marked |
| 215 // object, then all objects reachable from marked objects in object | 219 // object, then all objects reachable from marked objects in object |
| 216 // groups, and repeat. | 220 // groups, and repeat. |
| 217 static void ProcessObjectGroups(MarkingVisitor* visitor); | 221 static void ProcessObjectGroups(); |
| 218 | 222 |
| 219 // Mark objects reachable (transitively) from objects in the marking stack | 223 // Mark objects reachable (transitively) from objects in the marking stack |
| 220 // or overflowed in the heap. | 224 // or overflowed in the heap. |
| 221 static void ProcessMarkingStack(MarkingVisitor* visitor); | 225 static void ProcessMarkingStack(); |
| 222 | 226 |
| 223 // Mark objects reachable (transitively) from objects in the marking | 227 // Mark objects reachable (transitively) from objects in the marking |
| 224 // stack. This function empties the marking stack, but may leave | 228 // stack. This function empties the marking stack, but may leave |
| 225 // overflowed objects in the heap, in which case the marking stack's | 229 // overflowed objects in the heap, in which case the marking stack's |
| 226 // overflow flag will be set. | 230 // overflow flag will be set. |
| 227 static void EmptyMarkingStack(MarkingVisitor* visitor); | 231 static void EmptyMarkingStack(); |
| 228 | 232 |
| 229 // Refill the marking stack with overflowed objects from the heap. This | 233 // Refill the marking stack with overflowed objects from the heap. This |
| 230 // function either leaves the marking stack full or clears the overflow | 234 // function either leaves the marking stack full or clears the overflow |
| 231 // flag on the marking stack. | 235 // flag on the marking stack. |
| 232 static void RefillMarkingStack(); | 236 static void RefillMarkingStack(); |
| 233 | 237 |
| 234 // Callback function for telling whether the object *p is an unmarked | 238 // Callback function for telling whether the object *p is an unmarked |
| 235 // heap object. | 239 // heap object. |
| 236 static bool IsUnmarkedHeapObject(Object** p); | 240 static bool IsUnmarkedHeapObject(Object** p); |
| 237 | 241 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 446 |
| 443 friend class UnmarkObjectVisitor; | 447 friend class UnmarkObjectVisitor; |
| 444 static void UnmarkObject(HeapObject* obj); | 448 static void UnmarkObject(HeapObject* obj); |
| 445 #endif | 449 #endif |
| 446 }; | 450 }; |
| 447 | 451 |
| 448 | 452 |
| 449 } } // namespace v8::internal | 453 } } // namespace v8::internal |
| 450 | 454 |
| 451 #endif // V8_MARK_COMPACT_H_ | 455 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |