| 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/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 bool MarkCompactCollector::IsSweepingCompleted() { | 596 bool MarkCompactCollector::IsSweepingCompleted() { |
| 597 if (!pending_sweeper_tasks_semaphore_.WaitFor( | 597 if (!pending_sweeper_tasks_semaphore_.WaitFor( |
| 598 base::TimeDelta::FromSeconds(0))) { | 598 base::TimeDelta::FromSeconds(0))) { |
| 599 return false; | 599 return false; |
| 600 } | 600 } |
| 601 pending_sweeper_tasks_semaphore_.Signal(); | 601 pending_sweeper_tasks_semaphore_.Signal(); |
| 602 return true; | 602 return true; |
| 603 } | 603 } |
| 604 | 604 |
| 605 | 605 |
| 606 void Marking::TransferMark(Heap* heap, Address old_start, Address new_start) { | |
| 607 // This is only used when resizing an object. | |
| 608 DCHECK(MemoryChunk::FromAddress(old_start) == | |
| 609 MemoryChunk::FromAddress(new_start)); | |
| 610 | |
| 611 if (!heap->incremental_marking()->IsMarking()) return; | |
| 612 | |
| 613 // If the mark doesn't move, we don't check the color of the object. | |
| 614 // It doesn't matter whether the object is black, since it hasn't changed | |
| 615 // size, so the adjustment to the live data count will be zero anyway. | |
| 616 if (old_start == new_start) return; | |
| 617 | |
| 618 MarkBit new_mark_bit = MarkBitFrom(new_start); | |
| 619 MarkBit old_mark_bit = MarkBitFrom(old_start); | |
| 620 | |
| 621 #ifdef DEBUG | |
| 622 ObjectColor old_color = Color(old_mark_bit); | |
| 623 #endif | |
| 624 | |
| 625 if (Marking::IsBlack(old_mark_bit)) { | |
| 626 Marking::BlackToWhite(old_mark_bit); | |
| 627 Marking::MarkBlack(new_mark_bit); | |
| 628 return; | |
| 629 } else if (Marking::IsGrey(old_mark_bit)) { | |
| 630 Marking::GreyToWhite(old_mark_bit); | |
| 631 heap->incremental_marking()->WhiteToGreyAndPush( | |
| 632 HeapObject::FromAddress(new_start), new_mark_bit); | |
| 633 heap->incremental_marking()->RestartIfNotMarking(); | |
| 634 } | |
| 635 | |
| 636 #ifdef DEBUG | |
| 637 ObjectColor new_color = Color(new_mark_bit); | |
| 638 DCHECK(new_color == old_color); | |
| 639 #endif | |
| 640 } | |
| 641 | |
| 642 | |
| 643 const char* AllocationSpaceName(AllocationSpace space) { | 606 const char* AllocationSpaceName(AllocationSpace space) { |
| 644 switch (space) { | 607 switch (space) { |
| 645 case NEW_SPACE: | 608 case NEW_SPACE: |
| 646 return "NEW_SPACE"; | 609 return "NEW_SPACE"; |
| 647 case OLD_SPACE: | 610 case OLD_SPACE: |
| 648 return "OLD_SPACE"; | 611 return "OLD_SPACE"; |
| 649 case CODE_SPACE: | 612 case CODE_SPACE: |
| 650 return "CODE_SPACE"; | 613 return "CODE_SPACE"; |
| 651 case MAP_SPACE: | 614 case MAP_SPACE: |
| 652 return "MAP_SPACE"; | 615 return "MAP_SPACE"; |
| (...skipping 3834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4487 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4450 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 4488 if (Marking::IsBlack(mark_bit)) { | 4451 if (Marking::IsBlack(mark_bit)) { |
| 4489 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4452 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
| 4490 RecordRelocSlot(&rinfo, target); | 4453 RecordRelocSlot(&rinfo, target); |
| 4491 } | 4454 } |
| 4492 } | 4455 } |
| 4493 } | 4456 } |
| 4494 | 4457 |
| 4495 } // namespace internal | 4458 } // namespace internal |
| 4496 } // namespace v8 | 4459 } // namespace v8 |
| OLD | NEW |