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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/heap/incremental-marking.h" | 7 #include "src/heap/incremental-marking.h" |
8 | 8 |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 static void MarkObjectGreyDoNotEnqueue(Object* obj) { | 125 static void MarkObjectGreyDoNotEnqueue(Object* obj) { |
126 if (obj->IsHeapObject()) { | 126 if (obj->IsHeapObject()) { |
127 HeapObject* heap_obj = HeapObject::cast(obj); | 127 HeapObject* heap_obj = HeapObject::cast(obj); |
128 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj)); | 128 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj)); |
129 if (Marking::IsBlack(mark_bit)) { | 129 if (Marking::IsBlack(mark_bit)) { |
130 MemoryChunk::IncrementLiveBytesFromGC(heap_obj->address(), | 130 MemoryChunk::IncrementLiveBytesFromGC(heap_obj, -heap_obj->Size()); |
131 -heap_obj->Size()); | |
132 } | 131 } |
133 Marking::AnyToGrey(mark_bit); | 132 Marking::AnyToGrey(mark_bit); |
134 } | 133 } |
135 } | 134 } |
136 | 135 |
137 | 136 |
138 static inline void MarkBlackOrKeepBlack(HeapObject* heap_object, | 137 static inline void MarkBlackOrKeepBlack(HeapObject* heap_object, |
139 MarkBit mark_bit, int size) { | 138 MarkBit mark_bit, int size) { |
140 DCHECK(!Marking::IsImpossible(mark_bit)); | 139 DCHECK(!Marking::IsImpossible(mark_bit)); |
141 if (Marking::IsBlack(mark_bit)) return; | 140 if (Marking::IsBlack(mark_bit)) return; |
142 Marking::MarkBlack(mark_bit); | 141 Marking::MarkBlack(mark_bit); |
143 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(), size); | 142 MemoryChunk::IncrementLiveBytesFromGC(heap_object, size); |
144 } | 143 } |
145 | 144 |
146 | 145 |
147 class IncrementalMarkingMarkingVisitor | 146 class IncrementalMarkingMarkingVisitor |
148 : public StaticMarkingVisitor<IncrementalMarkingMarkingVisitor> { | 147 : public StaticMarkingVisitor<IncrementalMarkingMarkingVisitor> { |
149 public: | 148 public: |
150 static void Initialize() { | 149 static void Initialize() { |
151 StaticMarkingVisitor<IncrementalMarkingMarkingVisitor>::Initialize(); | 150 StaticMarkingVisitor<IncrementalMarkingMarkingVisitor>::Initialize(); |
152 table_.Register(kVisitFixedArray, &VisitFixedArrayIncremental); | 151 table_.Register(kVisitFixedArray, &VisitFixedArrayIncremental); |
153 table_.Register(kVisitNativeContext, &VisitNativeContextIncremental); | 152 table_.Register(kVisitNativeContext, &VisitNativeContextIncremental); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 IncrementalMarking::MarkObject(heap, HeapObject::cast(obj)); | 248 IncrementalMarking::MarkObject(heap, HeapObject::cast(obj)); |
250 } | 249 } |
251 | 250 |
252 // Marks the object black without pushing it on the marking stack. | 251 // Marks the object black without pushing it on the marking stack. |
253 // Returns true if object needed marking and false otherwise. | 252 // Returns true if object needed marking and false otherwise. |
254 INLINE(static bool MarkObjectWithoutPush(Heap* heap, Object* obj)) { | 253 INLINE(static bool MarkObjectWithoutPush(Heap* heap, Object* obj)) { |
255 HeapObject* heap_object = HeapObject::cast(obj); | 254 HeapObject* heap_object = HeapObject::cast(obj); |
256 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); | 255 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); |
257 if (Marking::IsWhite(mark_bit)) { | 256 if (Marking::IsWhite(mark_bit)) { |
258 Marking::MarkBlack(mark_bit); | 257 Marking::MarkBlack(mark_bit); |
259 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(), | 258 MemoryChunk::IncrementLiveBytesFromGC(heap_object, heap_object->Size()); |
260 heap_object->Size()); | |
261 return true; | 259 return true; |
262 } | 260 } |
263 return false; | 261 return false; |
264 } | 262 } |
265 }; | 263 }; |
266 | 264 |
267 | 265 |
268 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor { | 266 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor { |
269 public: | 267 public: |
270 explicit IncrementalMarkingRootMarkingVisitor( | 268 explicit IncrementalMarkingRootMarkingVisitor( |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 if (FLAG_trace_incremental_marking) { | 711 if (FLAG_trace_incremental_marking) { |
714 PrintF("[IncrementalMarking] Complete (hurry), spent %d ms.\n", | 712 PrintF("[IncrementalMarking] Complete (hurry), spent %d ms.\n", |
715 static_cast<int>(delta)); | 713 static_cast<int>(delta)); |
716 } | 714 } |
717 } | 715 } |
718 } | 716 } |
719 | 717 |
720 if (FLAG_cleanup_code_caches_at_gc) { | 718 if (FLAG_cleanup_code_caches_at_gc) { |
721 PolymorphicCodeCache* poly_cache = heap_->polymorphic_code_cache(); | 719 PolymorphicCodeCache* poly_cache = heap_->polymorphic_code_cache(); |
722 Marking::GreyToBlack(Marking::MarkBitFrom(poly_cache)); | 720 Marking::GreyToBlack(Marking::MarkBitFrom(poly_cache)); |
723 MemoryChunk::IncrementLiveBytesFromGC(poly_cache->address(), | 721 MemoryChunk::IncrementLiveBytesFromGC(poly_cache, |
724 PolymorphicCodeCache::kSize); | 722 PolymorphicCodeCache::kSize); |
725 } | 723 } |
726 | 724 |
727 Object* context = heap_->native_contexts_list(); | 725 Object* context = heap_->native_contexts_list(); |
728 while (!context->IsUndefined()) { | 726 while (!context->IsUndefined()) { |
729 // GC can happen when the context is not fully initialized, | 727 // GC can happen when the context is not fully initialized, |
730 // so the cache can be undefined. | 728 // so the cache can be undefined. |
731 HeapObject* cache = HeapObject::cast( | 729 HeapObject* cache = HeapObject::cast( |
732 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX)); | 730 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX)); |
733 if (!cache->IsUndefined()) { | 731 if (!cache->IsUndefined()) { |
734 MarkBit mark_bit = Marking::MarkBitFrom(cache); | 732 MarkBit mark_bit = Marking::MarkBitFrom(cache); |
735 if (Marking::IsGrey(mark_bit)) { | 733 if (Marking::IsGrey(mark_bit)) { |
736 Marking::GreyToBlack(mark_bit); | 734 Marking::GreyToBlack(mark_bit); |
737 MemoryChunk::IncrementLiveBytesFromGC(cache->address(), cache->Size()); | 735 MemoryChunk::IncrementLiveBytesFromGC(cache, cache->Size()); |
738 } | 736 } |
739 } | 737 } |
740 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | 738 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); |
741 } | 739 } |
742 } | 740 } |
743 | 741 |
744 | 742 |
745 void IncrementalMarking::Abort() { | 743 void IncrementalMarking::Abort() { |
746 if (IsStopped()) return; | 744 if (IsStopped()) return; |
747 if (FLAG_trace_incremental_marking) { | 745 if (FLAG_trace_incremental_marking) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1021 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
1024 idle_marking_delay_counter_++; | 1022 idle_marking_delay_counter_++; |
1025 } | 1023 } |
1026 | 1024 |
1027 | 1025 |
1028 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1026 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1029 idle_marking_delay_counter_ = 0; | 1027 idle_marking_delay_counter_ = 0; |
1030 } | 1028 } |
1031 } // namespace internal | 1029 } // namespace internal |
1032 } // namespace v8 | 1030 } // namespace v8 |
OLD | NEW |