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

Side by Side Diff: src/heap/incremental-marking.cc

Issue 2872323002: [heap] Color object black on unsafe layout change. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/heap/incremental-marking.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/incremental-marking.h" 5 #include "src/heap/incremental-marking.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/compilation-cache.h" 8 #include "src/compilation-cache.h"
9 #include "src/conversions.h" 9 #include "src/conversions.h"
10 #include "src/heap/concurrent-marking.h" 10 #include "src/heap/concurrent-marking.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 bool IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj) { 132 bool IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj) {
133 if (ObjectMarking::WhiteToGrey<kAtomicity>(obj, marking_state(obj))) { 133 if (ObjectMarking::WhiteToGrey<kAtomicity>(obj, marking_state(obj))) {
134 marking_deque()->Push(obj); 134 marking_deque()->Push(obj);
135 return true; 135 return true;
136 } 136 }
137 return false; 137 return false;
138 } 138 }
139 139
140 void IncrementalMarking::MarkBlackAndPush(HeapObject* obj) {
141 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj, marking_state(obj));
142 // Color the object black and push it into the bailout deque.
143 Marking::WhiteToGrey<kAtomicity>(mark_bit);
144 if (Marking::GreyToBlack<kAtomicity>(mark_bit)) {
145 #if V8_CONCURRENT_MARKING
146 marking_deque()->Push(obj, MarkingThread::kMain, TargetDeque::kBailout);
147 #else
148 marking_deque()->Push(obj);
149 #endif
150 }
151 }
152
140 void IncrementalMarking::TransferMark(Heap* heap, HeapObject* from, 153 void IncrementalMarking::TransferMark(Heap* heap, HeapObject* from,
141 HeapObject* to) { 154 HeapObject* to) {
142 DCHECK(MemoryChunk::FromAddress(from->address())->SweepingDone()); 155 DCHECK(MemoryChunk::FromAddress(from->address())->SweepingDone());
143 // This is only used when resizing an object. 156 // This is only used when resizing an object.
144 DCHECK(MemoryChunk::FromAddress(from->address()) == 157 DCHECK(MemoryChunk::FromAddress(from->address()) ==
145 MemoryChunk::FromAddress(to->address())); 158 MemoryChunk::FromAddress(to->address()));
146 159
147 if (!IsMarking()) return; 160 if (!IsMarking()) return;
148 161
149 // If the mark doesn't move, we don't check the color of the object. 162 // If the mark doesn't move, we don't check the color of the object.
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 } 871 }
859 872
860 void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) { 873 void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) {
861 #if ENABLE_SLOW_DCHECKS 874 #if ENABLE_SLOW_DCHECKS
862 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj, marking_state(obj)); 875 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj, marking_state(obj));
863 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); 876 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());
864 SLOW_DCHECK(Marking::IsGrey<kAtomicity>(mark_bit) || 877 SLOW_DCHECK(Marking::IsGrey<kAtomicity>(mark_bit) ||
865 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && 878 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) &&
866 Marking::IsBlack<kAtomicity>(mark_bit))); 879 Marking::IsBlack<kAtomicity>(mark_bit)));
867 #endif 880 #endif
868 if (ObjectMarking::GreyToBlack<kAtomicity>(obj, marking_state(obj))) { 881 // The object can already be black in two cases:
869 WhiteToGreyAndPush(map); 882 // 1. The object is a fixed array with the progress bar.
870 IncrementalMarkingMarkingVisitor::IterateBody(map, obj); 883 // 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
871 } else if (IsFixedArrayWithProgressBar(obj)) { 884 // unsafe layout change.
872 DCHECK(ObjectMarking::IsBlack<kAtomicity>(obj, marking_state(obj))); 885 if (!ObjectMarking::GreyToBlack<kAtomicity>(obj, marking_state(obj))) {
873 IncrementalMarkingMarkingVisitor::VisitFixedArrayIncremental(map, obj); 886 DCHECK(IsFixedArrayWithProgressBar(obj) || obj->IsJSObject());
874 } 887 }
888 DCHECK(ObjectMarking::IsBlack<kAtomicity>(obj, marking_state(obj)));
889 WhiteToGreyAndPush(map);
890 IncrementalMarkingMarkingVisitor::IterateBody(map, obj);
875 } 891 }
876 892
877 intptr_t IncrementalMarking::ProcessMarkingDeque( 893 intptr_t IncrementalMarking::ProcessMarkingDeque(
878 intptr_t bytes_to_process, ForceCompletionAction completion) { 894 intptr_t bytes_to_process, ForceCompletionAction completion) {
879 intptr_t bytes_processed = 0; 895 intptr_t bytes_processed = 0;
880 while (!marking_deque()->IsEmpty() && (bytes_processed < bytes_to_process || 896 while (!marking_deque()->IsEmpty() && (bytes_processed < bytes_to_process ||
881 completion == FORCE_COMPLETION)) { 897 completion == FORCE_COMPLETION)) {
882 HeapObject* obj = marking_deque()->Pop(); 898 HeapObject* obj = marking_deque()->Pop();
883 899
884 // Left trimming may result in white, grey, or black filler objects on the 900 // Left trimming may result in white, grey, or black filler objects on the
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 idle_marking_delay_counter_++; 1233 idle_marking_delay_counter_++;
1218 } 1234 }
1219 1235
1220 1236
1221 void IncrementalMarking::ClearIdleMarkingDelayCounter() { 1237 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
1222 idle_marking_delay_counter_ = 0; 1238 idle_marking_delay_counter_ = 0;
1223 } 1239 }
1224 1240
1225 } // namespace internal 1241 } // namespace internal
1226 } // namespace v8 1242 } // namespace v8
OLDNEW
« 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