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

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

Issue 1325643002: [heap] Fix recursive GCs caused by adjusting externally allocated memory (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
« src/api.cc ('K') | « src/api.cc ('k') | no next file » | 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/heap/heap.h" 5 #include "src/heap/heap.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 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 1793
1794 1794
1795 void Heap::RegisterNewArrayBuffer(bool in_new_space, void* data, 1795 void Heap::RegisterNewArrayBuffer(bool in_new_space, void* data,
1796 size_t length) { 1796 size_t length) {
1797 if (!data) return; 1797 if (!data) return;
1798 RegisterNewArrayBufferHelper(live_array_buffers_, data, length); 1798 RegisterNewArrayBufferHelper(live_array_buffers_, data, length);
1799 if (in_new_space) { 1799 if (in_new_space) {
1800 RegisterNewArrayBufferHelper(live_array_buffers_for_scavenge_, data, 1800 RegisterNewArrayBufferHelper(live_array_buffers_for_scavenge_, data,
1801 length); 1801 length);
1802 } 1802 }
1803
1804 // We may go over the limit of externally allocated memory here. We call the
1805 // api function to trigger a GC in this case.
1803 reinterpret_cast<v8::Isolate*>(isolate_) 1806 reinterpret_cast<v8::Isolate*>(isolate_)
1804 ->AdjustAmountOfExternalAllocatedMemory(length); 1807 ->AdjustAmountOfExternalAllocatedMemory(length);
1805 } 1808 }
1806 1809
1807 1810
1808 void Heap::UnregisterArrayBuffer(bool in_new_space, void* data) { 1811 void Heap::UnregisterArrayBuffer(bool in_new_space, void* data) {
1809 if (!data) return; 1812 if (!data) return;
1810 UnregisterArrayBufferHelper(live_array_buffers_, 1813 UnregisterArrayBufferHelper(live_array_buffers_,
1811 not_yet_discovered_array_buffers_, data); 1814 not_yet_discovered_array_buffers_, data);
1812 if (in_new_space) { 1815 if (in_new_space) {
(...skipping 22 matching lines...) Expand all
1835 } 1838 }
1836 } else { 1839 } else {
1837 for (auto& buffer : not_yet_discovered_array_buffers_) { 1840 for (auto& buffer : not_yet_discovered_array_buffers_) {
1838 // Scavenge can't happend during evacuation, so we only need to update 1841 // Scavenge can't happend during evacuation, so we only need to update
1839 // live_array_buffers_for_scavenge_. 1842 // live_array_buffers_for_scavenge_.
1840 // not_yet_discovered_array_buffers_for_scanvenge_ will be reset before 1843 // not_yet_discovered_array_buffers_for_scanvenge_ will be reset before
1841 // the next scavenge run in PrepareArrayBufferDiscoveryInNewSpace. 1844 // the next scavenge run in PrepareArrayBufferDiscoveryInNewSpace.
1842 live_array_buffers_for_scavenge_.erase(buffer.first); 1845 live_array_buffers_for_scavenge_.erase(buffer.first);
1843 } 1846 }
1844 } 1847 }
1845 size_t freed_memory = FreeDeadArrayBuffersHelper( 1848
1849 // Do not call through the api as this code is triggered while doing a GC.
1850 amount_of_external_allocated_memory_ += FreeDeadArrayBuffersHelper(
1846 isolate_, 1851 isolate_,
1847 from_scavenge ? live_array_buffers_for_scavenge_ : live_array_buffers_, 1852 from_scavenge ? live_array_buffers_for_scavenge_ : live_array_buffers_,
1848 from_scavenge ? not_yet_discovered_array_buffers_for_scavenge_ 1853 from_scavenge ? not_yet_discovered_array_buffers_for_scavenge_
1849 : not_yet_discovered_array_buffers_); 1854 : not_yet_discovered_array_buffers_);
1850 if (freed_memory) {
1851 reinterpret_cast<v8::Isolate*>(isolate_)
1852 ->AdjustAmountOfExternalAllocatedMemory(
1853 -static_cast<int64_t>(freed_memory));
1854 }
1855 } 1855 }
1856 1856
1857 1857
1858 void Heap::TearDownArrayBuffers() { 1858 void Heap::TearDownArrayBuffers() {
1859 TearDownArrayBuffersHelper(isolate_, live_array_buffers_, 1859 TearDownArrayBuffersHelper(isolate_, live_array_buffers_,
1860 not_yet_discovered_array_buffers_); 1860 not_yet_discovered_array_buffers_);
1861 } 1861 }
1862 1862
1863 1863
1864 void Heap::PrepareArrayBufferDiscoveryInNewSpace() { 1864 void Heap::PrepareArrayBufferDiscoveryInNewSpace() {
(...skipping 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after
6774 *object_type = "CODE_TYPE"; \ 6774 *object_type = "CODE_TYPE"; \
6775 *object_sub_type = "CODE_AGE/" #name; \ 6775 *object_sub_type = "CODE_AGE/" #name; \
6776 return true; 6776 return true;
6777 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6777 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6778 #undef COMPARE_AND_RETURN_NAME 6778 #undef COMPARE_AND_RETURN_NAME
6779 } 6779 }
6780 return false; 6780 return false;
6781 } 6781 }
6782 } // namespace internal 6782 } // namespace internal
6783 } // namespace v8 6783 } // namespace v8
OLDNEW
« src/api.cc ('K') | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698