From c5e480096382061964772acdd1d036c44cd1b665 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Tue, 25 Jan 2011 12:35:06 +0000 Subject: [PATCH] Adding GC hooks to support LiveObjectList functionality. Patch by Mark Lam from Hewlett-Packard Development Company, LP Review URL: http://codereview.chromium.org/6287004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6461 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap.cc | 6 ++++++ src/mark-compact.cc | 10 ++++++++++ src/spaces.cc | 3 +++ 3 files changed, 19 insertions(+) diff --git a/src/heap.cc b/src/heap.cc index 32d751a..7c7f3d2 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -35,6 +35,7 @@ #include "debug.h" #include "heap-profiler.h" #include "global-handles.h" +#include "liveobjectlist-inl.h" #include "mark-compact.h" #include "natives.h" #include "objects-visiting.h" @@ -400,6 +401,8 @@ void Heap::GarbageCollectionPrologue() { #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) ReportStatisticsBeforeGC(); #endif + + LiveObjectList::GCPrologue(); } intptr_t Heap::SizeOfObjects() { @@ -412,6 +415,7 @@ intptr_t Heap::SizeOfObjects() { } void Heap::GarbageCollectionEpilogue() { + LiveObjectList::GCEpilogue(); #ifdef DEBUG allow_allocation(true); ZapFromSpace(); @@ -1066,6 +1070,8 @@ void Heap::Scavenge() { UpdateNewSpaceReferencesInExternalStringTable( &UpdateNewSpaceReferenceInExternalStringTableEntry); + LiveObjectList::UpdateReferencesForScavengeGC(); + ASSERT(new_space_front == new_space_.top()); // Set age mark. diff --git a/src/mark-compact.cc b/src/mark-compact.cc index a946ffa..5c649d1 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -33,6 +33,7 @@ #include "gdb-jit.h" #include "global-handles.h" #include "ic-inl.h" +#include "liveobjectlist-inl.h" #include "mark-compact.h" #include "objects-visiting.h" #include "stub-cache.h" @@ -1660,6 +1661,7 @@ inline void EncodeForwardingAddressesInRange(Address start, free_start = current; is_prev_alive = false; } + LiveObjectList::ProcessNonLive(object); } } @@ -1880,6 +1882,9 @@ static void SweepNewSpace(NewSpace* space) { size, false); } else { + // Process the dead object before we write a NULL into its header. + LiveObjectList::ProcessNonLive(object); + size = object->Size(); Memory::Address_at(current) = NULL; } @@ -1899,6 +1904,7 @@ static void SweepNewSpace(NewSpace* space) { // Update roots. Heap::IterateRoots(&updating_visitor, VISIT_ALL_IN_SCAVENGE); + LiveObjectList::IterateElements(&updating_visitor); // Update pointers in old spaces. Heap::IterateDirtyRegions(Heap::old_pointer_space(), @@ -1986,6 +1992,7 @@ static void SweepSpace(PagedSpace* space) { free_start = current; is_previous_alive = false; } + LiveObjectList::ProcessNonLive(object); } // The object is now unmarked for the call to Size() at the top of the // loop. @@ -2164,6 +2171,7 @@ class MapCompact { void UpdateMapPointersInRoots() { Heap::IterateRoots(&map_updating_visitor_, VISIT_ONLY_STRONG); GlobalHandles::IterateWeakRoots(&map_updating_visitor_); + LiveObjectList::IterateElements(&map_updating_visitor_); } void UpdateMapPointersInPagedSpace(PagedSpace* space) { @@ -2533,6 +2541,8 @@ void MarkCompactCollector::UpdatePointers() { // Update the pointer to the head of the weak list of global contexts. updating_visitor.VisitPointer(&Heap::global_contexts_list_); + LiveObjectList::IterateElements(&updating_visitor); + int live_maps_size = IterateLiveObjects(Heap::map_space(), &UpdatePointersInOldObject); int live_pointer_olds_size = IterateLiveObjects(Heap::old_pointer_space(), diff --git a/src/spaces.cc b/src/spaces.cc index fca1032..a586fbf 100644 --- a/src/spaces.cc +++ b/src/spaces.cc @@ -27,6 +27,7 @@ #include "v8.h" +#include "liveobjectlist-inl.h" #include "macro-assembler.h" #include "mark-compact.h" #include "platform.h" @@ -3125,6 +3126,8 @@ void LargeObjectSpace::FreeUnmarkedObjects() { // Free the chunk. MarkCompactCollector::ReportDeleteIfNeeded(object); + LiveObjectList::ProcessNonLive(object); + size_ -= static_cast(chunk_size); objects_size_ -= object->Size(); page_count_--; -- 2.7.4