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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 } | 1633 } |
1634 return NULL; | 1634 return NULL; |
1635 } | 1635 } |
1636 | 1636 |
1637 private: | 1637 private: |
1638 Heap* heap_; | 1638 Heap* heap_; |
1639 }; | 1639 }; |
1640 | 1640 |
1641 | 1641 |
1642 void Heap::Scavenge() { | 1642 void Heap::Scavenge() { |
| 1643 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SCAVENGE); |
1643 RelocationLock relocation_lock(this); | 1644 RelocationLock relocation_lock(this); |
1644 // There are soft limits in the allocation code, designed to trigger a mark | 1645 // There are soft limits in the allocation code, designed to trigger a mark |
1645 // sweep collection by failing allocations. There is no sense in trying to | 1646 // sweep collection by failing allocations. There is no sense in trying to |
1646 // trigger one during scavenge: scavenges allocation should always succeed. | 1647 // trigger one during scavenge: scavenges allocation should always succeed. |
1647 AlwaysAllocateScope scope(isolate()); | 1648 AlwaysAllocateScope scope(isolate()); |
1648 | 1649 |
1649 #ifdef VERIFY_HEAP | 1650 #ifdef VERIFY_HEAP |
1650 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this); | 1651 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this); |
1651 #endif | 1652 #endif |
1652 | 1653 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 // updated as a side effect of promoting an object. | 1685 // updated as a side effect of promoting an object. |
1685 // | 1686 // |
1686 // There is guaranteed to be enough room at the top of the to space | 1687 // There is guaranteed to be enough room at the top of the to space |
1687 // for the addresses of promoted objects: every object promoted | 1688 // for the addresses of promoted objects: every object promoted |
1688 // frees up its size in bytes from the top of the new space, and | 1689 // frees up its size in bytes from the top of the new space, and |
1689 // objects are at least one pointer in size. | 1690 // objects are at least one pointer in size. |
1690 Address new_space_front = new_space_.ToSpaceStart(); | 1691 Address new_space_front = new_space_.ToSpaceStart(); |
1691 promotion_queue_.Initialize(); | 1692 promotion_queue_.Initialize(); |
1692 | 1693 |
1693 ScavengeVisitor scavenge_visitor(this); | 1694 ScavengeVisitor scavenge_visitor(this); |
1694 // Copy roots. | 1695 { |
1695 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); | 1696 // Copy roots. |
| 1697 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_ROOTS); |
| 1698 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); |
| 1699 } |
1696 | 1700 |
1697 // Copy objects reachable from the old generation. | |
1698 { | 1701 { |
| 1702 // Copy objects reachable from the old generation. |
| 1703 GCTracer::Scope gc_scope(tracer(), |
| 1704 GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS); |
1699 StoreBufferRebuildScope scope(this, store_buffer(), | 1705 StoreBufferRebuildScope scope(this, store_buffer(), |
1700 &ScavengeStoreBufferCallback); | 1706 &ScavengeStoreBufferCallback); |
1701 store_buffer()->IteratePointersToNewSpace(&ScavengeObject); | 1707 store_buffer()->IteratePointersToNewSpace(&ScavengeObject); |
1702 } | 1708 } |
1703 | 1709 |
1704 // Copy objects reachable from the encountered weak collections list. | 1710 { |
1705 scavenge_visitor.VisitPointer(&encountered_weak_collections_); | 1711 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_WEAK); |
1706 // Copy objects reachable from the encountered weak cells. | 1712 // Copy objects reachable from the encountered weak collections list. |
1707 scavenge_visitor.VisitPointer(&encountered_weak_cells_); | 1713 scavenge_visitor.VisitPointer(&encountered_weak_collections_); |
1708 | 1714 // Copy objects reachable from the encountered weak cells. |
1709 // Copy objects reachable from the code flushing candidates list. | 1715 scavenge_visitor.VisitPointer(&encountered_weak_cells_); |
1710 MarkCompactCollector* collector = mark_compact_collector(); | |
1711 if (collector->is_code_flushing_enabled()) { | |
1712 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); | |
1713 } | 1716 } |
1714 | 1717 |
1715 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1718 { |
| 1719 // Copy objects reachable from the code flushing candidates list. |
| 1720 GCTracer::Scope gc_scope(tracer(), |
| 1721 GCTracer::Scope::SCAVENGER_CODE_FLUSH_CANDIDATES); |
| 1722 MarkCompactCollector* collector = mark_compact_collector(); |
| 1723 if (collector->is_code_flushing_enabled()) { |
| 1724 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); |
| 1725 } |
| 1726 } |
1716 | 1727 |
1717 while (isolate()->global_handles()->IterateObjectGroups( | 1728 { |
1718 &scavenge_visitor, &IsUnscavengedHeapObject)) { | 1729 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE); |
1719 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1730 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1720 } | 1731 } |
1721 isolate()->global_handles()->RemoveObjectGroups(); | 1732 |
1722 isolate()->global_handles()->RemoveImplicitRefGroups(); | 1733 { |
| 1734 GCTracer::Scope gc_scope(tracer(), |
| 1735 GCTracer::Scope::SCAVENGER_OBJECT_GROUPS); |
| 1736 while (isolate()->global_handles()->IterateObjectGroups( |
| 1737 &scavenge_visitor, &IsUnscavengedHeapObject)) { |
| 1738 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
| 1739 } |
| 1740 isolate()->global_handles()->RemoveObjectGroups(); |
| 1741 isolate()->global_handles()->RemoveImplicitRefGroups(); |
| 1742 } |
1723 | 1743 |
1724 isolate()->global_handles()->IdentifyNewSpaceWeakIndependentHandles( | 1744 isolate()->global_handles()->IdentifyNewSpaceWeakIndependentHandles( |
1725 &IsUnscavengedHeapObject); | 1745 &IsUnscavengedHeapObject); |
1726 | 1746 |
1727 isolate()->global_handles()->IterateNewSpaceWeakIndependentRoots( | 1747 isolate()->global_handles()->IterateNewSpaceWeakIndependentRoots( |
1728 &scavenge_visitor); | 1748 &scavenge_visitor); |
1729 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1749 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1730 | 1750 |
1731 UpdateNewSpaceReferencesInExternalStringTable( | 1751 UpdateNewSpaceReferencesInExternalStringTable( |
1732 &UpdateNewSpaceReferenceInExternalStringTableEntry); | 1752 &UpdateNewSpaceReferenceInExternalStringTableEntry); |
(...skipping 5153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6886 *object_type = "CODE_TYPE"; \ | 6906 *object_type = "CODE_TYPE"; \ |
6887 *object_sub_type = "CODE_AGE/" #name; \ | 6907 *object_sub_type = "CODE_AGE/" #name; \ |
6888 return true; | 6908 return true; |
6889 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6909 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6890 #undef COMPARE_AND_RETURN_NAME | 6910 #undef COMPARE_AND_RETURN_NAME |
6891 } | 6911 } |
6892 return false; | 6912 return false; |
6893 } | 6913 } |
6894 } // namespace internal | 6914 } // namespace internal |
6895 } // namespace v8 | 6915 } // namespace v8 |
OLD | NEW |