 Chromium Code Reviews
 Chromium Code Reviews Issue 2872323002:
  [heap] Color object black on unsafe layout change.  (Closed)
    
  
    Issue 2872323002:
  [heap] Color object black on unsafe layout change.  (Closed) 
  | Index: src/heap/incremental-marking.cc | 
| diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc | 
| index da54a14ed6fbddd64c9b2e73232544738736b8dc..262f59d23a9d2df26d0220f195e3efbaffb30de9 100644 | 
| --- a/src/heap/incremental-marking.cc | 
| +++ b/src/heap/incremental-marking.cc | 
| @@ -137,6 +137,19 @@ bool IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj) { | 
| return false; | 
| } | 
| +void IncrementalMarking::MarkBlackAndPush(HeapObject* obj) { | 
| + MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj, marking_state(obj)); | 
| + // Color the object black and push it into the bailout deque. | 
| + Marking::WhiteToGrey<kAtomicity>(mark_bit); | 
| + if (Marking::GreyToBlack<kAtomicity>(mark_bit)) { | 
| +#if V8_CONCURRENT_MARKING | 
| + marking_deque()->Push(obj, MarkingThread::kMain, TargetDeque::kBailout); | 
| +#else | 
| + marking_deque()->Push(obj); | 
| +#endif | 
| + } | 
| +} | 
| + | 
| void IncrementalMarking::TransferMark(Heap* heap, HeapObject* from, | 
| HeapObject* to) { | 
| DCHECK(MemoryChunk::FromAddress(from->address())->SweepingDone()); | 
| @@ -865,13 +878,16 @@ void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) { | 
| (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); | 
| - } | 
| + // 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 | 
| 
Hannes Payer (out of office)
2017/05/10 20:37:45
Don't you want to bail out for black JSObjects?
 
ulan
2017/05/11 10:37:24
As discussed offline we now have to handle black J
 | 
| + // 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( |