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

Unified Diff: src/heap/incremental-marking.cc

Issue 2872323002: [heap] Color object black on unsafe layout change. (Closed)
Patch Set: fix unused variable 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/incremental-marking.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/incremental-marking.cc
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc
index da54a14ed6fbddd64c9b2e73232544738736b8dc..cb9f46782de264d3272baf809edce8f88b68ac89 100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -137,6 +137,20 @@ bool IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj) {
return false;
}
+void IncrementalMarking::MarkBlackAndPush(HeapObject* obj) {
+ // Color the object black and push it into the bailout deque.
+ ObjectMarking::WhiteToGrey<kAtomicity>(obj, marking_state(obj));
+ if (ObjectMarking::GreyToBlack<kAtomicity>(obj, marking_state(obj))) {
+#if V8_CONCURRENT_MARKING
+ marking_deque()->Push(obj, MarkingThread::kMain, TargetDeque::kBailout);
+#else
+ if (!marking_deque()->Push(obj)) {
+ ObjectMarking::BlackToGrey<kAtomicity>(obj, marking_state(obj));
+ }
+#endif
+ }
+}
+
void IncrementalMarking::TransferMark(Heap* heap, HeapObject* from,
HeapObject* to) {
DCHECK(MemoryChunk::FromAddress(from->address())->SweepingDone());
@@ -813,13 +827,9 @@ void IncrementalMarking::UpdateMarkingDequeAfterScavenge() {
return nullptr;
}
HeapObject* dest = map_word.ToForwardingAddress();
- if (ObjectMarking::IsBlack<kAtomicity>(dest, marking_state(dest))) {
- // The object is already processed by the marker.
- return nullptr;
- }
- DCHECK(ObjectMarking::IsGrey<kAtomicity>(obj, marking_state(obj)) ||
- (obj->IsFiller() &&
- ObjectMarking::IsWhite<kAtomicity>(obj, marking_state(obj))));
+ DCHECK_IMPLIES(
+ ObjectMarking::IsWhite<kAtomicity>(obj, marking_state(obj)),
+ obj->IsFiller());
return dest;
} else if (heap_->InToSpace(obj)) {
// The object may be on a page that was moved in new space.
@@ -838,12 +848,9 @@ void IncrementalMarking::UpdateMarkingDequeAfterScavenge() {
? obj
: nullptr;
}
- DCHECK(ObjectMarking::IsGrey<kAtomicity>(obj, marking_state(obj)) ||
- (obj->IsFiller() &&
- ObjectMarking::IsWhite<kAtomicity>(obj, marking_state(obj))) ||
- (MemoryChunk::FromAddress(obj->address())
- ->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) &&
- ObjectMarking::IsBlack<kAtomicity>(obj, marking_state(obj))));
+ DCHECK_IMPLIES(
+ ObjectMarking::IsWhite<kAtomicity>(obj, marking_state(obj)),
+ obj->IsFiller());
// Skip one word filler objects that appear on the
// stack when we perform in place array shift.
return (obj->map() == filler_map) ? nullptr : obj;
@@ -858,20 +865,20 @@ bool IncrementalMarking::IsFixedArrayWithProgressBar(HeapObject* obj) {
}
void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) {
-#if ENABLE_SLOW_DCHECKS
MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj, marking_state(obj));
- MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());
- SLOW_DCHECK(Marking::IsGrey<kAtomicity>(mark_bit) ||
- (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) &&
- Marking::IsBlack<kAtomicity>(mark_bit)));
-#endif
- if (ObjectMarking::GreyToBlack<kAtomicity>(obj, marking_state(obj))) {
- WhiteToGreyAndPush(map);
- IncrementalMarkingMarkingVisitor::IterateBody(map, obj);
- } else if (IsFixedArrayWithProgressBar(obj)) {
- DCHECK(ObjectMarking::IsBlack<kAtomicity>(obj, marking_state(obj)));
- IncrementalMarkingMarkingVisitor::VisitFixedArrayIncremental(map, obj);
- }
+ DCHECK(Marking::IsGrey<kAtomicity>(mark_bit) ||
+ Marking::IsBlack<kAtomicity>(mark_bit));
+ USE(mark_bit);
+ // The object can already be black in two cases:
+ // 1. The object is a fixed array with the progress bar.
+ // 2. The object is a JSObject that was colored black before
+ // unsafe layout change.
+ if (!ObjectMarking::GreyToBlack<kAtomicity>(obj, marking_state(obj))) {
+ DCHECK(IsFixedArrayWithProgressBar(obj) || obj->IsJSObject());
+ }
+ DCHECK(ObjectMarking::IsBlack<kAtomicity>(obj, marking_state(obj)));
+ WhiteToGreyAndPush(map);
+ IncrementalMarkingMarkingVisitor::IterateBody(map, obj);
}
intptr_t IncrementalMarking::ProcessMarkingDeque(
« no previous file with comments | « src/heap/incremental-marking.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698