| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 heap_object->Size()); | 331 heap_object->Size()); |
| 332 return true; | 332 return true; |
| 333 } | 333 } |
| 334 return false; | 334 return false; |
| 335 } | 335 } |
| 336 }; | 336 }; |
| 337 | 337 |
| 338 | 338 |
| 339 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor { | 339 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor { |
| 340 public: | 340 public: |
| 341 IncrementalMarkingRootMarkingVisitor(Heap* heap, | 341 explicit IncrementalMarkingRootMarkingVisitor( |
| 342 IncrementalMarking* incremental_marking) | 342 IncrementalMarking* incremental_marking) |
| 343 : heap_(heap), | 343 : incremental_marking_(incremental_marking) { |
| 344 incremental_marking_(incremental_marking) { | |
| 345 } | 344 } |
| 346 | 345 |
| 347 void VisitPointer(Object** p) { | 346 void VisitPointer(Object** p) { |
| 348 MarkObjectByPointer(p); | 347 MarkObjectByPointer(p); |
| 349 } | 348 } |
| 350 | 349 |
| 351 void VisitPointers(Object** start, Object** end) { | 350 void VisitPointers(Object** start, Object** end) { |
| 352 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); | 351 for (Object** p = start; p < end; p++) MarkObjectByPointer(p); |
| 353 } | 352 } |
| 354 | 353 |
| 355 private: | 354 private: |
| 356 void MarkObjectByPointer(Object** p) { | 355 void MarkObjectByPointer(Object** p) { |
| 357 Object* obj = *p; | 356 Object* obj = *p; |
| 358 if (!obj->IsHeapObject()) return; | 357 if (!obj->IsHeapObject()) return; |
| 359 | 358 |
| 360 HeapObject* heap_object = HeapObject::cast(obj); | 359 HeapObject* heap_object = HeapObject::cast(obj); |
| 361 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); | 360 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); |
| 362 if (mark_bit.data_only()) { | 361 if (mark_bit.data_only()) { |
| 363 MarkBlackOrKeepGrey(heap_object, mark_bit, heap_object->Size()); | 362 MarkBlackOrKeepGrey(heap_object, mark_bit, heap_object->Size()); |
| 364 } else { | 363 } else { |
| 365 if (Marking::IsWhite(mark_bit)) { | 364 if (Marking::IsWhite(mark_bit)) { |
| 366 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit); | 365 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit); |
| 367 } | 366 } |
| 368 } | 367 } |
| 369 } | 368 } |
| 370 | 369 |
| 371 Heap* heap_; | |
| 372 IncrementalMarking* incremental_marking_; | 370 IncrementalMarking* incremental_marking_; |
| 373 }; | 371 }; |
| 374 | 372 |
| 375 | 373 |
| 376 void IncrementalMarking::Initialize() { | 374 void IncrementalMarking::Initialize() { |
| 377 IncrementalMarkingMarkingVisitor::Initialize(); | 375 IncrementalMarkingMarkingVisitor::Initialize(); |
| 378 } | 376 } |
| 379 | 377 |
| 380 | 378 |
| 381 void IncrementalMarking::SetOldSpacePageFlags(MemoryChunk* chunk, | 379 void IncrementalMarking::SetOldSpacePageFlags(MemoryChunk* chunk, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 heap_->CompletelyClearInstanceofCache(); | 619 heap_->CompletelyClearInstanceofCache(); |
| 622 heap_->isolate()->compilation_cache()->MarkCompactPrologue(); | 620 heap_->isolate()->compilation_cache()->MarkCompactPrologue(); |
| 623 | 621 |
| 624 if (FLAG_cleanup_code_caches_at_gc) { | 622 if (FLAG_cleanup_code_caches_at_gc) { |
| 625 // We will mark cache black with a separate pass | 623 // We will mark cache black with a separate pass |
| 626 // when we finish marking. | 624 // when we finish marking. |
| 627 MarkObjectGreyDoNotEnqueue(heap_->polymorphic_code_cache()); | 625 MarkObjectGreyDoNotEnqueue(heap_->polymorphic_code_cache()); |
| 628 } | 626 } |
| 629 | 627 |
| 630 // Mark strong roots grey. | 628 // Mark strong roots grey. |
| 631 IncrementalMarkingRootMarkingVisitor visitor(heap_, this); | 629 IncrementalMarkingRootMarkingVisitor visitor(this); |
| 632 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); | 630 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); |
| 633 | 631 |
| 634 // Ready to start incremental marking. | 632 // Ready to start incremental marking. |
| 635 if (FLAG_trace_incremental_marking) { | 633 if (FLAG_trace_incremental_marking) { |
| 636 PrintF("[IncrementalMarking] Running\n"); | 634 PrintF("[IncrementalMarking] Running\n"); |
| 637 } | 635 } |
| 638 } | 636 } |
| 639 | 637 |
| 640 | 638 |
| 641 void IncrementalMarking::PrepareForScavenge() { | 639 void IncrementalMarking::PrepareForScavenge() { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 bytes_scanned_ = 0; | 993 bytes_scanned_ = 0; |
| 996 write_barriers_invoked_since_last_step_ = 0; | 994 write_barriers_invoked_since_last_step_ = 0; |
| 997 } | 995 } |
| 998 | 996 |
| 999 | 997 |
| 1000 int64_t IncrementalMarking::SpaceLeftInOldSpace() { | 998 int64_t IncrementalMarking::SpaceLeftInOldSpace() { |
| 1001 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); | 999 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); |
| 1002 } | 1000 } |
| 1003 | 1001 |
| 1004 } } // namespace v8::internal | 1002 } } // namespace v8::internal |
| OLD | NEW |