| 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 namespace v8 { | 33 namespace v8 { |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 // Callback function, returns whether an object is alive. The heap size | 36 // Callback function, returns whether an object is alive. The heap size |
| 37 // of the object is returned in size. It optionally updates the offset | 37 // of the object is returned in size. It optionally updates the offset |
| 38 // to the first live object in the page (only used for old and map objects). | 38 // to the first live object in the page (only used for old and map objects). |
| 39 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); | 39 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); |
| 40 | 40 |
| 41 // Forward declarations. | 41 // Forward declarations. |
| 42 class CodeFlusher; |
| 42 class GCTracer; | 43 class GCTracer; |
| 44 class MarkingVisitor; |
| 43 class RootMarkingVisitor; | 45 class RootMarkingVisitor; |
| 44 class MarkingVisitor; | |
| 45 | 46 |
| 46 | 47 |
| 47 // ---------------------------------------------------------------------------- | 48 // ---------------------------------------------------------------------------- |
| 48 // Marking stack for tracing live objects. | 49 // Marking stack for tracing live objects. |
| 49 | 50 |
| 50 class MarkingStack { | 51 class MarkingStack { |
| 51 public: | 52 public: |
| 52 MarkingStack() : low_(NULL), top_(NULL), high_(NULL), overflowed_(false) { } | 53 MarkingStack() : low_(NULL), top_(NULL), high_(NULL), overflowed_(false) { } |
| 53 | 54 |
| 54 void Initialize(Address low, Address high) { | 55 void Initialize(Address low, Address high) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // Returns size of a possibly marked object. | 184 // Returns size of a possibly marked object. |
| 184 static int SizeOfMarkedObject(HeapObject* obj); | 185 static int SizeOfMarkedObject(HeapObject* obj); |
| 185 | 186 |
| 186 // Distinguishable invalid map encodings (for single word and multiple words) | 187 // Distinguishable invalid map encodings (for single word and multiple words) |
| 187 // that indicate free regions. | 188 // that indicate free regions. |
| 188 static const uint32_t kSingleFreeEncoding = 0; | 189 static const uint32_t kSingleFreeEncoding = 0; |
| 189 static const uint32_t kMultiFreeEncoding = 1; | 190 static const uint32_t kMultiFreeEncoding = 1; |
| 190 | 191 |
| 191 inline Heap* heap() const { return heap_; } | 192 inline Heap* heap() const { return heap_; } |
| 192 | 193 |
| 194 CodeFlusher* code_flusher() { return code_flusher_; } |
| 195 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } |
| 196 void EnableCodeFlushing(bool enable); |
| 197 |
| 193 private: | 198 private: |
| 194 MarkCompactCollector(); | 199 MarkCompactCollector(); |
| 200 ~MarkCompactCollector(); |
| 195 | 201 |
| 196 #ifdef DEBUG | 202 #ifdef DEBUG |
| 197 enum CollectorState { | 203 enum CollectorState { |
| 198 IDLE, | 204 IDLE, |
| 199 PREPARE_GC, | 205 PREPARE_GC, |
| 200 MARK_LIVE_OBJECTS, | 206 MARK_LIVE_OBJECTS, |
| 201 SWEEP_SPACES, | 207 SWEEP_SPACES, |
| 202 ENCODE_FORWARDING_ADDRESSES, | 208 ENCODE_FORWARDING_ADDRESSES, |
| 203 UPDATE_POINTERS, | 209 UPDATE_POINTERS, |
| 204 RELOCATE_OBJECTS | 210 RELOCATE_OBJECTS |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 486 |
| 481 friend class MarkObjectVisitor; | 487 friend class MarkObjectVisitor; |
| 482 static void VisitObject(HeapObject* obj); | 488 static void VisitObject(HeapObject* obj); |
| 483 | 489 |
| 484 friend class UnmarkObjectVisitor; | 490 friend class UnmarkObjectVisitor; |
| 485 static void UnmarkObject(HeapObject* obj); | 491 static void UnmarkObject(HeapObject* obj); |
| 486 #endif | 492 #endif |
| 487 | 493 |
| 488 Heap* heap_; | 494 Heap* heap_; |
| 489 MarkingStack marking_stack_; | 495 MarkingStack marking_stack_; |
| 496 CodeFlusher* code_flusher_; |
| 497 |
| 490 friend class Heap; | 498 friend class Heap; |
| 491 friend class OverflowedObjectsScanner; | 499 friend class OverflowedObjectsScanner; |
| 492 }; | 500 }; |
| 493 | 501 |
| 494 | 502 |
| 495 } } // namespace v8::internal | 503 } } // namespace v8::internal |
| 496 | 504 |
| 497 #endif // V8_MARK_COMPACT_H_ | 505 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |