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

Unified Diff: src/heap/array-buffer-tracker.cc

Issue 2107443002: [heap] Optimize ArrayBuffer tracking (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove rehashing logic Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/array-buffer-tracker.h ('k') | src/heap/array-buffer-tracker-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/array-buffer-tracker.cc
diff --git a/src/heap/array-buffer-tracker.cc b/src/heap/array-buffer-tracker.cc
index a870b35ec50fa5db2b0c7adc23e9a3ef58859e70..65bf3ec61e87322e22bb7aa320d92a4d521ae303 100644
--- a/src/heap/array-buffer-tracker.cc
+++ b/src/heap/array-buffer-tracker.cc
@@ -16,16 +16,18 @@ LocalArrayBufferTracker::~LocalArrayBufferTracker() {
template <LocalArrayBufferTracker::FreeMode free_mode>
void LocalArrayBufferTracker::Free() {
size_t freed_memory = 0;
- for (TrackingMap::iterator it = array_buffers_.begin();
+ for (TrackingData::iterator it = array_buffers_.begin();
it != array_buffers_.end();) {
+ JSArrayBuffer* buffer = reinterpret_cast<JSArrayBuffer*>(*it);
if ((free_mode == kFreeAll) ||
- Marking::IsWhite(Marking::MarkBitFrom(it->first))) {
- heap_->isolate()->array_buffer_allocator()->Free(it->second.first,
- it->second.second);
- freed_memory += it->second.second;
+ Marking::IsWhite(Marking::MarkBitFrom(buffer))) {
+ const size_t len = NumberToSize(heap_->isolate(), buffer->byte_length());
+ heap_->isolate()->array_buffer_allocator()->Free(buffer->backing_store(),
+ len);
+ freed_memory += len;
it = array_buffers_.erase(it);
} else {
- it++;
+ ++it;
}
}
if (freed_memory > 0) {
@@ -38,11 +40,11 @@ template <typename Callback>
void LocalArrayBufferTracker::Process(Callback callback) {
JSArrayBuffer* new_buffer = nullptr;
size_t freed_memory = 0;
- for (TrackingMap::iterator it = array_buffers_.begin();
+ for (TrackingData::iterator it = array_buffers_.begin();
it != array_buffers_.end();) {
- const CallbackResult result = callback(it->first, &new_buffer);
+ const CallbackResult result = callback(*it, &new_buffer);
if (result == kKeepEntry) {
- it++;
+ ++it;
} else if (result == kUpdateEntry) {
DCHECK_NOT_NULL(new_buffer);
Page* target_page = Page::FromAddress(new_buffer->address());
@@ -55,13 +57,14 @@ void LocalArrayBufferTracker::Process(Callback callback) {
tracker = target_page->local_tracker();
}
DCHECK_NOT_NULL(tracker);
- tracker->Add(new_buffer, it->second);
+ tracker->Add(new_buffer);
if (target_page->InNewSpace()) target_page->mutex()->Unlock();
it = array_buffers_.erase(it);
} else if (result == kRemoveEntry) {
- heap_->isolate()->array_buffer_allocator()->Free(it->second.first,
- it->second.second);
- freed_memory += it->second.second;
+ const size_t len = NumberToSize(heap_->isolate(), (*it)->byte_length());
+ heap_->isolate()->array_buffer_allocator()->Free((*it)->backing_store(),
+ len);
+ freed_memory += len;
it = array_buffers_.erase(it);
} else {
UNREACHABLE();
« no previous file with comments | « src/heap/array-buffer-tracker.h ('k') | src/heap/array-buffer-tracker-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698