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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "api.h" | 8 #include "api.h" |
9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
10 #include "codegen.h" | 10 #include "codegen.h" |
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 Object** start = &external_string_table_.old_space_strings_[0]; | 1674 Object** start = &external_string_table_.old_space_strings_[0]; |
1675 Object** end = start + external_string_table_.old_space_strings_.length(); | 1675 Object** end = start + external_string_table_.old_space_strings_.length(); |
1676 for (Object** p = start; p < end; ++p) *p = updater_func(this, p); | 1676 for (Object** p = start; p < end; ++p) *p = updater_func(this, p); |
1677 } | 1677 } |
1678 | 1678 |
1679 UpdateNewSpaceReferencesInExternalStringTable(updater_func); | 1679 UpdateNewSpaceReferencesInExternalStringTable(updater_func); |
1680 } | 1680 } |
1681 | 1681 |
1682 | 1682 |
1683 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { | 1683 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { |
1684 // We don't record weak slots during marking or scavenges. | 1684 ProcessArrayBuffers(retainer); |
1685 // Instead we do it once when we complete mark-compact cycle. | 1685 ProcessNativeContexts(retainer); |
1686 // Note that write barrier has no effect if we are already in the middle of | |
1687 // compacting mark-sweep cycle and we have to record slots manually. | |
1688 bool record_slots = | |
1689 gc_state() == MARK_COMPACT && | |
1690 mark_compact_collector()->is_compacting(); | |
1691 ProcessArrayBuffers(retainer, record_slots); | |
1692 ProcessNativeContexts(retainer, record_slots); | |
1693 // TODO(mvstanton): AllocationSites only need to be processed during | 1686 // TODO(mvstanton): AllocationSites only need to be processed during |
1694 // MARK_COMPACT, as they live in old space. Verify and address. | 1687 // MARK_COMPACT, as they live in old space. Verify and address. |
1695 ProcessAllocationSites(retainer, record_slots); | 1688 ProcessAllocationSites(retainer); |
1696 } | 1689 } |
1697 | 1690 |
1698 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer, | 1691 |
1699 bool record_slots) { | 1692 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) { |
1700 Object* head = | 1693 Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer); |
1701 VisitWeakList<Context>( | |
1702 this, native_contexts_list(), retainer, record_slots); | |
1703 // Update the head of the list of contexts. | 1694 // Update the head of the list of contexts. |
1704 set_native_contexts_list(head); | 1695 set_native_contexts_list(head); |
1705 } | 1696 } |
1706 | 1697 |
1707 | 1698 |
1708 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer, | 1699 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer) { |
1709 bool record_slots) { | |
1710 Object* array_buffer_obj = | 1700 Object* array_buffer_obj = |
1711 VisitWeakList<JSArrayBuffer>(this, | 1701 VisitWeakList<JSArrayBuffer>(this, array_buffers_list(), retainer); |
1712 array_buffers_list(), | |
1713 retainer, record_slots); | |
1714 set_array_buffers_list(array_buffer_obj); | 1702 set_array_buffers_list(array_buffer_obj); |
1715 } | 1703 } |
1716 | 1704 |
1717 | 1705 |
1718 void Heap::TearDownArrayBuffers() { | 1706 void Heap::TearDownArrayBuffers() { |
1719 Object* undefined = undefined_value(); | 1707 Object* undefined = undefined_value(); |
1720 for (Object* o = array_buffers_list(); o != undefined;) { | 1708 for (Object* o = array_buffers_list(); o != undefined;) { |
1721 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); | 1709 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); |
1722 Runtime::FreeArrayBuffer(isolate(), buffer); | 1710 Runtime::FreeArrayBuffer(isolate(), buffer); |
1723 o = buffer->weak_next(); | 1711 o = buffer->weak_next(); |
1724 } | 1712 } |
1725 set_array_buffers_list(undefined); | 1713 set_array_buffers_list(undefined); |
1726 } | 1714 } |
1727 | 1715 |
1728 | 1716 |
1729 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer, | 1717 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) { |
1730 bool record_slots) { | |
1731 Object* allocation_site_obj = | 1718 Object* allocation_site_obj = |
1732 VisitWeakList<AllocationSite>(this, | 1719 VisitWeakList<AllocationSite>(this, allocation_sites_list(), retainer); |
1733 allocation_sites_list(), | |
1734 retainer, record_slots); | |
1735 set_allocation_sites_list(allocation_site_obj); | 1720 set_allocation_sites_list(allocation_site_obj); |
1736 } | 1721 } |
1737 | 1722 |
1738 | 1723 |
1739 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { | 1724 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { |
1740 DisallowHeapAllocation no_allocation_scope; | 1725 DisallowHeapAllocation no_allocation_scope; |
1741 Object* cur = allocation_sites_list(); | 1726 Object* cur = allocation_sites_list(); |
1742 bool marked = false; | 1727 bool marked = false; |
1743 while (cur->IsAllocationSite()) { | 1728 while (cur->IsAllocationSite()) { |
1744 AllocationSite* casted = AllocationSite::cast(cur); | 1729 AllocationSite* casted = AllocationSite::cast(cur); |
(...skipping 4735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6480 static_cast<int>(object_sizes_last_time_[index])); | 6465 static_cast<int>(object_sizes_last_time_[index])); |
6481 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6466 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6482 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6467 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6483 | 6468 |
6484 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6469 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6485 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6470 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6486 ClearObjectStats(); | 6471 ClearObjectStats(); |
6487 } | 6472 } |
6488 | 6473 |
6489 } } // namespace v8::internal | 6474 } } // namespace v8::internal |
OLD | NEW |