| Index: src/mark-compact.h
|
| ===================================================================
|
| --- src/mark-compact.h (revision 1168)
|
| +++ src/mark-compact.h (working copy)
|
| @@ -44,12 +44,12 @@
|
| class MarkingVisitor;
|
|
|
|
|
| -// ----------------------------------------------------------------------------
|
| +// -------------------------------------------------------------------------
|
| // Mark-Compact collector
|
| //
|
| // All methods are static.
|
|
|
| -class MarkCompactCollector : public AllStatic {
|
| +class MarkCompactCollector: public AllStatic {
|
| public:
|
| // Type of functions to compute forwarding addresses of objects in
|
| // compacted spaces. Given an object and its size, return a (non-failure)
|
| @@ -127,22 +127,19 @@
|
| // choosing spaces to compact.
|
| static void Prepare();
|
|
|
| - // Finishes GC, performs heap verification.
|
| + // Finishes GC, performs heap verification if enabled.
|
| static void Finish();
|
|
|
| - // --------------------------------------------------------------------------
|
| - // Phase 1: functions related to marking phase.
|
| - // before: Heap is in normal state, collector is 'IDLE'.
|
| + // -----------------------------------------------------------------------
|
| + // Phase 1: Marking live objects.
|
| //
|
| - // The first word of a page in old spaces has the end of
|
| - // allocation address of the page.
|
| + // Before: The heap has been prepared for garbage collection by
|
| + // MarkCompactCollector::Prepare() and is otherwise in its
|
| + // normal state.
|
| //
|
| - // The word at Chunk::high_ address has the address of the
|
| - // first page in the next chunk. (The address is tagged to
|
| - // distinguish it from end-of-allocation address).
|
| - //
|
| - // after: live objects are marked.
|
| + // After: Live objects are marked and non-live objects are unmarked.
|
|
|
| +
|
| friend class RootMarkingVisitor;
|
| friend class MarkingVisitor;
|
|
|
| @@ -206,7 +203,6 @@
|
|
|
| #ifdef DEBUG
|
| static void UpdateLiveObjectCount(HeapObject* obj);
|
| - static void VerifyHeapAfterMarkingPhase();
|
| #endif
|
|
|
| // We sweep the large object space in the same way whether we are
|
| @@ -216,30 +212,50 @@
|
| // Test whether a (possibly marked) object is a Map.
|
| static inline bool SafeIsMap(HeapObject* object);
|
|
|
| - // Map transitions from a live map to a dead map must be killed.
|
| + // Map transitions from a live map to a dead map must be killed.
|
| // We replace them with a null descriptor, with the same key.
|
| static void ClearNonLiveTransitions();
|
|
|
| - // --------------------------------------------------------------------------
|
| - // Phase 2: functions related to computing and encoding forwarding pointers
|
| - // before: live objects' map pointers are marked as '00'
|
| - // after: Map pointers of live old and map objects have encoded
|
| - // forwarding pointers and map pointers
|
| + // -----------------------------------------------------------------------
|
| + // Phase 2: Sweeping to clear mark bits and free non-live objects for
|
| + // a non-compacting collection, or else computing and encoding
|
| + // forwarding addresses for a compacting collection.
|
| //
|
| - // The 3rd word of a page has the page top offset after compaction.
|
| + // Before: Live objects are marked and non-live objects are unmarked.
|
| //
|
| - // The 4th word of a page in the map space has the map index
|
| - // of this page in the map table. This word is not used in
|
| - // the old space.
|
| + // After: (Non-compacting collection.) Live objects are unmarked,
|
| + // non-live regions have been added to their space's free
|
| + // list.
|
| //
|
| - // The 5th and 6th words of a page have the start and end
|
| - // addresses of the first free region in the page.
|
| + // After: (Compacting collection.) The forwarding address of live
|
| + // objects in the paged spaces is encoded in their map word
|
| + // along with their (non-forwarded) map pointer.
|
| //
|
| - // The 7th word of a page in old spaces has the forwarding address
|
| - // of the first live object in the page.
|
| + // The forwarding address of live objects in the new space is
|
| + // written to their map word's offset in the inactive
|
| + // semispace.
|
| //
|
| - // Live young objects have their forwarding pointers in
|
| - // the from space at the same offset to the beginning of the space.
|
| + // Bookkeeping data is written to the remembered-set are of
|
| + // eached paged-space page that contains live objects after
|
| + // compaction:
|
| + //
|
| + // The 3rd word of the page (first word of the remembered
|
| + // set) contains the relocation top address, the address of
|
| + // the first word after the end of the last live object in
|
| + // the page after compaction.
|
| + //
|
| + // The 4th word contains the zero-based index of the page in
|
| + // its space. This word is only used for map space pages, in
|
| + // order to encode the map addresses in 21 bits to free 11
|
| + // bits per map word for the forwarding address.
|
| + //
|
| + // The 5th word contains the (nonencoded) forwarding address
|
| + // of the first live object in the page.
|
| + //
|
| + // In both the new space and the paged spaces, a linked list
|
| + // of live regions is constructructed (linked through
|
| + // pointers in the non-live region immediately following each
|
| + // live region) to speed further passes of the collector.
|
|
|
| // Encodes forwarding addresses of objects in compactable parts of the
|
| // heap.
|
| @@ -272,20 +288,22 @@
|
| static void DeallocateCodeBlock(Address start, int size_in_bytes);
|
| static void DeallocateMapBlock(Address start, int size_in_bytes);
|
|
|
| - // Phase 2: If we are not compacting the heap, we simply sweep the spaces
|
| - // except for the large object space, clearing mark bits and adding
|
| - // unmarked regions to each space's free list.
|
| + // If we are not compacting the heap, we simply sweep the spaces except
|
| + // for the large object space, clearing mark bits and adding unmarked
|
| + // regions to each space's free list.
|
| static void SweepSpaces();
|
|
|
| -#ifdef DEBUG
|
| - static void VerifyHeapAfterEncodingForwardingAddresses();
|
| -#endif
|
| + // -----------------------------------------------------------------------
|
| + // Phase 3: Updating pointers in live objects.
|
| + //
|
| + // Before: Same as after phase 2 (compacting collection).
|
| + //
|
| + // After: All pointers in live objects, including encoded map
|
| + // pointers, are updated to point to their target's new
|
| + // location. The remembered set area of each paged-space
|
| + // page containing live objects still contains bookkeeping
|
| + // information.
|
|
|
| - // --------------------------------------------------------------------------
|
| - // Phase 3: function related to updating pointers and decode map pointers
|
| - // before: see after phase 2
|
| - // after: all pointers are updated to forwarding addresses.
|
| -
|
| friend class UpdatingVisitor; // helper for updating visited objects
|
|
|
| // Updates pointers in all spaces.
|
| @@ -302,15 +320,18 @@
|
| // Calculates the forwarding address of an object in an old space.
|
| static Address GetForwardingAddressInOldSpace(HeapObject* obj);
|
|
|
| -#ifdef DEBUG
|
| - static void VerifyHeapAfterUpdatingPointers();
|
| -#endif
|
| + // -----------------------------------------------------------------------
|
| + // Phase 4: Relocating objects.
|
| + //
|
| + // Before: Pointers to live objects are updated to point to their
|
| + // target's new location. The remembered set area of each
|
| + // paged-space page containing live objects still contains
|
| + // bookkeeping information.
|
| + //
|
| + // After: Objects have been moved to their new addresses. The
|
| + // remembered set area of each paged-space page containing
|
| + // live objects still contains bookkeeping information.
|
|
|
| - // --------------------------------------------------------------------------
|
| - // Phase 4: functions related to relocating objects
|
| - // before: see after phase 3
|
| - // after: heap is in a normal state, except remembered set is not built
|
| -
|
| // Relocates objects in all spaces.
|
| static void RelocateObjects();
|
|
|
| @@ -334,18 +355,19 @@
|
| // Copy a new object.
|
| static int RelocateNewObject(HeapObject* obj);
|
|
|
| -#ifdef DEBUG
|
| - static void VerifyHeapAfterRelocatingObjects();
|
| -#endif
|
| + // -----------------------------------------------------------------------
|
| + // Phase 5: Rebuilding remembered sets.
|
| + //
|
| + // Before: The heap is in a normal state except that remembered sets
|
| + // in the paged spaces are not correct.
|
| + //
|
| + // After: The heap is in a normal state.
|
|
|
| - // ---------------------------------------------------------------------------
|
| - // Phase 5: functions related to rebuilding remembered sets
|
| -
|
| // Rebuild remembered set in old and map spaces.
|
| static void RebuildRSets();
|
|
|
| #ifdef DEBUG
|
| - // ---------------------------------------------------------------------------
|
| + // -----------------------------------------------------------------------
|
| // Debugging variables, functions and classes
|
| // Counters used for debugging the marking phase of mark-compact or
|
| // mark-sweep collection.
|
| @@ -371,12 +393,6 @@
|
| // Number of live bytes in this collection.
|
| static int live_bytes_;
|
|
|
| - static void VerifyPageHeaders(PagedSpace* space);
|
| -
|
| - // Verification functions when relocating objects.
|
| - friend class VerifyCopyingVisitor;
|
| - static void VerifyCopyingObjects(Object** p);
|
| -
|
| friend class MarkObjectVisitor;
|
| static void VisitObject(HeapObject* obj);
|
|
|
|
|