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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 #if defined(V8_MAX_SEMISPACE_SIZE) | 149 #if defined(V8_MAX_SEMISPACE_SIZE) |
150 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 150 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
151 #endif | 151 #endif |
152 | 152 |
153 // Ensure old_generation_size_ is a multiple of kPageSize. | 153 // Ensure old_generation_size_ is a multiple of kPageSize. |
154 DCHECK(MB >= Page::kPageSize); | 154 DCHECK(MB >= Page::kPageSize); |
155 | 155 |
156 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); | 156 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); |
157 set_native_contexts_list(NULL); | 157 set_native_contexts_list(NULL); |
158 set_array_buffers_list(Smi::FromInt(0)); | 158 set_array_buffers_list(Smi::FromInt(0)); |
| 159 set_last_array_buffer_in_list(Smi::FromInt(0)); |
159 set_allocation_sites_list(Smi::FromInt(0)); | 160 set_allocation_sites_list(Smi::FromInt(0)); |
160 set_encountered_weak_collections(Smi::FromInt(0)); | 161 set_encountered_weak_collections(Smi::FromInt(0)); |
161 set_encountered_weak_cells(Smi::FromInt(0)); | 162 set_encountered_weak_cells(Smi::FromInt(0)); |
162 // Put a dummy entry in the remembered pages so we can find the list the | 163 // Put a dummy entry in the remembered pages so we can find the list the |
163 // minidump even if there are no real unmapped pages. | 164 // minidump even if there are no real unmapped pages. |
164 RememberUnmappedPage(NULL, false); | 165 RememberUnmappedPage(NULL, false); |
165 | 166 |
166 ClearObjectStats(true); | 167 ClearObjectStats(true); |
167 } | 168 } |
168 | 169 |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 | 1673 |
1673 | 1674 |
1674 void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) { | 1675 void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) { |
1675 ProcessArrayBuffers(retainer, true); | 1676 ProcessArrayBuffers(retainer, true); |
1676 ProcessNewArrayBufferViews(retainer); | 1677 ProcessNewArrayBufferViews(retainer); |
1677 ProcessNativeContexts(retainer); | 1678 ProcessNativeContexts(retainer); |
1678 } | 1679 } |
1679 | 1680 |
1680 | 1681 |
1681 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) { | 1682 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) { |
1682 Object* head = | 1683 Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer, |
1683 VisitWeakList<Context>(this, native_contexts_list(), retainer, false); | 1684 false, NULL); |
1684 // Update the head of the list of contexts. | 1685 // Update the head of the list of contexts. |
1685 set_native_contexts_list(head); | 1686 set_native_contexts_list(head); |
1686 } | 1687 } |
1687 | 1688 |
1688 | 1689 |
1689 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer, | 1690 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer, |
1690 bool stop_after_young) { | 1691 bool stop_after_young) { |
1691 Object* array_buffer_obj = VisitWeakList<JSArrayBuffer>( | 1692 Object* last_array_buffer = undefined_value(); |
1692 this, array_buffers_list(), retainer, stop_after_young); | 1693 Object* array_buffer_obj = |
| 1694 VisitWeakList<JSArrayBuffer>(this, array_buffers_list(), retainer, |
| 1695 stop_after_young, &last_array_buffer); |
1693 set_array_buffers_list(array_buffer_obj); | 1696 set_array_buffers_list(array_buffer_obj); |
| 1697 set_last_array_buffer_in_list(last_array_buffer); |
1694 | 1698 |
1695 // Verify invariant that young array buffers come before old array buffers | 1699 // Verify invariant that young array buffers come before old array buffers |
1696 // in array buffers list if there was no promotion failure. | 1700 // in array buffers list if there was no promotion failure. |
1697 Object* undefined = undefined_value(); | 1701 Object* undefined = undefined_value(); |
1698 Object* next = array_buffers_list(); | 1702 Object* next = array_buffers_list(); |
1699 bool old_objects_recorded = false; | 1703 bool old_objects_recorded = false; |
1700 if (migration_failure()) return; | 1704 if (migration_failure()) return; |
1701 while (next != undefined) { | 1705 while (next != undefined) { |
1702 if (!old_objects_recorded) { | 1706 if (!old_objects_recorded) { |
1703 old_objects_recorded = !InNewSpace(next); | 1707 old_objects_recorded = !InNewSpace(next); |
1704 } | 1708 } |
1705 CHECK((InNewSpace(next) && !old_objects_recorded) || !InNewSpace(next)); | 1709 CHECK((InNewSpace(next) && !old_objects_recorded) || !InNewSpace(next)); |
1706 next = JSArrayBuffer::cast(next)->weak_next(); | 1710 next = JSArrayBuffer::cast(next)->weak_next(); |
1707 } | 1711 } |
1708 } | 1712 } |
1709 | 1713 |
1710 | 1714 |
1711 void Heap::ProcessNewArrayBufferViews(WeakObjectRetainer* retainer) { | 1715 void Heap::ProcessNewArrayBufferViews(WeakObjectRetainer* retainer) { |
1712 // Retain the list of new space views. | 1716 // Retain the list of new space views. |
1713 Object* typed_array_obj = VisitWeakList<JSArrayBufferView>( | 1717 Object* typed_array_obj = VisitWeakList<JSArrayBufferView>( |
1714 this, new_array_buffer_views_list_, retainer, false); | 1718 this, new_array_buffer_views_list_, retainer, false, NULL); |
1715 set_new_array_buffer_views_list(typed_array_obj); | 1719 set_new_array_buffer_views_list(typed_array_obj); |
1716 | 1720 |
1717 // Some objects in the list may be in old space now. Find them | 1721 // Some objects in the list may be in old space now. Find them |
1718 // and move them to the corresponding array buffer. | 1722 // and move them to the corresponding array buffer. |
1719 Object* view = VisitNewArrayBufferViewsWeakList( | 1723 Object* view = VisitNewArrayBufferViewsWeakList( |
1720 this, new_array_buffer_views_list_, retainer); | 1724 this, new_array_buffer_views_list_, retainer); |
1721 set_new_array_buffer_views_list(view); | 1725 set_new_array_buffer_views_list(view); |
1722 } | 1726 } |
1723 | 1727 |
1724 | 1728 |
1725 void Heap::TearDownArrayBuffers() { | 1729 void Heap::TearDownArrayBuffers() { |
1726 Object* undefined = undefined_value(); | 1730 Object* undefined = undefined_value(); |
1727 for (Object* o = array_buffers_list(); o != undefined;) { | 1731 for (Object* o = array_buffers_list(); o != undefined;) { |
1728 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); | 1732 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); |
1729 Runtime::FreeArrayBuffer(isolate(), buffer); | 1733 Runtime::FreeArrayBuffer(isolate(), buffer); |
1730 o = buffer->weak_next(); | 1734 o = buffer->weak_next(); |
1731 } | 1735 } |
1732 set_array_buffers_list(undefined); | 1736 set_array_buffers_list(undefined); |
1733 } | 1737 } |
1734 | 1738 |
1735 | 1739 |
1736 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) { | 1740 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) { |
1737 Object* allocation_site_obj = VisitWeakList<AllocationSite>( | 1741 Object* allocation_site_obj = VisitWeakList<AllocationSite>( |
1738 this, allocation_sites_list(), retainer, false); | 1742 this, allocation_sites_list(), retainer, false, NULL); |
1739 set_allocation_sites_list(allocation_site_obj); | 1743 set_allocation_sites_list(allocation_site_obj); |
1740 } | 1744 } |
1741 | 1745 |
1742 | 1746 |
1743 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { | 1747 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { |
1744 DisallowHeapAllocation no_allocation_scope; | 1748 DisallowHeapAllocation no_allocation_scope; |
1745 Object* cur = allocation_sites_list(); | 1749 Object* cur = allocation_sites_list(); |
1746 bool marked = false; | 1750 bool marked = false; |
1747 while (cur->IsAllocationSite()) { | 1751 while (cur->IsAllocationSite()) { |
1748 AllocationSite* casted = AllocationSite::cast(cur); | 1752 AllocationSite* casted = AllocationSite::cast(cur); |
(...skipping 3588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5337 // Create initial maps. | 5341 // Create initial maps. |
5338 if (!CreateInitialMaps()) return false; | 5342 if (!CreateInitialMaps()) return false; |
5339 CreateApiObjects(); | 5343 CreateApiObjects(); |
5340 | 5344 |
5341 // Create initial objects | 5345 // Create initial objects |
5342 CreateInitialObjects(); | 5346 CreateInitialObjects(); |
5343 CHECK_EQ(0u, gc_count_); | 5347 CHECK_EQ(0u, gc_count_); |
5344 | 5348 |
5345 set_native_contexts_list(undefined_value()); | 5349 set_native_contexts_list(undefined_value()); |
5346 set_array_buffers_list(undefined_value()); | 5350 set_array_buffers_list(undefined_value()); |
| 5351 set_last_array_buffer_in_list(undefined_value()); |
5347 set_new_array_buffer_views_list(undefined_value()); | 5352 set_new_array_buffer_views_list(undefined_value()); |
5348 set_allocation_sites_list(undefined_value()); | 5353 set_allocation_sites_list(undefined_value()); |
5349 return true; | 5354 return true; |
5350 } | 5355 } |
5351 | 5356 |
5352 | 5357 |
5353 void Heap::SetStackLimits() { | 5358 void Heap::SetStackLimits() { |
5354 DCHECK(isolate_ != NULL); | 5359 DCHECK(isolate_ != NULL); |
5355 DCHECK(isolate_ == isolate()); | 5360 DCHECK(isolate_ == isolate()); |
5356 // On 64 bit machines, pointers are generally out of range of Smis. We write | 5361 // On 64 bit machines, pointers are generally out of range of Smis. We write |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6306 static_cast<int>(object_sizes_last_time_[index])); | 6311 static_cast<int>(object_sizes_last_time_[index])); |
6307 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6312 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6308 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6313 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6309 | 6314 |
6310 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6315 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6311 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6316 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6312 ClearObjectStats(); | 6317 ClearObjectStats(); |
6313 } | 6318 } |
6314 } | 6319 } |
6315 } // namespace v8::internal | 6320 } // namespace v8::internal |
OLD | NEW |