| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 Object* obj = *p; | 244 Object* obj = *p; |
| 245 if (obj->IsHeapObject()) { | 245 if (obj->IsHeapObject()) { |
| 246 heap->mark_compact_collector()->RecordSlot(anchor, p, obj); | 246 heap->mark_compact_collector()->RecordSlot(anchor, p, obj); |
| 247 MarkObject(heap, obj); | 247 MarkObject(heap, obj); |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 // Marks the object grey and pushes it on the marking stack. | 252 // Marks the object grey and pushes it on the marking stack. |
| 253 INLINE(static void MarkObject(Heap* heap, Object* obj)) { | 253 INLINE(static void MarkObject(Heap* heap, Object* obj)) { |
| 254 HeapObject* heap_object = HeapObject::cast(obj); | 254 IncrementalMarking::MarkObject(heap, obj); |
| 255 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); | |
| 256 if (mark_bit.data_only()) { | |
| 257 MarkBlackOrKeepGrey(heap_object, mark_bit, heap_object->Size()); | |
| 258 } else if (Marking::IsWhite(mark_bit)) { | |
| 259 heap->incremental_marking()->WhiteToGreyAndPush(heap_object, mark_bit); | |
| 260 } | |
| 261 } | 255 } |
| 262 | 256 |
| 263 // Marks the object black without pushing it on the marking stack. | 257 // Marks the object black without pushing it on the marking stack. |
| 264 // Returns true if object needed marking and false otherwise. | 258 // Returns true if object needed marking and false otherwise. |
| 265 INLINE(static bool MarkObjectWithoutPush(Heap* heap, Object* obj)) { | 259 INLINE(static bool MarkObjectWithoutPush(Heap* heap, Object* obj)) { |
| 266 HeapObject* heap_object = HeapObject::cast(obj); | 260 HeapObject* heap_object = HeapObject::cast(obj); |
| 267 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); | 261 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); |
| 268 if (Marking::IsWhite(mark_bit)) { | 262 if (Marking::IsWhite(mark_bit)) { |
| 269 mark_bit.Set(); | 263 mark_bit.Set(); |
| 270 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(), | 264 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(), |
| 271 heap_object->Size()); | 265 heap_object->Size()); |
| 272 return true; | 266 return true; |
| 273 } | 267 } |
| 274 return false; | 268 return false; |
| 275 } | 269 } |
| 276 }; | 270 }; |
| 277 | 271 |
| 278 | 272 |
| 279 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor { | 273 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor { |
| 280 public: | 274 public: |
| 281 explicit IncrementalMarkingRootMarkingVisitor( | 275 explicit IncrementalMarkingRootMarkingVisitor( |
| 282 IncrementalMarking* incremental_marking) | 276 IncrementalMarking* incremental_marking) |
| 283 : incremental_marking_(incremental_marking) {} | 277 : heap_(incremental_marking->heap()) {} |
| 284 | 278 |
| 285 void VisitPointer(Object** p) { MarkObjectByPointer(p); } | 279 void VisitPointer(Object** p) { MarkObjectByPointer(p); } |
| 286 | 280 |
| 287 void VisitPointers(Object** start, Object** end) { | 281 void VisitPointers(Object** start, Object** end) { |
| 288 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); | 282 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); |
| 289 } | 283 } |
| 290 | 284 |
| 291 private: | 285 private: |
| 292 void MarkObjectByPointer(Object** p) { | 286 void MarkObjectByPointer(Object** p) { |
| 293 Object* obj = *p; | 287 Object* obj = *p; |
| 294 if (!obj->IsHeapObject()) return; | 288 if (!obj->IsHeapObject()) return; |
| 295 | 289 |
| 296 HeapObject* heap_object = HeapObject::cast(obj); | 290 IncrementalMarking::MarkObject(heap_, obj); |
| 297 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); | |
| 298 if (mark_bit.data_only()) { | |
| 299 MarkBlackOrKeepGrey(heap_object, mark_bit, heap_object->Size()); | |
| 300 } else { | |
| 301 if (Marking::IsWhite(mark_bit)) { | |
| 302 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit); | |
| 303 } | |
| 304 } | |
| 305 } | 291 } |
| 306 | 292 |
| 307 IncrementalMarking* incremental_marking_; | 293 Heap* heap_; |
| 308 }; | 294 }; |
| 309 | 295 |
| 310 | 296 |
| 311 void IncrementalMarking::Initialize() { | 297 void IncrementalMarking::Initialize() { |
| 312 IncrementalMarkingMarkingVisitor::Initialize(); | 298 IncrementalMarkingMarkingVisitor::Initialize(); |
| 313 } | 299 } |
| 314 | 300 |
| 315 | 301 |
| 316 void IncrementalMarking::SetOldSpacePageFlags(MemoryChunk* chunk, | 302 void IncrementalMarking::SetOldSpacePageFlags(MemoryChunk* chunk, |
| 317 bool is_marking, | 303 bool is_marking, |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); | 618 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); |
| 633 SLOW_DCHECK(Marking::IsGrey(mark_bit) || | 619 SLOW_DCHECK(Marking::IsGrey(mark_bit) || |
| 634 (obj->IsFiller() && Marking::IsWhite(mark_bit)) || | 620 (obj->IsFiller() && Marking::IsWhite(mark_bit)) || |
| 635 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && | 621 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && |
| 636 Marking::IsBlack(mark_bit))); | 622 Marking::IsBlack(mark_bit))); |
| 637 #endif | 623 #endif |
| 638 MarkBlackOrKeepBlack(obj, mark_bit, size); | 624 MarkBlackOrKeepBlack(obj, mark_bit, size); |
| 639 } | 625 } |
| 640 | 626 |
| 641 | 627 |
| 628 void IncrementalMarking::MarkObject(Heap* heap, Object* obj) { |
| 629 HeapObject* heap_object = HeapObject::cast(obj); |
| 630 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); |
| 631 if (mark_bit.data_only()) { |
| 632 MarkBlackOrKeepGrey(heap_object, mark_bit, heap_object->Size()); |
| 633 } else if (Marking::IsWhite(mark_bit)) { |
| 634 heap->incremental_marking()->WhiteToGreyAndPush(heap_object, mark_bit); |
| 635 } |
| 636 } |
| 637 |
| 638 |
| 642 intptr_t IncrementalMarking::ProcessMarkingDeque(intptr_t bytes_to_process) { | 639 intptr_t IncrementalMarking::ProcessMarkingDeque(intptr_t bytes_to_process) { |
| 643 intptr_t bytes_processed = 0; | 640 intptr_t bytes_processed = 0; |
| 644 Map* filler_map = heap_->one_pointer_filler_map(); | 641 Map* filler_map = heap_->one_pointer_filler_map(); |
| 645 MarkingDeque* marking_deque = | 642 MarkingDeque* marking_deque = |
| 646 heap_->mark_compact_collector()->marking_deque(); | 643 heap_->mark_compact_collector()->marking_deque(); |
| 647 while (!marking_deque->IsEmpty() && bytes_processed < bytes_to_process) { | 644 while (!marking_deque->IsEmpty() && bytes_processed < bytes_to_process) { |
| 648 HeapObject* obj = marking_deque->Pop(); | 645 HeapObject* obj = marking_deque->Pop(); |
| 649 | 646 |
| 650 // Explicitly skip one word fillers. Incremental markbit patterns are | 647 // Explicitly skip one word fillers. Incremental markbit patterns are |
| 651 // correct only for objects that occupy at least two words. | 648 // correct only for objects that occupy at least two words. |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1000 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
| 1004 idle_marking_delay_counter_++; | 1001 idle_marking_delay_counter_++; |
| 1005 } | 1002 } |
| 1006 | 1003 |
| 1007 | 1004 |
| 1008 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1005 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1009 idle_marking_delay_counter_ = 0; | 1006 idle_marking_delay_counter_ = 0; |
| 1010 } | 1007 } |
| 1011 } | 1008 } |
| 1012 } // namespace v8::internal | 1009 } // namespace v8::internal |
| OLD | NEW |