Revision: 9721
Author: [email protected]
Date: Thu Oct 20 04:40:16 2011
Log: Switch UnreachableObjectsFilter to use Marking instead of
InstrusiveMarking.
GcSafeFindCodeForInnerPointer does not work with intrusive marking now and
it is used when roots are iterated.
[email protected]
Review URL: http://codereview.chromium.org/8342037
http://code.google.com/p/v8/source/detail?r=9721
Modified:
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/liveobjectlist.cc
/branches/bleeding_edge/src/mark-compact.cc
/branches/bleeding_edge/src/mark-compact.h
=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Oct 19 03:15:09 2011
+++ /branches/bleeding_edge/src/heap.cc Thu Oct 20 04:40:16 2011
@@ -5766,56 +5766,51 @@
class UnreachableObjectsFilter : public HeapObjectsFilter {
public:
UnreachableObjectsFilter() {
- MarkUnreachableObjects();
+ MarkReachableObjects();
+ }
+
+ ~UnreachableObjectsFilter() {
+ Isolate::Current()->heap()->mark_compact_collector()->ClearMarkbits();
}
bool SkipObject(HeapObject* object) {
- if (IntrusiveMarking::IsMarked(object)) {
- IntrusiveMarking::ClearMark(object);
- return true;
- } else {
- return false;
- }
+ 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();
- obj->Iterate(this);
+ 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 @@
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;
=======================================
--- /branches/bleeding_edge/src/heap.h Tue Oct 11 08:52:15 2011
+++ /branches/bleeding_edge/src/heap.h Thu Oct 20 04:40:16 2011
@@ -1954,7 +1954,6 @@
public:
enum HeapObjectsFiltering {
kNoFiltering,
- kFilterFreeListNodes,
kFilterUnreachable
};
=======================================
--- /branches/bleeding_edge/src/liveobjectlist.cc Thu Sep 22 04:30:04 2011
+++ /branches/bleeding_edge/src/liveobjectlist.cc Thu Oct 20 04:40:16 2011
@@ -1085,7 +1085,7 @@
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 @@
// 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 @@
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++;
=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Wed Oct 12 08:43:41 2011
+++ /branches/bleeding_edge/src/mark-compact.cc Thu Oct 20 04:40:16 2011
@@ -330,7 +330,7 @@
#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(NewSpace* space) {
+static void ClearMarkbitsInNewSpace(NewSpace* space) {
NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd());
while (it.has_next()) {
@@ -348,15 +348,15 @@
}
-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());
-
- LargeObjectIterator it(heap->lo_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());
for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
MarkBit mark_bit = Marking::MarkBitFrom(obj);
mark_bit.Clear();
@@ -504,7 +504,7 @@
// 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;
}
=======================================
--- /branches/bleeding_edge/src/mark-compact.h Thu Oct 13 04:50:00 2011
+++ /branches/bleeding_edge/src/mark-compact.h Thu Oct 20 04:40:16 2011
@@ -538,6 +538,8 @@
void InvalidateCode(Code* code);
+ void ClearMarkbits();
+
private:
MarkCompactCollector();
~MarkCompactCollector();
@@ -717,7 +719,6 @@
void SweepSpace(PagedSpace* space, SweeperType sweeper);
-
#ifdef DEBUG
//
-----------------------------------------------------------------------
// Debugging variables, functions and classes
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev