Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: src/heap/mark-compact.cc

Issue 2857713002: [heap] Make non-atomic markbit operations consistent with atomic ones. (Closed)
Patch Set: fix overlap check Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/heap/mark-compact-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index f6d98bed55126cc86cfe0e779855bcb0fbee145a..9f6b47f1e8b3231ca51dad3513c4a782593c30a8 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -1176,12 +1176,10 @@ class StaticYoungGenerationMarkingVisitor
StackLimitCheck check(heap->isolate());
if (check.HasOverflowed()) return false;
- if (ObjectMarking::IsBlackOrGrey<MarkBit::NON_ATOMIC>(
- object, MarkingState::External(object)))
- return true;
- ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>(
- object, MarkingState::External(object));
- IterateBody(object->map(), object);
+ if (ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>(
+ object, MarkingState::External(object))) {
+ IterateBody(object->map(), object);
+ }
return true;
}
};
@@ -1217,11 +1215,7 @@ class MarkCompactMarkingVisitor
// Marks the object black without pushing it on the marking stack.
// Returns true if object needed marking and false otherwise.
INLINE(static bool MarkObjectWithoutPush(Heap* heap, HeapObject* object)) {
- if (ObjectMarking::IsWhite(object, MarkingState::Internal(object))) {
- ObjectMarking::WhiteToBlack(object, MarkingState::Internal(object));
- return true;
- }
- return false;
+ return ObjectMarking::WhiteToBlack(object, MarkingState::Internal(object));
}
// Mark object pointed to by p.
@@ -1239,14 +1233,15 @@ class MarkCompactMarkingVisitor
HeapObject* obj)) {
#ifdef DEBUG
DCHECK(collector->heap()->Contains(obj));
- DCHECK(ObjectMarking::IsWhite(obj, MarkingState::Internal(obj)));
#endif
- Map* map = obj->map();
- Heap* heap = obj->GetHeap();
- ObjectMarking::WhiteToBlack(obj, MarkingState::Internal(obj));
- // Mark the map pointer and the body.
- heap->mark_compact_collector()->MarkObject(map);
- IterateBody(map, obj);
+ if (ObjectMarking::WhiteToBlack(obj, MarkingState::Internal(obj))) {
+ Map* map = obj->map();
+ Heap* heap = obj->GetHeap();
+ ObjectMarking::WhiteToBlack(obj, MarkingState::Internal(obj));
+ // Mark the map pointer and the body.
+ heap->mark_compact_collector()->MarkObject(map);
+ IterateBody(map, obj);
+ }
}
// Visit all unmarked objects pointed to by [start, end).
@@ -1264,8 +1259,6 @@ class MarkCompactMarkingVisitor
if (!o->IsHeapObject()) continue;
collector->RecordSlot(object, p, o);
HeapObject* obj = HeapObject::cast(o);
- if (ObjectMarking::IsBlackOrGrey(obj, MarkingState::Internal(obj)))
- continue;
VisitUnmarkedObject(collector, obj);
}
return true;
@@ -1462,16 +1455,12 @@ class MinorMarkCompactCollector::RootMarkingVisitor : public RootVisitor {
if (!collector_->heap()->InNewSpace(object)) return;
- if (ObjectMarking::IsBlackOrGrey<MarkBit::NON_ATOMIC>(
- object, MarkingState::External(object)))
- return;
-
- Map* map = object->map();
- ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>(
- object, MarkingState::External(object));
- StaticYoungGenerationMarkingVisitor::IterateBody(map, object);
-
- collector_->EmptyMarkingDeque();
+ if (ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>(
+ object, MarkingState::External(object))) {
+ Map* map = object->map();
+ StaticYoungGenerationMarkingVisitor::IterateBody(map, object);
+ collector_->EmptyMarkingDeque();
+ }
}
MinorMarkCompactCollector* collector_;
@@ -1512,22 +1501,16 @@ class MarkCompactCollector::RootMarkingVisitor : public ObjectVisitor,
HeapObject* object = HeapObject::cast(*p);
- if (ObjectMarking::IsBlackOrGrey<MarkBit::NON_ATOMIC>(
- object, MarkingState::Internal(object)))
- return;
-
- Map* map = object->map();
- // Mark the object.
- ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>(
- object, MarkingState::Internal(object));
-
- // Mark the map pointer and body, and push them on the marking stack.
- collector_->MarkObject(map);
- MarkCompactMarkingVisitor::IterateBody(map, object);
-
- // Mark all the objects reachable from the map and body. May leave
- // overflowed objects in the heap.
- collector_->EmptyMarkingDeque();
+ if (ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>(
+ object, MarkingState::Internal(object))) {
+ Map* map = object->map();
+ // Mark the map pointer and body, and push them on the marking stack.
+ collector_->MarkObject(map);
+ MarkCompactMarkingVisitor::IterateBody(map, object);
+ // Mark all the objects reachable from the map and body. May leave
+ // overflowed objects in the heap.
+ collector_->EmptyMarkingDeque();
+ }
}
MarkCompactCollector* collector_;
@@ -1638,8 +1621,7 @@ void MarkCompactCollector::DiscoverGreyObjectsWithIterator(T* it) {
Map* filler_map = heap()->one_pointer_filler_map();
for (HeapObject* object = it->Next(); object != NULL; object = it->Next()) {
if ((object->map() != filler_map) &&
- ObjectMarking::IsGrey(object, MarkingState::Internal(object))) {
- ObjectMarking::GreyToBlack(object, MarkingState::Internal(object));
+ ObjectMarking::GreyToBlack(object, MarkingState::Internal(object))) {
PushBlack(object);
if (marking_deque()->IsFull()) return;
}
@@ -1651,8 +1633,10 @@ void MarkCompactCollector::DiscoverGreyObjectsOnPage(MemoryChunk* p) {
LiveObjectIterator<kGreyObjects> it(p, MarkingState::Internal(p));
HeapObject* object = NULL;
while ((object = it.Next()) != NULL) {
- DCHECK(ObjectMarking::IsGrey(object, MarkingState::Internal(object)));
- ObjectMarking::GreyToBlack(object, MarkingState::Internal(object));
+ bool success =
+ ObjectMarking::GreyToBlack(object, MarkingState::Internal(object));
+ DCHECK(success);
+ USE(success);
PushBlack(object);
if (marking_deque()->IsFull()) return;
}
@@ -2146,15 +2130,12 @@ bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) {
void MarkCompactCollector::MarkStringTable(RootMarkingVisitor* visitor) {
StringTable* string_table = heap()->string_table();
// Mark the string table itself.
- if (ObjectMarking::IsWhite(string_table,
- MarkingState::Internal(string_table))) {
- // String table could have already been marked by visiting the handles list.
- ObjectMarking::WhiteToBlack(string_table,
- MarkingState::Internal(string_table));
- }
- // Explicitly mark the prefix.
- string_table->IteratePrefix(visitor);
- ProcessMarkingDeque();
+ if (ObjectMarking::WhiteToBlack(string_table,
+ MarkingState::Internal(string_table))) {
+ // Explicitly mark the prefix.
+ string_table->IteratePrefix(visitor);
+ ProcessMarkingDeque();
+ }
}
void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) {
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/heap/mark-compact-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698