OLD | NEW |
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/gc-idle-time-handler.h" | 10 #include "src/heap/gc-idle-time-handler.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 heap->incremental_marking()->RestartIfNotMarking(); | 146 heap->incremental_marking()->RestartIfNotMarking(); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 class IncrementalMarkingMarkingVisitor | 150 class IncrementalMarkingMarkingVisitor |
151 : public StaticMarkingVisitor<IncrementalMarkingMarkingVisitor> { | 151 : public StaticMarkingVisitor<IncrementalMarkingMarkingVisitor> { |
152 public: | 152 public: |
153 static void Initialize() { | 153 static void Initialize() { |
154 StaticMarkingVisitor<IncrementalMarkingMarkingVisitor>::Initialize(); | 154 StaticMarkingVisitor<IncrementalMarkingMarkingVisitor>::Initialize(); |
155 table_.Register(kVisitFixedArray, &VisitFixedArrayIncremental); | 155 table_.Register(kVisitFixedArray, &VisitFixedArrayIncremental); |
156 table_.Register(kVisitNativeContext, &VisitNativeContextIncremental); | |
157 } | 156 } |
158 | 157 |
159 static const int kProgressBarScanningChunk = 32 * 1024; | 158 static const int kProgressBarScanningChunk = 32 * 1024; |
160 | 159 |
161 static void VisitFixedArrayIncremental(Map* map, HeapObject* object) { | 160 static void VisitFixedArrayIncremental(Map* map, HeapObject* object) { |
162 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); | 161 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); |
163 if (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) { | 162 if (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) { |
164 DCHECK(!FLAG_use_marking_progress_bar || | 163 DCHECK(!FLAG_use_marking_progress_bar || |
165 chunk->owner()->identity() == LO_SPACE); | 164 chunk->owner()->identity() == LO_SPACE); |
166 Heap* heap = map->GetHeap(); | 165 Heap* heap = map->GetHeap(); |
(...skipping 25 matching lines...) Expand all Loading... |
192 heap->mark_compact_collector()->UnshiftBlack(object); | 191 heap->mark_compact_collector()->UnshiftBlack(object); |
193 } | 192 } |
194 heap->incremental_marking()->NotifyIncompleteScanOfObject( | 193 heap->incremental_marking()->NotifyIncompleteScanOfObject( |
195 object_size - (start_offset - already_scanned_offset)); | 194 object_size - (start_offset - already_scanned_offset)); |
196 } | 195 } |
197 } else { | 196 } else { |
198 FixedArrayVisitor::Visit(map, object); | 197 FixedArrayVisitor::Visit(map, object); |
199 } | 198 } |
200 } | 199 } |
201 | 200 |
202 static void VisitNativeContextIncremental(Map* map, HeapObject* object) { | |
203 Context* context = Context::cast(object); | |
204 | |
205 // We will mark cache black with a separate pass when we finish marking. | |
206 // Note that GC can happen when the context is not fully initialized, | |
207 // so the cache can be undefined. | |
208 Object* cache = context->get(Context::NORMALIZED_MAP_CACHE_INDEX); | |
209 if (!cache->IsUndefined(map->GetIsolate())) { | |
210 if (cache->IsHeapObject()) { | |
211 HeapObject* heap_obj = HeapObject::cast(cache); | |
212 // Mark the object grey if it is white, do not enque it into the marking | |
213 // deque. | |
214 if (ObjectMarking::IsWhite(heap_obj)) { | |
215 ObjectMarking::WhiteToGrey(heap_obj); | |
216 } | |
217 } | |
218 } | |
219 VisitNativeContext(map, context); | |
220 } | |
221 | |
222 INLINE(static void VisitPointer(Heap* heap, HeapObject* object, Object** p)) { | 201 INLINE(static void VisitPointer(Heap* heap, HeapObject* object, Object** p)) { |
223 Object* target = *p; | 202 Object* target = *p; |
224 if (target->IsHeapObject()) { | 203 if (target->IsHeapObject()) { |
225 heap->mark_compact_collector()->RecordSlot(object, p, target); | 204 heap->mark_compact_collector()->RecordSlot(object, p, target); |
226 MarkObject(heap, target); | 205 MarkObject(heap, target); |
227 } | 206 } |
228 } | 207 } |
229 | 208 |
230 INLINE(static void VisitPointers(Heap* heap, HeapObject* object, | 209 INLINE(static void VisitPointers(Heap* heap, HeapObject* object, |
231 Object** start, Object** end)) { | 210 Object** start, Object** end)) { |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 idle_marking_delay_counter_++; | 1135 idle_marking_delay_counter_++; |
1157 } | 1136 } |
1158 | 1137 |
1159 | 1138 |
1160 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1139 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1161 idle_marking_delay_counter_ = 0; | 1140 idle_marking_delay_counter_ = 0; |
1162 } | 1141 } |
1163 | 1142 |
1164 } // namespace internal | 1143 } // namespace internal |
1165 } // namespace v8 | 1144 } // namespace v8 |
OLD | NEW |