| 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); |
| 156 } | 157 } |
| 157 | 158 |
| 158 static const int kProgressBarScanningChunk = 32 * 1024; | 159 static const int kProgressBarScanningChunk = 32 * 1024; |
| 159 | 160 |
| 160 static void VisitFixedArrayIncremental(Map* map, HeapObject* object) { | 161 static void VisitFixedArrayIncremental(Map* map, HeapObject* object) { |
| 161 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); | 162 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); |
| 162 if (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) { | 163 if (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) { |
| 163 DCHECK(!FLAG_use_marking_progress_bar || | 164 DCHECK(!FLAG_use_marking_progress_bar || |
| 164 chunk->owner()->identity() == LO_SPACE); | 165 chunk->owner()->identity() == LO_SPACE); |
| 165 Heap* heap = map->GetHeap(); | 166 Heap* heap = map->GetHeap(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 191 heap->mark_compact_collector()->UnshiftBlack(object); | 192 heap->mark_compact_collector()->UnshiftBlack(object); |
| 192 } | 193 } |
| 193 heap->incremental_marking()->NotifyIncompleteScanOfObject( | 194 heap->incremental_marking()->NotifyIncompleteScanOfObject( |
| 194 object_size - (start_offset - already_scanned_offset)); | 195 object_size - (start_offset - already_scanned_offset)); |
| 195 } | 196 } |
| 196 } else { | 197 } else { |
| 197 FixedArrayVisitor::Visit(map, object); | 198 FixedArrayVisitor::Visit(map, object); |
| 198 } | 199 } |
| 199 } | 200 } |
| 200 | 201 |
| 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 |
| 201 INLINE(static void VisitPointer(Heap* heap, HeapObject* object, Object** p)) { | 222 INLINE(static void VisitPointer(Heap* heap, HeapObject* object, Object** p)) { |
| 202 Object* target = *p; | 223 Object* target = *p; |
| 203 if (target->IsHeapObject()) { | 224 if (target->IsHeapObject()) { |
| 204 heap->mark_compact_collector()->RecordSlot(object, p, target); | 225 heap->mark_compact_collector()->RecordSlot(object, p, target); |
| 205 MarkObject(heap, target); | 226 MarkObject(heap, target); |
| 206 } | 227 } |
| 207 } | 228 } |
| 208 | 229 |
| 209 INLINE(static void VisitPointers(Heap* heap, HeapObject* object, | 230 INLINE(static void VisitPointers(Heap* heap, HeapObject* object, |
| 210 Object** start, Object** end)) { | 231 Object** start, Object** end)) { |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 idle_marking_delay_counter_++; | 1156 idle_marking_delay_counter_++; |
| 1136 } | 1157 } |
| 1137 | 1158 |
| 1138 | 1159 |
| 1139 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1160 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1140 idle_marking_delay_counter_ = 0; | 1161 idle_marking_delay_counter_ = 0; |
| 1141 } | 1162 } |
| 1142 | 1163 |
| 1143 } // namespace internal | 1164 } // namespace internal |
| 1144 } // namespace v8 | 1165 } // namespace v8 |
| OLD | NEW |