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

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

Issue 1199913002: Keep track of ArrayBuffers based on collector type, not space (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments Created 5 years, 6 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/objects-visiting-inl.h » ('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 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 isolate->array_buffer_allocator()->Free(buffer->first, buffer->second); 1856 isolate->array_buffer_allocator()->Free(buffer->first, buffer->second);
1857 } 1857 }
1858 live_buffers.clear(); 1858 live_buffers.clear();
1859 not_yet_discovered_buffers.clear(); 1859 not_yet_discovered_buffers.clear();
1860 } 1860 }
1861 1861
1862 1862
1863 void Heap::RegisterNewArrayBuffer(bool in_new_space, void* data, 1863 void Heap::RegisterNewArrayBuffer(bool in_new_space, void* data,
1864 size_t length) { 1864 size_t length) {
1865 if (!data) return; 1865 if (!data) return;
1866 RegisterNewArrayBufferHelper( 1866 RegisterNewArrayBufferHelper(live_array_buffers_, data, length);
1867 in_new_space ? live_new_array_buffers_ : live_array_buffers_, data, 1867 if (in_new_space) {
1868 length); 1868 RegisterNewArrayBufferHelper(live_array_buffers_for_scavenge_, data,
1869 length);
1870 }
1869 reinterpret_cast<v8::Isolate*>(isolate_) 1871 reinterpret_cast<v8::Isolate*>(isolate_)
1870 ->AdjustAmountOfExternalAllocatedMemory(length); 1872 ->AdjustAmountOfExternalAllocatedMemory(length);
1871 } 1873 }
1872 1874
1873 1875
1874 void Heap::UnregisterArrayBuffer(bool in_new_space, void* data) { 1876 void Heap::UnregisterArrayBuffer(bool in_new_space, void* data) {
1875 if (!data) return; 1877 if (!data) return;
1876 UnregisterArrayBufferHelper( 1878 UnregisterArrayBufferHelper(live_array_buffers_,
1877 in_new_space ? live_new_array_buffers_ : live_array_buffers_, 1879 not_yet_discovered_array_buffers_, data);
1878 in_new_space ? not_yet_discovered_new_array_buffers_ 1880 if (in_new_space) {
1879 : not_yet_discovered_array_buffers_, 1881 UnregisterArrayBufferHelper(live_array_buffers_for_scavenge_,
1882 not_yet_discovered_array_buffers_for_scavenge_,
1883 data);
1884 }
1885 }
1886
1887
1888 void Heap::RegisterLiveArrayBuffer(bool from_scavenge, void* data) {
1889 // ArrayBuffer might be in the middle of being constructed.
1890 if (data == undefined_value()) return;
1891 RegisterLiveArrayBufferHelper(
1892 from_scavenge ? not_yet_discovered_array_buffers_for_scavenge_
1893 : not_yet_discovered_array_buffers_,
1880 data); 1894 data);
1881 } 1895 }
1882 1896
1883 1897
1884 void Heap::RegisterLiveArrayBuffer(bool in_new_space, void* data) { 1898 void Heap::FreeDeadArrayBuffers(bool from_scavenge) {
1885 // ArrayBuffer might be in the middle of being constructed. 1899 if (from_scavenge) {
1886 if (data == undefined_value()) return; 1900 for (auto& buffer : not_yet_discovered_array_buffers_for_scavenge_) {
1887 RegisterLiveArrayBufferHelper(in_new_space 1901 not_yet_discovered_array_buffers_.erase(buffer.first);
1888 ? not_yet_discovered_new_array_buffers_ 1902 live_array_buffers_.erase(buffer.first);
1889 : not_yet_discovered_array_buffers_, 1903 }
1890 data); 1904 } else {
1891 } 1905 for (auto& buffer : not_yet_discovered_array_buffers_) {
1892 1906 // Scavenge can't happend during evacuation, so we only need to update
1893 1907 // live_array_buffers_for_scavenge_.
1894 void Heap::FreeDeadArrayBuffers(bool in_new_space) { 1908 // not_yet_discovered_array_buffers_for_scanvenge_ will be reset before
1909 // the next scavenge run in PrepareArrayBufferDiscoveryInNewSpace.
1910 live_array_buffers_for_scavenge_.erase(buffer.first);
1911 }
1912 }
1895 size_t freed_memory = FreeDeadArrayBuffersHelper( 1913 size_t freed_memory = FreeDeadArrayBuffersHelper(
1896 isolate_, in_new_space ? live_new_array_buffers_ : live_array_buffers_, 1914 isolate_,
1897 in_new_space ? not_yet_discovered_new_array_buffers_ 1915 from_scavenge ? live_array_buffers_for_scavenge_ : live_array_buffers_,
1898 : not_yet_discovered_array_buffers_); 1916 from_scavenge ? not_yet_discovered_array_buffers_for_scavenge_
1917 : not_yet_discovered_array_buffers_);
1899 if (freed_memory) { 1918 if (freed_memory) {
1900 reinterpret_cast<v8::Isolate*>(isolate_) 1919 reinterpret_cast<v8::Isolate*>(isolate_)
1901 ->AdjustAmountOfExternalAllocatedMemory( 1920 ->AdjustAmountOfExternalAllocatedMemory(
1902 -static_cast<int64_t>(freed_memory)); 1921 -static_cast<int64_t>(freed_memory));
1903 } 1922 }
1904 } 1923 }
1905 1924
1906 1925
1907 void Heap::TearDownArrayBuffers() { 1926 void Heap::TearDownArrayBuffers() {
1908 TearDownArrayBuffersHelper(isolate_, live_array_buffers_, 1927 TearDownArrayBuffersHelper(isolate_, live_array_buffers_,
1909 not_yet_discovered_array_buffers_); 1928 not_yet_discovered_array_buffers_);
1910 TearDownArrayBuffersHelper(isolate_, live_new_array_buffers_,
1911 not_yet_discovered_new_array_buffers_);
1912 } 1929 }
1913 1930
1914 1931
1915 void Heap::PrepareArrayBufferDiscoveryInNewSpace() { 1932 void Heap::PrepareArrayBufferDiscoveryInNewSpace() {
1916 not_yet_discovered_new_array_buffers_ = live_new_array_buffers_; 1933 not_yet_discovered_array_buffers_for_scavenge_ =
1934 live_array_buffers_for_scavenge_;
1917 } 1935 }
1918 1936
1919 1937
1920 void Heap::PromoteArrayBuffer(Object* obj) { 1938 void Heap::PromoteArrayBuffer(Object* obj) {
1921 JSArrayBuffer* buffer = JSArrayBuffer::cast(obj); 1939 JSArrayBuffer* buffer = JSArrayBuffer::cast(obj);
1922 if (buffer->is_external()) return; 1940 if (buffer->is_external()) return;
1923 void* data = buffer->backing_store(); 1941 void* data = buffer->backing_store();
1924 if (!data) return; 1942 if (!data) return;
1925 // ArrayBuffer might be in the middle of being constructed. 1943 // ArrayBuffer might be in the middle of being constructed.
1926 if (data == undefined_value()) return; 1944 if (data == undefined_value()) return;
1927 DCHECK(live_new_array_buffers_.count(data) > 0); 1945 DCHECK(live_array_buffers_for_scavenge_.count(data) > 0);
1928 live_array_buffers_[data] = live_new_array_buffers_[data]; 1946 DCHECK(live_array_buffers_.count(data) > 0);
1929 live_new_array_buffers_.erase(data); 1947 live_array_buffers_for_scavenge_.erase(data);
1930 not_yet_discovered_new_array_buffers_.erase(data); 1948 not_yet_discovered_array_buffers_for_scavenge_.erase(data);
1931 } 1949 }
1932 1950
1933 1951
1934 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) { 1952 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) {
1935 Object* allocation_site_obj = 1953 Object* allocation_site_obj =
1936 VisitWeakList<AllocationSite>(this, allocation_sites_list(), retainer); 1954 VisitWeakList<AllocationSite>(this, allocation_sites_list(), retainer);
1937 set_allocation_sites_list(allocation_site_obj); 1955 set_allocation_sites_list(allocation_site_obj);
1938 } 1956 }
1939 1957
1940 1958
(...skipping 4871 matching lines...) Expand 10 before | Expand all | Expand 10 after
6812 *object_type = "CODE_TYPE"; \ 6830 *object_type = "CODE_TYPE"; \
6813 *object_sub_type = "CODE_AGE/" #name; \ 6831 *object_sub_type = "CODE_AGE/" #name; \
6814 return true; 6832 return true;
6815 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6833 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6816 #undef COMPARE_AND_RETURN_NAME 6834 #undef COMPARE_AND_RETURN_NAME
6817 } 6835 }
6818 return false; 6836 return false;
6819 } 6837 }
6820 } // namespace internal 6838 } // namespace internal
6821 } // namespace v8 6839 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/objects-visiting-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698