| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // that indicate free regions. | 186 // that indicate free regions. |
| 187 static const uint32_t kSingleFreeEncoding = 0; | 187 static const uint32_t kSingleFreeEncoding = 0; |
| 188 static const uint32_t kMultiFreeEncoding = 1; | 188 static const uint32_t kMultiFreeEncoding = 1; |
| 189 | 189 |
| 190 inline Heap* heap() const { return heap_; } | 190 inline Heap* heap() const { return heap_; } |
| 191 | 191 |
| 192 CodeFlusher* code_flusher() { return code_flusher_; } | 192 CodeFlusher* code_flusher() { return code_flusher_; } |
| 193 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } | 193 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } |
| 194 void EnableCodeFlushing(bool enable); | 194 void EnableCodeFlushing(bool enable); |
| 195 | 195 |
| 196 inline Object* encountered_weak_maps() { return encountered_weak_maps_; } |
| 197 inline void set_encountered_weak_maps(Object* weak_map) { |
| 198 encountered_weak_maps_ = weak_map; |
| 199 } |
| 200 |
| 196 private: | 201 private: |
| 197 MarkCompactCollector(); | 202 MarkCompactCollector(); |
| 198 ~MarkCompactCollector(); | 203 ~MarkCompactCollector(); |
| 199 | 204 |
| 200 #ifdef DEBUG | 205 #ifdef DEBUG |
| 201 enum CollectorState { | 206 enum CollectorState { |
| 202 IDLE, | 207 IDLE, |
| 203 PREPARE_GC, | 208 PREPARE_GC, |
| 204 MARK_LIVE_OBJECTS, | 209 MARK_LIVE_OBJECTS, |
| 205 SWEEP_SPACES, | 210 SWEEP_SPACES, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 // compacting or not, because the large object space is never compacted. | 327 // compacting or not, because the large object space is never compacted. |
| 323 void SweepLargeObjectSpace(); | 328 void SweepLargeObjectSpace(); |
| 324 | 329 |
| 325 // Test whether a (possibly marked) object is a Map. | 330 // Test whether a (possibly marked) object is a Map. |
| 326 static inline bool SafeIsMap(HeapObject* object); | 331 static inline bool SafeIsMap(HeapObject* object); |
| 327 | 332 |
| 328 // Map transitions from a live map to a dead map must be killed. | 333 // Map transitions from a live map to a dead map must be killed. |
| 329 // We replace them with a null descriptor, with the same key. | 334 // We replace them with a null descriptor, with the same key. |
| 330 void ClearNonLiveTransitions(); | 335 void ClearNonLiveTransitions(); |
| 331 | 336 |
| 337 // Mark all values associated with reachable keys in weak maps encountered |
| 338 // so far. This might push new object or even new weak maps onto the |
| 339 // marking stack. |
| 340 void ProcessWeakMaps(); |
| 341 |
| 342 // After all reachable objects have been marked those weak map entries |
| 343 // with an unreachable key are removed from all encountered weak maps. |
| 344 // The linked list of all encountered weak maps is destroyed. |
| 345 void ClearWeakMaps(); |
| 346 |
| 332 // ----------------------------------------------------------------------- | 347 // ----------------------------------------------------------------------- |
| 333 // Phase 2: Sweeping to clear mark bits and free non-live objects for | 348 // Phase 2: Sweeping to clear mark bits and free non-live objects for |
| 334 // a non-compacting collection, or else computing and encoding | 349 // a non-compacting collection, or else computing and encoding |
| 335 // forwarding addresses for a compacting collection. | 350 // forwarding addresses for a compacting collection. |
| 336 // | 351 // |
| 337 // Before: Live objects are marked and non-live objects are unmarked. | 352 // Before: Live objects are marked and non-live objects are unmarked. |
| 338 // | 353 // |
| 339 // After: (Non-compacting collection.) Live objects are unmarked, | 354 // After: (Non-compacting collection.) Live objects are unmarked, |
| 340 // non-live regions have been added to their space's free | 355 // non-live regions have been added to their space's free |
| 341 // list. | 356 // list. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 friend class MarkObjectVisitor; | 507 friend class MarkObjectVisitor; |
| 493 static void VisitObject(HeapObject* obj); | 508 static void VisitObject(HeapObject* obj); |
| 494 | 509 |
| 495 friend class UnmarkObjectVisitor; | 510 friend class UnmarkObjectVisitor; |
| 496 static void UnmarkObject(HeapObject* obj); | 511 static void UnmarkObject(HeapObject* obj); |
| 497 #endif | 512 #endif |
| 498 | 513 |
| 499 Heap* heap_; | 514 Heap* heap_; |
| 500 MarkingStack marking_stack_; | 515 MarkingStack marking_stack_; |
| 501 CodeFlusher* code_flusher_; | 516 CodeFlusher* code_flusher_; |
| 517 Object* encountered_weak_maps_; |
| 502 | 518 |
| 503 friend class Heap; | 519 friend class Heap; |
| 504 friend class OverflowedObjectsScanner; | 520 friend class OverflowedObjectsScanner; |
| 505 }; | 521 }; |
| 506 | 522 |
| 507 | 523 |
| 508 } } // namespace v8::internal | 524 } } // namespace v8::internal |
| 509 | 525 |
| 510 #endif // V8_MARK_COMPACT_H_ | 526 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |