summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/array-buffer-collector.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/heap/array-buffer-collector.cc')
-rw-r--r--deps/v8/src/heap/array-buffer-collector.cc25
1 files changed, 7 insertions, 18 deletions
diff --git a/deps/v8/src/heap/array-buffer-collector.cc b/deps/v8/src/heap/array-buffer-collector.cc
index b6d7df8191..672d5e68f0 100644
--- a/deps/v8/src/heap/array-buffer-collector.cc
+++ b/deps/v8/src/heap/array-buffer-collector.cc
@@ -14,33 +14,22 @@
namespace v8 {
namespace internal {
-namespace {
-
-void FreeAllocationsHelper(
- Heap* heap, const std::vector<JSArrayBuffer::Allocation>& allocations) {
- for (JSArrayBuffer::Allocation alloc : allocations) {
- JSArrayBuffer::FreeBackingStore(heap->isolate(), alloc);
- }
-}
-
-} // namespace
-
void ArrayBufferCollector::QueueOrFreeGarbageAllocations(
- std::vector<JSArrayBuffer::Allocation> allocations) {
+ std::vector<std::shared_ptr<BackingStore>> backing_stores) {
if (heap_->ShouldReduceMemory()) {
- FreeAllocationsHelper(heap_, allocations);
+ // Destruct the vector, which destructs the std::shared_ptrs, freeing
+ // the backing stores.
+ backing_stores.clear();
} else {
base::MutexGuard guard(&allocations_mutex_);
- allocations_.push_back(std::move(allocations));
+ allocations_.push_back(std::move(backing_stores));
}
}
void ArrayBufferCollector::PerformFreeAllocations() {
base::MutexGuard guard(&allocations_mutex_);
- for (const std::vector<JSArrayBuffer::Allocation>& allocations :
- allocations_) {
- FreeAllocationsHelper(heap_, allocations);
- }
+ // Destruct the vector, which destructs the vecotr of std::shared_ptrs,
+ // freeing the backing stores if their refcount drops to zero.
allocations_.clear();
}