Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: src/heap/heap.cc

Issue 1115043005: Revert of Remove the weak list of array buffers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // easier if you can define it as part of the build environment. 147 // easier if you can define it as part of the build environment.
148 #if defined(V8_MAX_SEMISPACE_SIZE) 148 #if defined(V8_MAX_SEMISPACE_SIZE)
149 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; 149 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
150 #endif 150 #endif
151 151
152 // Ensure old_generation_size_ is a multiple of kPageSize. 152 // Ensure old_generation_size_ is a multiple of kPageSize.
153 DCHECK(MB >= Page::kPageSize); 153 DCHECK(MB >= Page::kPageSize);
154 154
155 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); 155 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
156 set_native_contexts_list(NULL); 156 set_native_contexts_list(NULL);
157 set_array_buffers_list(Smi::FromInt(0));
158 set_last_array_buffer_in_list(Smi::FromInt(0));
157 set_allocation_sites_list(Smi::FromInt(0)); 159 set_allocation_sites_list(Smi::FromInt(0));
158 set_encountered_weak_collections(Smi::FromInt(0)); 160 set_encountered_weak_collections(Smi::FromInt(0));
159 set_encountered_weak_cells(Smi::FromInt(0)); 161 set_encountered_weak_cells(Smi::FromInt(0));
160 // Put a dummy entry in the remembered pages so we can find the list the 162 // Put a dummy entry in the remembered pages so we can find the list the
161 // minidump even if there are no real unmapped pages. 163 // minidump even if there are no real unmapped pages.
162 RememberUnmappedPage(NULL, false); 164 RememberUnmappedPage(NULL, false);
163 165
164 ClearObjectStats(true); 166 ClearObjectStats(true);
165 } 167 }
166 168
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 Object** start = &external_string_table_.old_space_strings_[0]; 1698 Object** start = &external_string_table_.old_space_strings_[0];
1697 Object** end = start + external_string_table_.old_space_strings_.length(); 1699 Object** end = start + external_string_table_.old_space_strings_.length();
1698 for (Object** p = start; p < end; ++p) *p = updater_func(this, p); 1700 for (Object** p = start; p < end; ++p) *p = updater_func(this, p);
1699 } 1701 }
1700 1702
1701 UpdateNewSpaceReferencesInExternalStringTable(updater_func); 1703 UpdateNewSpaceReferencesInExternalStringTable(updater_func);
1702 } 1704 }
1703 1705
1704 1706
1705 void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) { 1707 void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) {
1708 ProcessArrayBuffers(retainer, false);
1706 ProcessNativeContexts(retainer); 1709 ProcessNativeContexts(retainer);
1707 ProcessAllocationSites(retainer); 1710 ProcessAllocationSites(retainer);
1708 } 1711 }
1709 1712
1710 1713
1711 void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) { 1714 void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) {
1715 ProcessArrayBuffers(retainer, true);
1712 ProcessNativeContexts(retainer); 1716 ProcessNativeContexts(retainer);
1713 } 1717 }
1714 1718
1715 1719
1716 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) { 1720 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) {
1717 Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer); 1721 Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer,
1722 false, NULL);
1718 // Update the head of the list of contexts. 1723 // Update the head of the list of contexts.
1719 set_native_contexts_list(head); 1724 set_native_contexts_list(head);
1720 } 1725 }
1721 1726
1722 1727
1723 void Heap::RegisterNewArrayBuffer(void* data, size_t length) { 1728 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer,
1724 live_array_buffers_[data] = length; 1729 bool stop_after_young) {
1725 reinterpret_cast<v8::Isolate*>(isolate_) 1730 Object* last_array_buffer = undefined_value();
1726 ->AdjustAmountOfExternalAllocatedMemory(length); 1731 Object* array_buffer_obj =
1727 } 1732 VisitWeakList<JSArrayBuffer>(this, array_buffers_list(), retainer,
1733 stop_after_young, &last_array_buffer);
1734 set_array_buffers_list(array_buffer_obj);
1735 set_last_array_buffer_in_list(last_array_buffer);
1728 1736
1729 1737 // Verify invariant that young array buffers come before old array buffers
1730 void Heap::UnregisterArrayBuffer(void* data) { 1738 // in array buffers list if there was no promotion failure.
1731 DCHECK(live_array_buffers_.count(data) > 0); 1739 Object* undefined = undefined_value();
1732 live_array_buffers_.erase(data); 1740 Object* next = array_buffers_list();
1733 not_yet_discovered_array_buffers_.erase(data); 1741 bool old_objects_recorded = false;
1734 } 1742 while (next != undefined) {
1735 1743 if (!old_objects_recorded) {
1736 1744 old_objects_recorded = !InNewSpace(next);
1737 void Heap::RegisterLiveArrayBuffer(void* data) { 1745 }
1738 not_yet_discovered_array_buffers_.erase(data); 1746 CHECK((InNewSpace(next) && !old_objects_recorded) || !InNewSpace(next));
1739 } 1747 next = JSArrayBuffer::cast(next)->weak_next();
1740
1741
1742 void Heap::FreeDeadArrayBuffers() {
1743 for (auto buffer = not_yet_discovered_array_buffers_.begin();
1744 buffer != not_yet_discovered_array_buffers_.end(); ++buffer) {
1745 isolate_->array_buffer_allocator()->Free(buffer->first, buffer->second);
1746 // Don't use the API method here since this could trigger another GC.
1747 amount_of_external_allocated_memory_ -= buffer->second;
1748 live_array_buffers_.erase(buffer->first);
1749 } 1748 }
1750 not_yet_discovered_array_buffers_ = live_array_buffers_;
1751 } 1749 }
1752 1750
1753 1751
1754 void Heap::TearDownArrayBuffers() { 1752 void Heap::TearDownArrayBuffers() {
1755 for (auto buffer = live_array_buffers_.begin(); 1753 Object* undefined = undefined_value();
1756 buffer != live_array_buffers_.end(); ++buffer) { 1754 for (Object* o = array_buffers_list(); o != undefined;) {
1757 isolate_->array_buffer_allocator()->Free(buffer->first, buffer->second); 1755 JSArrayBuffer* buffer = JSArrayBuffer::cast(o);
1756 Runtime::FreeArrayBuffer(isolate(), buffer);
1757 o = buffer->weak_next();
1758 } 1758 }
1759 live_array_buffers_.clear(); 1759 set_array_buffers_list(undefined);
1760 not_yet_discovered_array_buffers_.clear();
1761 } 1760 }
1762 1761
1763 1762
1764 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) { 1763 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) {
1765 Object* allocation_site_obj = 1764 Object* allocation_site_obj = VisitWeakList<AllocationSite>(
1766 VisitWeakList<AllocationSite>(this, allocation_sites_list(), retainer); 1765 this, allocation_sites_list(), retainer, false, NULL);
1767 set_allocation_sites_list(allocation_site_obj); 1766 set_allocation_sites_list(allocation_site_obj);
1768 } 1767 }
1769 1768
1770 1769
1771 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { 1770 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) {
1772 DisallowHeapAllocation no_allocation_scope; 1771 DisallowHeapAllocation no_allocation_scope;
1773 Object* cur = allocation_sites_list(); 1772 Object* cur = allocation_sites_list();
1774 bool marked = false; 1773 bool marked = false;
1775 while (cur->IsAllocationSite()) { 1774 while (cur->IsAllocationSite()) {
1776 AllocationSite* casted = AllocationSite::cast(cur); 1775 AllocationSite* casted = AllocationSite::cast(cur);
(...skipping 3624 matching lines...) Expand 10 before | Expand all | Expand 10 after
5401 bool Heap::CreateHeapObjects() { 5400 bool Heap::CreateHeapObjects() {
5402 // Create initial maps. 5401 // Create initial maps.
5403 if (!CreateInitialMaps()) return false; 5402 if (!CreateInitialMaps()) return false;
5404 CreateApiObjects(); 5403 CreateApiObjects();
5405 5404
5406 // Create initial objects 5405 // Create initial objects
5407 CreateInitialObjects(); 5406 CreateInitialObjects();
5408 CHECK_EQ(0u, gc_count_); 5407 CHECK_EQ(0u, gc_count_);
5409 5408
5410 set_native_contexts_list(undefined_value()); 5409 set_native_contexts_list(undefined_value());
5410 set_array_buffers_list(undefined_value());
5411 set_last_array_buffer_in_list(undefined_value());
5411 set_allocation_sites_list(undefined_value()); 5412 set_allocation_sites_list(undefined_value());
5412 return true; 5413 return true;
5413 } 5414 }
5414 5415
5415 5416
5416 void Heap::SetStackLimits() { 5417 void Heap::SetStackLimits() {
5417 DCHECK(isolate_ != NULL); 5418 DCHECK(isolate_ != NULL);
5418 DCHECK(isolate_ == isolate()); 5419 DCHECK(isolate_ == isolate());
5419 // On 64 bit machines, pointers are generally out of range of Smis. We write 5420 // On 64 bit machines, pointers are generally out of range of Smis. We write
5420 // something that looks like an out of range Smi to the GC. 5421 // something that looks like an out of range Smi to the GC.
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
6413 static_cast<int>(object_sizes_last_time_[index])); 6414 static_cast<int>(object_sizes_last_time_[index]));
6414 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6415 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6415 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6416 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6416 6417
6417 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6418 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6418 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6419 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6419 ClearObjectStats(); 6420 ClearObjectStats();
6420 } 6421 }
6421 } 6422 }
6422 } // namespace v8::internal 6423 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698