Commit 5d72dde9 authored by vegorov@chromium.org's avatar vegorov@chromium.org

Switch UnreachableObjectsFilter to use Marking instead of InstrusiveMarking.

GcSafeFindCodeForInnerPointer does not work with intrusive marking now and it is used when roots are iterated.

R=erik.corry@gmail.com

Review URL: http://codereview.chromium.org/8342037

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9721 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 38881358
...@@ -5766,56 +5766,51 @@ class HeapObjectsFilter { ...@@ -5766,56 +5766,51 @@ class HeapObjectsFilter {
class UnreachableObjectsFilter : public HeapObjectsFilter { class UnreachableObjectsFilter : public HeapObjectsFilter {
public: public:
UnreachableObjectsFilter() { UnreachableObjectsFilter() {
MarkUnreachableObjects(); MarkReachableObjects();
}
~UnreachableObjectsFilter() {
Isolate::Current()->heap()->mark_compact_collector()->ClearMarkbits();
} }
bool SkipObject(HeapObject* object) { bool SkipObject(HeapObject* object) {
if (IntrusiveMarking::IsMarked(object)) { MarkBit mark_bit = Marking::MarkBitFrom(object);
IntrusiveMarking::ClearMark(object); return !mark_bit.Get();
return true;
} else {
return false;
}
} }
private: private:
class UnmarkingVisitor : public ObjectVisitor { class MarkingVisitor : public ObjectVisitor {
public: public:
UnmarkingVisitor() : list_(10) {} MarkingVisitor() : marking_stack_(10) {}
void VisitPointers(Object** start, Object** end) { void VisitPointers(Object** start, Object** end) {
for (Object** p = start; p < end; p++) { for (Object** p = start; p < end; p++) {
if (!(*p)->IsHeapObject()) continue; if (!(*p)->IsHeapObject()) continue;
HeapObject* obj = HeapObject::cast(*p); HeapObject* obj = HeapObject::cast(*p);
if (IntrusiveMarking::IsMarked(obj)) { MarkBit mark_bit = Marking::MarkBitFrom(obj);
IntrusiveMarking::ClearMark(obj); if (!mark_bit.Get()) {
list_.Add(obj); mark_bit.Set();
marking_stack_.Add(obj);
} }
} }
} }
bool can_process() { return !list_.is_empty(); } void TransitiveClosure() {
while (!marking_stack_.is_empty()) {
void ProcessNext() { HeapObject* obj = marking_stack_.RemoveLast();
HeapObject* obj = list_.RemoveLast(); obj->Iterate(this);
obj->Iterate(this); }
} }
private: private:
List<HeapObject*> list_; List<HeapObject*> marking_stack_;
}; };
void MarkUnreachableObjects() { void MarkReachableObjects() {
HeapIterator iterator; Heap* heap = Isolate::Current()->heap();
for (HeapObject* obj = iterator.next(); MarkingVisitor visitor;
obj != NULL; heap->IterateRoots(&visitor, VISIT_ALL);
obj = iterator.next()) { visitor.TransitiveClosure();
IntrusiveMarking::SetMark(obj);
}
UnmarkingVisitor visitor;
HEAP->IterateRoots(&visitor, VISIT_ALL);
while (visitor.can_process())
visitor.ProcessNext();
} }
AssertNoAllocation no_alloc; AssertNoAllocation no_alloc;
...@@ -5843,13 +5838,8 @@ HeapIterator::~HeapIterator() { ...@@ -5843,13 +5838,8 @@ HeapIterator::~HeapIterator() {
void HeapIterator::Init() { void HeapIterator::Init() {
// Start the iteration. // Start the iteration.
space_iterator_ = filtering_ == kNoFiltering ? new SpaceIterator : space_iterator_ = new SpaceIterator;
new SpaceIterator(Isolate::Current()->heap()->
GcSafeSizeOfOldObjectFunction());
switch (filtering_) { switch (filtering_) {
case kFilterFreeListNodes:
// TODO(gc): Not handled.
break;
case kFilterUnreachable: case kFilterUnreachable:
filter_ = new UnreachableObjectsFilter; filter_ = new UnreachableObjectsFilter;
break; break;
......
...@@ -1954,7 +1954,6 @@ class HeapIterator BASE_EMBEDDED { ...@@ -1954,7 +1954,6 @@ class HeapIterator BASE_EMBEDDED {
public: public:
enum HeapObjectsFiltering { enum HeapObjectsFiltering {
kNoFiltering, kNoFiltering,
kFilterFreeListNodes,
kFilterUnreachable kFilterUnreachable
}; };
......
...@@ -1085,7 +1085,7 @@ void LiveObjectList::SortAll() { ...@@ -1085,7 +1085,7 @@ void LiveObjectList::SortAll() {
static int CountHeapObjects() { static int CountHeapObjects() {
int count = 0; int count = 0;
// Iterate over all the heap spaces and count the number of objects. // Iterate over all the heap spaces and count the number of objects.
HeapIterator iterator(HeapIterator::kFilterFreeListNodes); HeapIterator iterator;
HeapObject* heap_obj = NULL; HeapObject* heap_obj = NULL;
while ((heap_obj = iterator.next()) != NULL) { while ((heap_obj = iterator.next()) != NULL) {
count++; count++;
...@@ -1122,7 +1122,7 @@ MaybeObject* LiveObjectList::Capture() { ...@@ -1122,7 +1122,7 @@ MaybeObject* LiveObjectList::Capture() {
// allocation, and we need allocate below. // allocation, and we need allocate below.
{ {
// Iterate over all the heap spaces and add the objects. // Iterate over all the heap spaces and add the objects.
HeapIterator iterator(HeapIterator::kFilterFreeListNodes); HeapIterator iterator;
HeapObject* heap_obj = NULL; HeapObject* heap_obj = NULL;
bool failed = false; bool failed = false;
while (!failed && (heap_obj = iterator.next()) != NULL) { while (!failed && (heap_obj = iterator.next()) != NULL) {
...@@ -2513,7 +2513,7 @@ void LiveObjectList::Verify(bool match_heap_exactly) { ...@@ -2513,7 +2513,7 @@ void LiveObjectList::Verify(bool match_heap_exactly) {
OS::Print(" Start verify ...\n"); OS::Print(" Start verify ...\n");
OS::Print(" Verifying ..."); OS::Print(" Verifying ...");
Flush(); Flush();
HeapIterator iterator(HeapIterator::kFilterFreeListNodes); HeapIterator iterator;
HeapObject* heap_obj = NULL; HeapObject* heap_obj = NULL;
while ((heap_obj = iterator.next()) != NULL) { while ((heap_obj = iterator.next()) != NULL) {
number_of_heap_objects++; number_of_heap_objects++;
......
...@@ -330,7 +330,7 @@ void MarkCompactCollector::VerifyMarkbitsAreClean() { ...@@ -330,7 +330,7 @@ void MarkCompactCollector::VerifyMarkbitsAreClean() {
#endif #endif
static void ClearMarkbits(PagedSpace* space) { static void ClearMarkbitsInPagedSpace(PagedSpace* space) {
PageIterator it(space); PageIterator it(space);
while (it.has_next()) { while (it.has_next()) {
...@@ -339,7 +339,7 @@ static void ClearMarkbits(PagedSpace* space) { ...@@ -339,7 +339,7 @@ static void ClearMarkbits(PagedSpace* space) {
} }
static void ClearMarkbits(NewSpace* space) { static void ClearMarkbitsInNewSpace(NewSpace* space) {
NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd());
while (it.has_next()) { while (it.has_next()) {
...@@ -348,15 +348,15 @@ static void ClearMarkbits(NewSpace* space) { ...@@ -348,15 +348,15 @@ static void ClearMarkbits(NewSpace* space) {
} }
static void ClearMarkbits(Heap* heap) { void MarkCompactCollector::ClearMarkbits() {
ClearMarkbits(heap->code_space()); ClearMarkbitsInPagedSpace(heap_->code_space());
ClearMarkbits(heap->map_space()); ClearMarkbitsInPagedSpace(heap_->map_space());
ClearMarkbits(heap->old_pointer_space()); ClearMarkbitsInPagedSpace(heap_->old_pointer_space());
ClearMarkbits(heap->old_data_space()); ClearMarkbitsInPagedSpace(heap_->old_data_space());
ClearMarkbits(heap->cell_space()); ClearMarkbitsInPagedSpace(heap_->cell_space());
ClearMarkbits(heap->new_space()); ClearMarkbitsInNewSpace(heap_->new_space());
LargeObjectIterator it(heap->lo_space()); LargeObjectIterator it(heap_->lo_space());
for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
MarkBit mark_bit = Marking::MarkBitFrom(obj); MarkBit mark_bit = Marking::MarkBitFrom(obj);
mark_bit.Clear(); mark_bit.Clear();
...@@ -504,7 +504,7 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) { ...@@ -504,7 +504,7 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) {
// Clear marking bits for precise sweeping to collect all garbage. // Clear marking bits for precise sweeping to collect all garbage.
if (was_marked_incrementally_ && PreciseSweepingRequired()) { if (was_marked_incrementally_ && PreciseSweepingRequired()) {
heap()->incremental_marking()->Abort(); heap()->incremental_marking()->Abort();
ClearMarkbits(heap_); ClearMarkbits();
AbortCompaction(); AbortCompaction();
was_marked_incrementally_ = false; was_marked_incrementally_ = false;
} }
......
...@@ -538,6 +538,8 @@ class MarkCompactCollector { ...@@ -538,6 +538,8 @@ class MarkCompactCollector {
void InvalidateCode(Code* code); void InvalidateCode(Code* code);
void ClearMarkbits();
private: private:
MarkCompactCollector(); MarkCompactCollector();
~MarkCompactCollector(); ~MarkCompactCollector();
...@@ -717,7 +719,6 @@ class MarkCompactCollector { ...@@ -717,7 +719,6 @@ class MarkCompactCollector {
void SweepSpace(PagedSpace* space, SweeperType sweeper); void SweepSpace(PagedSpace* space, SweeperType sweeper);
#ifdef DEBUG #ifdef DEBUG
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Debugging variables, functions and classes // Debugging variables, functions and classes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment