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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 Marking::WhiteToGrey(mark_bit); | 122 Marking::WhiteToGrey(mark_bit); |
123 heap_->mark_compact_collector()->marking_deque()->Push(obj); | 123 heap_->mark_compact_collector()->marking_deque()->Push(obj); |
124 } | 124 } |
125 | 125 |
126 | 126 |
127 static void MarkObjectGreyDoNotEnqueue(Object* obj) { | 127 static void MarkObjectGreyDoNotEnqueue(Object* obj) { |
128 if (obj->IsHeapObject()) { | 128 if (obj->IsHeapObject()) { |
129 HeapObject* heap_obj = HeapObject::cast(obj); | 129 HeapObject* heap_obj = HeapObject::cast(obj); |
130 MarkBit mark_bit = ObjectMarking::MarkBitFrom(HeapObject::cast(obj)); | 130 MarkBit mark_bit = ObjectMarking::MarkBitFrom(HeapObject::cast(obj)); |
131 if (Marking::IsBlack(mark_bit)) { | 131 if (Marking::IsBlack(mark_bit)) { |
132 MemoryChunk::IncrementLiveBytesFromGC(heap_obj, -heap_obj->Size()); | 132 MemoryChunk::IncrementLiveBytes(heap_obj, -heap_obj->Size()); |
133 } | 133 } |
134 Marking::AnyToGrey(mark_bit); | 134 Marking::AnyToGrey(mark_bit); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 void IncrementalMarking::TransferMark(Heap* heap, Address old_start, | 138 void IncrementalMarking::TransferMark(Heap* heap, Address old_start, |
139 Address new_start) { | 139 Address new_start) { |
140 // This is only used when resizing an object. | 140 // This is only used when resizing an object. |
141 DCHECK(MemoryChunk::FromAddress(old_start) == | 141 DCHECK(MemoryChunk::FromAddress(old_start) == |
142 MemoryChunk::FromAddress(new_start)); | 142 MemoryChunk::FromAddress(new_start)); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 IncrementalMarking::MarkGrey(heap, HeapObject::cast(obj)); | 261 IncrementalMarking::MarkGrey(heap, HeapObject::cast(obj)); |
262 } | 262 } |
263 | 263 |
264 // Marks the object black without pushing it on the marking stack. | 264 // Marks the object black without pushing it on the marking stack. |
265 // Returns true if object needed marking and false otherwise. | 265 // Returns true if object needed marking and false otherwise. |
266 INLINE(static bool MarkObjectWithoutPush(Heap* heap, Object* obj)) { | 266 INLINE(static bool MarkObjectWithoutPush(Heap* heap, Object* obj)) { |
267 HeapObject* heap_object = HeapObject::cast(obj); | 267 HeapObject* heap_object = HeapObject::cast(obj); |
268 MarkBit mark_bit = ObjectMarking::MarkBitFrom(heap_object); | 268 MarkBit mark_bit = ObjectMarking::MarkBitFrom(heap_object); |
269 if (Marking::IsWhite(mark_bit)) { | 269 if (Marking::IsWhite(mark_bit)) { |
270 Marking::MarkBlack(mark_bit); | 270 Marking::MarkBlack(mark_bit); |
271 MemoryChunk::IncrementLiveBytesFromGC(heap_object, heap_object->Size()); | 271 MemoryChunk::IncrementLiveBytes(heap_object, heap_object->Size()); |
272 return true; | 272 return true; |
273 } | 273 } |
274 return false; | 274 return false; |
275 } | 275 } |
276 }; | 276 }; |
277 | 277 |
278 void IncrementalMarking::IterateBlackObject(HeapObject* object) { | 278 void IncrementalMarking::IterateBlackObject(HeapObject* object) { |
279 if (IsMarking() && Marking::IsBlack(ObjectMarking::MarkBitFrom(object))) { | 279 if (IsMarking() && Marking::IsBlack(ObjectMarking::MarkBitFrom(object))) { |
280 Page* page = Page::FromAddress(object->address()); | 280 Page* page = Page::FromAddress(object->address()); |
281 if ((page->owner() != nullptr) && (page->owner()->identity() == LO_SPACE)) { | 281 if ((page->owner() != nullptr) && (page->owner()->identity() == LO_SPACE)) { |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 MarkBit mark_bit = ObjectMarking::MarkBitFrom(object); | 857 MarkBit mark_bit = ObjectMarking::MarkBitFrom(object); |
858 if (Marking::IsWhite(mark_bit)) { | 858 if (Marking::IsWhite(mark_bit)) { |
859 heap->incremental_marking()->WhiteToGreyAndPush(object, mark_bit); | 859 heap->incremental_marking()->WhiteToGreyAndPush(object, mark_bit); |
860 } | 860 } |
861 } | 861 } |
862 | 862 |
863 void IncrementalMarking::MarkBlack(HeapObject* obj, int size) { | 863 void IncrementalMarking::MarkBlack(HeapObject* obj, int size) { |
864 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj); | 864 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj); |
865 if (Marking::IsBlack(mark_bit)) return; | 865 if (Marking::IsBlack(mark_bit)) return; |
866 Marking::GreyToBlack(mark_bit); | 866 Marking::GreyToBlack(mark_bit); |
867 MemoryChunk::IncrementLiveBytesFromGC(obj, size); | 867 MemoryChunk::IncrementLiveBytes(obj, size); |
868 } | 868 } |
869 | 869 |
870 intptr_t IncrementalMarking::ProcessMarkingDeque( | 870 intptr_t IncrementalMarking::ProcessMarkingDeque( |
871 intptr_t bytes_to_process, ForceCompletionAction completion) { | 871 intptr_t bytes_to_process, ForceCompletionAction completion) { |
872 intptr_t bytes_processed = 0; | 872 intptr_t bytes_processed = 0; |
873 MarkingDeque* marking_deque = | 873 MarkingDeque* marking_deque = |
874 heap_->mark_compact_collector()->marking_deque(); | 874 heap_->mark_compact_collector()->marking_deque(); |
875 while (!marking_deque->IsEmpty() && (bytes_processed < bytes_to_process || | 875 while (!marking_deque->IsEmpty() && (bytes_processed < bytes_to_process || |
876 completion == FORCE_COMPLETION)) { | 876 completion == FORCE_COMPLETION)) { |
877 HeapObject* obj = marking_deque->Pop(); | 877 HeapObject* obj = marking_deque->Pop(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 Object* context = heap_->native_contexts_list(); | 926 Object* context = heap_->native_contexts_list(); |
927 while (!context->IsUndefined(heap_->isolate())) { | 927 while (!context->IsUndefined(heap_->isolate())) { |
928 // GC can happen when the context is not fully initialized, | 928 // GC can happen when the context is not fully initialized, |
929 // so the cache can be undefined. | 929 // so the cache can be undefined. |
930 HeapObject* cache = HeapObject::cast( | 930 HeapObject* cache = HeapObject::cast( |
931 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX)); | 931 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX)); |
932 if (!cache->IsUndefined(heap_->isolate())) { | 932 if (!cache->IsUndefined(heap_->isolate())) { |
933 MarkBit mark_bit = ObjectMarking::MarkBitFrom(cache); | 933 MarkBit mark_bit = ObjectMarking::MarkBitFrom(cache); |
934 if (Marking::IsGrey(mark_bit)) { | 934 if (Marking::IsGrey(mark_bit)) { |
935 Marking::GreyToBlack(mark_bit); | 935 Marking::GreyToBlack(mark_bit); |
936 MemoryChunk::IncrementLiveBytesFromGC(cache, cache->Size()); | 936 MemoryChunk::IncrementLiveBytes(cache, cache->Size()); |
937 } | 937 } |
938 } | 938 } |
939 context = Context::cast(context)->next_context_link(); | 939 context = Context::cast(context)->next_context_link(); |
940 } | 940 } |
941 } | 941 } |
942 | 942 |
943 | 943 |
944 void IncrementalMarking::Stop() { | 944 void IncrementalMarking::Stop() { |
945 if (IsStopped()) return; | 945 if (IsStopped()) return; |
946 if (FLAG_trace_incremental_marking) { | 946 if (FLAG_trace_incremental_marking) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 idle_marking_delay_counter_++; | 1190 idle_marking_delay_counter_++; |
1191 } | 1191 } |
1192 | 1192 |
1193 | 1193 |
1194 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1194 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1195 idle_marking_delay_counter_ = 0; | 1195 idle_marking_delay_counter_ = 0; |
1196 } | 1196 } |
1197 | 1197 |
1198 } // namespace internal | 1198 } // namespace internal |
1199 } // namespace v8 | 1199 } // namespace v8 |
OLD | NEW |