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 {
class UnreachableObjectsFilter : public HeapObjectsFilter {
public:
UnreachableObjectsFilter() {
MarkUnreachableObjects();
MarkReachableObjects();
}
bool SkipObject(HeapObject* object) {
if (IntrusiveMarking::IsMarked(object)) {
IntrusiveMarking::ClearMark(object);
return true;
} else {
return false;
~UnreachableObjectsFilter() {
Isolate::Current()->heap()->mark_compact_collector()->ClearMarkbits();
}
bool SkipObject(HeapObject* object) {
MarkBit mark_bit = Marking::MarkBitFrom(object);
return !mark_bit.Get();
}
private:
class UnmarkingVisitor : public ObjectVisitor {
class MarkingVisitor : public ObjectVisitor {
public:
UnmarkingVisitor() : list_(10) {}
MarkingVisitor() : marking_stack_(10) {}
void VisitPointers(Object** start, Object** end) {
for (Object** p = start; p < end; p++) {
if (!(*p)->IsHeapObject()) continue;
HeapObject* obj = HeapObject::cast(*p);
if (IntrusiveMarking::IsMarked(obj)) {
IntrusiveMarking::ClearMark(obj);
list_.Add(obj);
MarkBit mark_bit = Marking::MarkBitFrom(obj);
if (!mark_bit.Get()) {
mark_bit.Set();
marking_stack_.Add(obj);
}
}
}
bool can_process() { return !list_.is_empty(); }
void ProcessNext() {
HeapObject* obj = list_.RemoveLast();
void TransitiveClosure() {
while (!marking_stack_.is_empty()) {
HeapObject* obj = marking_stack_.RemoveLast();
obj->Iterate(this);
}
}
private:
List<HeapObject*> list_;
List<HeapObject*> marking_stack_;
};
void MarkUnreachableObjects() {
HeapIterator iterator;
for (HeapObject* obj = iterator.next();
obj != NULL;
obj = iterator.next()) {
IntrusiveMarking::SetMark(obj);
}
UnmarkingVisitor visitor;
HEAP->IterateRoots(&visitor, VISIT_ALL);
while (visitor.can_process())
visitor.ProcessNext();
void MarkReachableObjects() {
Heap* heap = Isolate::Current()->heap();
MarkingVisitor visitor;
heap->IterateRoots(&visitor, VISIT_ALL);
visitor.TransitiveClosure();
}
AssertNoAllocation no_alloc;
......@@ -5843,13 +5838,8 @@ HeapIterator::~HeapIterator() {
void HeapIterator::Init() {
// Start the iteration.
space_iterator_ = filtering_ == kNoFiltering ? new SpaceIterator :
new SpaceIterator(Isolate::Current()->heap()->
GcSafeSizeOfOldObjectFunction());
space_iterator_ = new SpaceIterator;
switch (filtering_) {
case kFilterFreeListNodes:
// TODO(gc): Not handled.
break;
case kFilterUnreachable:
filter_ = new UnreachableObjectsFilter;
break;
......
......@@ -1954,7 +1954,6 @@ class HeapIterator BASE_EMBEDDED {
public:
enum HeapObjectsFiltering {
kNoFiltering,
kFilterFreeListNodes,
kFilterUnreachable
};
......
......@@ -1085,7 +1085,7 @@ void LiveObjectList::SortAll() {
static int CountHeapObjects() {
int count = 0;
// Iterate over all the heap spaces and count the number of objects.
HeapIterator iterator(HeapIterator::kFilterFreeListNodes);
HeapIterator iterator;
HeapObject* heap_obj = NULL;
while ((heap_obj = iterator.next()) != NULL) {
count++;
......@@ -1122,7 +1122,7 @@ MaybeObject* LiveObjectList::Capture() {
// allocation, and we need allocate below.
{
// Iterate over all the heap spaces and add the objects.
HeapIterator iterator(HeapIterator::kFilterFreeListNodes);
HeapIterator iterator;
HeapObject* heap_obj = NULL;
bool failed = false;
while (!failed && (heap_obj = iterator.next()) != NULL) {
......@@ -2513,7 +2513,7 @@ void LiveObjectList::Verify(bool match_heap_exactly) {
OS::Print(" Start verify ...\n");
OS::Print(" Verifying ...");
Flush();
HeapIterator iterator(HeapIterator::kFilterFreeListNodes);
HeapIterator iterator;
HeapObject* heap_obj = NULL;
while ((heap_obj = iterator.next()) != NULL) {
number_of_heap_objects++;
......
......@@ -330,7 +330,7 @@ void MarkCompactCollector::VerifyMarkbitsAreClean() {
#endif
static void ClearMarkbits(PagedSpace* space) {
static void ClearMarkbitsInPagedSpace(PagedSpace* space) {
PageIterator it(space);
while (it.has_next()) {
......@@ -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());
while (it.has_next()) {
......@@ -348,15 +348,15 @@ static void ClearMarkbits(NewSpace* space) {
}
static void ClearMarkbits(Heap* heap) {
ClearMarkbits(heap->code_space());
ClearMarkbits(heap->map_space());
ClearMarkbits(heap->old_pointer_space());
ClearMarkbits(heap->old_data_space());
ClearMarkbits(heap->cell_space());
ClearMarkbits(heap->new_space());
void MarkCompactCollector::ClearMarkbits() {
ClearMarkbitsInPagedSpace(heap_->code_space());
ClearMarkbitsInPagedSpace(heap_->map_space());
ClearMarkbitsInPagedSpace(heap_->old_pointer_space());
ClearMarkbitsInPagedSpace(heap_->old_data_space());
ClearMarkbitsInPagedSpace(heap_->cell_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()) {
MarkBit mark_bit = Marking::MarkBitFrom(obj);
mark_bit.Clear();
......@@ -504,7 +504,7 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) {
// Clear marking bits for precise sweeping to collect all garbage.
if (was_marked_incrementally_ && PreciseSweepingRequired()) {
heap()->incremental_marking()->Abort();
ClearMarkbits(heap_);
ClearMarkbits();
AbortCompaction();
was_marked_incrementally_ = false;
}
......
......@@ -538,6 +538,8 @@ class MarkCompactCollector {
void InvalidateCode(Code* code);
void ClearMarkbits();
private:
MarkCompactCollector();
~MarkCompactCollector();
......@@ -717,7 +719,6 @@ class MarkCompactCollector {
void SweepSpace(PagedSpace* space, SweeperType sweeper);
#ifdef DEBUG
// -----------------------------------------------------------------------
// 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