| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "compilation-cache.h" | 30 #include "compilation-cache.h" |
| 31 #include "execution.h" | 31 #include "execution.h" |
| 32 #include "heap-profiler.h" | 32 #include "heap-profiler.h" |
| 33 #include "gdb-jit.h" |
| 33 #include "global-handles.h" | 34 #include "global-handles.h" |
| 34 #include "ic-inl.h" | 35 #include "ic-inl.h" |
| 36 #include "liveobjectlist-inl.h" |
| 35 #include "mark-compact.h" | 37 #include "mark-compact.h" |
| 36 #include "objects-visiting.h" | 38 #include "objects-visiting.h" |
| 37 #include "stub-cache.h" | 39 #include "stub-cache.h" |
| 38 | 40 |
| 39 namespace v8 { | 41 namespace v8 { |
| 40 namespace internal { | 42 namespace internal { |
| 41 | 43 |
| 42 // ------------------------------------------------------------------------- | 44 // ------------------------------------------------------------------------- |
| 43 // MarkCompactCollector | 45 // MarkCompactCollector |
| 44 | 46 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 ASSERT(!FLAG_always_compact || !FLAG_never_compact); | 170 ASSERT(!FLAG_always_compact || !FLAG_never_compact); |
| 169 | 171 |
| 170 compacting_collection_ = | 172 compacting_collection_ = |
| 171 FLAG_always_compact || force_compaction_ || compact_on_next_gc_; | 173 FLAG_always_compact || force_compaction_ || compact_on_next_gc_; |
| 172 compact_on_next_gc_ = false; | 174 compact_on_next_gc_ = false; |
| 173 | 175 |
| 174 if (FLAG_never_compact) compacting_collection_ = false; | 176 if (FLAG_never_compact) compacting_collection_ = false; |
| 175 if (!Heap::map_space()->MapPointersEncodable()) | 177 if (!Heap::map_space()->MapPointersEncodable()) |
| 176 compacting_collection_ = false; | 178 compacting_collection_ = false; |
| 177 if (FLAG_collect_maps) CreateBackPointers(); | 179 if (FLAG_collect_maps) CreateBackPointers(); |
| 180 #ifdef ENABLE_GDB_JIT_INTERFACE |
| 181 if (FLAG_gdbjit) { |
| 182 // If GDBJIT interface is active disable compaction. |
| 183 compacting_collection_ = false; |
| 184 } |
| 185 #endif |
| 178 | 186 |
| 179 PagedSpaces spaces; | 187 PagedSpaces spaces; |
| 180 for (PagedSpace* space = spaces.next(); | 188 for (PagedSpace* space = spaces.next(); |
| 181 space != NULL; space = spaces.next()) { | 189 space != NULL; space = spaces.next()) { |
| 182 space->PrepareForMarkCompact(compacting_collection_); | 190 space->PrepareForMarkCompact(compacting_collection_); |
| 183 } | 191 } |
| 184 | 192 |
| 185 Address new_space_top = Heap::new_space()->top(); | 193 Address new_space_top = Heap::new_space()->top(); |
| 186 Address new_space_bottom = Heap::new_space()->bottom(); | 194 Address new_space_bottom = Heap::new_space()->bottom(); |
| 187 | 195 |
| (...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 | 1681 |
| 1674 // Promotion failed. Just migrate object to another semispace. | 1682 // Promotion failed. Just migrate object to another semispace. |
| 1675 // Allocation cannot fail at this point: semispaces are of equal size. | 1683 // Allocation cannot fail at this point: semispaces are of equal size. |
| 1676 Object* target = space->AllocateRaw(size)->ToObjectUnchecked(); | 1684 Object* target = space->AllocateRaw(size)->ToObjectUnchecked(); |
| 1677 | 1685 |
| 1678 MigrateObject(HeapObject::cast(target)->address(), | 1686 MigrateObject(HeapObject::cast(target)->address(), |
| 1679 current, | 1687 current, |
| 1680 size, | 1688 size, |
| 1681 false); | 1689 false); |
| 1682 } else { | 1690 } else { |
| 1691 // Process the dead object before we write a NULL into its header. |
| 1692 LiveObjectList::ProcessNonLive(object); |
| 1693 |
| 1683 size = object->Size(); | 1694 size = object->Size(); |
| 1684 // Mark dead objects in the new space with null in their map field. | 1695 // Mark dead objects in the new space with null in their map field. |
| 1685 Memory::Address_at(current) = NULL; | 1696 Memory::Address_at(current) = NULL; |
| 1686 } | 1697 } |
| 1687 } | 1698 } |
| 1688 | 1699 |
| 1689 // Second pass: find pointers to new space and update them. | 1700 // Second pass: find pointers to new space and update them. |
| 1690 PointersToNewGenUpdatingVisitor updating_visitor; | 1701 PointersToNewGenUpdatingVisitor updating_visitor; |
| 1691 | 1702 |
| 1692 // Update pointers in to space. | 1703 // Update pointers in to space. |
| 1693 Address current = space->bottom(); | 1704 Address current = space->bottom(); |
| 1694 while (current < space->top()) { | 1705 while (current < space->top()) { |
| 1695 HeapObject* object = HeapObject::FromAddress(current); | 1706 HeapObject* object = HeapObject::FromAddress(current); |
| 1696 current += | 1707 current += |
| 1697 StaticPointersToNewGenUpdatingVisitor::IterateBody(object->map(), | 1708 StaticPointersToNewGenUpdatingVisitor::IterateBody(object->map(), |
| 1698 object); | 1709 object); |
| 1699 } | 1710 } |
| 1700 | 1711 |
| 1701 // Update roots. | 1712 // Update roots. |
| 1702 Heap::IterateRoots(&updating_visitor, VISIT_ALL_IN_SCAVENGE); | 1713 Heap::IterateRoots(&updating_visitor, VISIT_ALL_IN_SCAVENGE); |
| 1714 LiveObjectList::IterateElements(&updating_visitor); |
| 1703 | 1715 |
| 1704 { | 1716 { |
| 1705 StoreBufferRebuildScope scope; | 1717 StoreBufferRebuildScope scope; |
| 1706 StoreBuffer::IteratePointersToNewSpace(&UpdatePointerToNewGen); | 1718 StoreBuffer::IteratePointersToNewSpace(&UpdatePointerToNewGen); |
| 1707 } | 1719 } |
| 1708 | 1720 |
| 1709 // Update pointers from cells. | 1721 // Update pointers from cells. |
| 1710 HeapObjectIterator cell_iterator(Heap::cell_space()); | 1722 HeapObjectIterator cell_iterator(Heap::cell_space()); |
| 1711 for (HeapObject* cell = cell_iterator.next(); | 1723 for (HeapObject* cell = cell_iterator.next(); |
| 1712 cell != NULL; | 1724 cell != NULL; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2096 Page* p = it.next(); | 2108 Page* p = it.next(); |
| 2097 total += IterateLiveObjectsInRange(p->ObjectAreaStart(), | 2109 total += IterateLiveObjectsInRange(p->ObjectAreaStart(), |
| 2098 p->AllocationTop(), | 2110 p->AllocationTop(), |
| 2099 size_f); | 2111 size_f); |
| 2100 } | 2112 } |
| 2101 return total; | 2113 return total; |
| 2102 } | 2114 } |
| 2103 | 2115 |
| 2104 | 2116 |
| 2105 void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj) { | 2117 void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj) { |
| 2118 #ifdef ENABLE_GDB_JIT_INTERFACE |
| 2119 if (obj->IsCode()) { |
| 2120 GDBJITInterface::RemoveCode(reinterpret_cast<Code*>(obj)); |
| 2121 } |
| 2122 #endif |
| 2106 #ifdef ENABLE_LOGGING_AND_PROFILING | 2123 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 2107 if (obj->IsCode()) { | 2124 if (obj->IsCode()) { |
| 2108 PROFILE(CodeDeleteEvent(obj->address())); | 2125 PROFILE(CodeDeleteEvent(obj->address())); |
| 2109 } else if (obj->IsJSFunction()) { | 2126 } else if (obj->IsJSFunction()) { |
| 2110 // TODO(gc): we are sweeping old pointer space conservatively thus | 2127 // TODO(gc): we are sweeping old pointer space conservatively thus |
| 2111 // we can't notify attached profiler about death of functions. | 2128 // we can't notify attached profiler about death of functions. |
| 2112 // Consider disabling conservative sweeping when profiler | 2129 // Consider disabling conservative sweeping when profiler |
| 2113 // is enabled. | 2130 // is enabled. |
| 2114 PROFILE(FunctionDeleteEvent(obj->address())); | 2131 PROFILE(FunctionDeleteEvent(obj->address())); |
| 2115 } | 2132 } |
| 2116 #endif | 2133 #endif |
| 2117 } | 2134 } |
| 2118 | 2135 |
| 2119 | 2136 |
| 2120 void MarkCompactCollector::Initialize() { | 2137 void MarkCompactCollector::Initialize() { |
| 2121 StaticPointersToNewGenUpdatingVisitor::Initialize(); | 2138 StaticPointersToNewGenUpdatingVisitor::Initialize(); |
| 2122 StaticMarkingVisitor::Initialize(); | 2139 StaticMarkingVisitor::Initialize(); |
| 2123 } | 2140 } |
| 2124 | 2141 |
| 2125 | 2142 |
| 2126 } } // namespace v8::internal | 2143 } } // namespace v8::internal |
| OLD | NEW |