OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/array-buffer-tracker.h" | 5 #include "src/heap/array-buffer-tracker.h" |
6 #include "src/heap/array-buffer-tracker-inl.h" | 6 #include "src/heap/array-buffer-tracker-inl.h" |
7 #include "src/heap/heap.h" | 7 #include "src/heap/heap.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 11 matching lines...) Expand all Loading... |
22 Marking::IsWhite(Marking::MarkBitFrom(it->first))) { | 22 Marking::IsWhite(Marking::MarkBitFrom(it->first))) { |
23 heap_->isolate()->array_buffer_allocator()->Free(it->second.first, | 23 heap_->isolate()->array_buffer_allocator()->Free(it->second.first, |
24 it->second.second); | 24 it->second.second); |
25 freed_memory += it->second.second; | 25 freed_memory += it->second.second; |
26 it = array_buffers_.erase(it); | 26 it = array_buffers_.erase(it); |
27 } else { | 27 } else { |
28 it++; | 28 it++; |
29 } | 29 } |
30 } | 30 } |
31 if (freed_memory > 0) { | 31 if (freed_memory > 0) { |
32 heap_->update_amount_of_external_allocated_freed_memory( | 32 heap_->update_external_memory_concurrently_freed( |
33 static_cast<intptr_t>(freed_memory)); | 33 static_cast<intptr_t>(freed_memory)); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 template <typename Callback> | 37 template <typename Callback> |
38 void LocalArrayBufferTracker::Process(Callback callback) { | 38 void LocalArrayBufferTracker::Process(Callback callback) { |
39 JSArrayBuffer* new_buffer = nullptr; | 39 JSArrayBuffer* new_buffer = nullptr; |
40 size_t freed_memory = 0; | 40 size_t freed_memory = 0; |
41 for (TrackingMap::iterator it = array_buffers_.begin(); | 41 for (TrackingMap::iterator it = array_buffers_.begin(); |
42 it != array_buffers_.end();) { | 42 it != array_buffers_.end();) { |
(...skipping 18 matching lines...) Expand all Loading... |
61 } else if (result == kRemoveEntry) { | 61 } else if (result == kRemoveEntry) { |
62 heap_->isolate()->array_buffer_allocator()->Free(it->second.first, | 62 heap_->isolate()->array_buffer_allocator()->Free(it->second.first, |
63 it->second.second); | 63 it->second.second); |
64 freed_memory += it->second.second; | 64 freed_memory += it->second.second; |
65 it = array_buffers_.erase(it); | 65 it = array_buffers_.erase(it); |
66 } else { | 66 } else { |
67 UNREACHABLE(); | 67 UNREACHABLE(); |
68 } | 68 } |
69 } | 69 } |
70 if (freed_memory > 0) { | 70 if (freed_memory > 0) { |
71 heap_->update_amount_of_external_allocated_freed_memory( | 71 heap_->update_external_memory_concurrently_freed( |
72 static_cast<intptr_t>(freed_memory)); | 72 static_cast<intptr_t>(freed_memory)); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void ArrayBufferTracker::FreeDeadInNewSpace(Heap* heap) { | 76 void ArrayBufferTracker::FreeDeadInNewSpace(Heap* heap) { |
77 DCHECK_EQ(heap->gc_state(), Heap::HeapState::SCAVENGE); | 77 DCHECK_EQ(heap->gc_state(), Heap::HeapState::SCAVENGE); |
78 NewSpacePageIterator from_it(heap->new_space()->FromSpaceStart(), | 78 NewSpacePageIterator from_it(heap->new_space()->FromSpaceStart(), |
79 heap->new_space()->FromSpaceEnd()); | 79 heap->new_space()->FromSpaceEnd()); |
80 while (from_it.has_next()) { | 80 while (from_it.has_next()) { |
81 Page* page = from_it.next(); | 81 Page* page = from_it.next(); |
82 bool empty = ProcessBuffers(page, kUpdateForwardedRemoveOthers); | 82 bool empty = ProcessBuffers(page, kUpdateForwardedRemoveOthers); |
83 CHECK(empty); | 83 CHECK(empty); |
84 } | 84 } |
85 heap->account_amount_of_external_allocated_freed_memory(); | 85 heap->account_external_memory_concurrently_freed(); |
86 } | 86 } |
87 | 87 |
88 void ArrayBufferTracker::FreeDead(Page* page) { | 88 void ArrayBufferTracker::FreeDead(Page* page) { |
89 // Callers need to ensure having the page lock. | 89 // Callers need to ensure having the page lock. |
90 LocalArrayBufferTracker* tracker = page->local_tracker(); | 90 LocalArrayBufferTracker* tracker = page->local_tracker(); |
91 if (tracker == nullptr) return; | 91 if (tracker == nullptr) return; |
92 DCHECK(!page->SweepingDone()); | 92 DCHECK(!page->SweepingDone()); |
93 tracker->Free<LocalArrayBufferTracker::kFreeDead>(); | 93 tracker->Free<LocalArrayBufferTracker::kFreeDead>(); |
94 if (tracker->IsEmpty()) { | 94 if (tracker->IsEmpty()) { |
95 page->ReleaseLocalTracker(); | 95 page->ReleaseLocalTracker(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 { | 129 { |
130 base::LockGuard<base::Mutex> guard(page->mutex()); | 130 base::LockGuard<base::Mutex> guard(page->mutex()); |
131 LocalArrayBufferTracker* tracker = page->local_tracker(); | 131 LocalArrayBufferTracker* tracker = page->local_tracker(); |
132 if (tracker == nullptr) return false; | 132 if (tracker == nullptr) return false; |
133 return tracker->IsTracked(buffer); | 133 return tracker->IsTracked(buffer); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 } // namespace internal | 137 } // namespace internal |
138 } // namespace v8 | 138 } // namespace v8 |
OLD | NEW |