Index: src/heap/array-buffer-tracker.cc |
diff --git a/src/heap/array-buffer-tracker.cc b/src/heap/array-buffer-tracker.cc |
index 65bf3ec61e87322e22bb7aa320d92a4d521ae303..a870b35ec50fa5db2b0c7adc23e9a3ef58859e70 100644 |
--- a/src/heap/array-buffer-tracker.cc |
+++ b/src/heap/array-buffer-tracker.cc |
@@ -16,18 +16,16 @@ |
template <LocalArrayBufferTracker::FreeMode free_mode> |
void LocalArrayBufferTracker::Free() { |
size_t freed_memory = 0; |
- for (TrackingData::iterator it = array_buffers_.begin(); |
+ for (TrackingMap::iterator it = array_buffers_.begin(); |
it != array_buffers_.end();) { |
- JSArrayBuffer* buffer = reinterpret_cast<JSArrayBuffer*>(*it); |
if ((free_mode == kFreeAll) || |
- 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; |
+ Marking::IsWhite(Marking::MarkBitFrom(it->first))) { |
+ heap_->isolate()->array_buffer_allocator()->Free(it->second.first, |
+ it->second.second); |
+ freed_memory += it->second.second; |
it = array_buffers_.erase(it); |
} else { |
- ++it; |
+ it++; |
} |
} |
if (freed_memory > 0) { |
@@ -40,11 +38,11 @@ |
void LocalArrayBufferTracker::Process(Callback callback) { |
JSArrayBuffer* new_buffer = nullptr; |
size_t freed_memory = 0; |
- for (TrackingData::iterator it = array_buffers_.begin(); |
+ for (TrackingMap::iterator it = array_buffers_.begin(); |
it != array_buffers_.end();) { |
- const CallbackResult result = callback(*it, &new_buffer); |
+ const CallbackResult result = callback(it->first, &new_buffer); |
if (result == kKeepEntry) { |
- ++it; |
+ it++; |
} else if (result == kUpdateEntry) { |
DCHECK_NOT_NULL(new_buffer); |
Page* target_page = Page::FromAddress(new_buffer->address()); |
@@ -57,14 +55,13 @@ |
tracker = target_page->local_tracker(); |
} |
DCHECK_NOT_NULL(tracker); |
- tracker->Add(new_buffer); |
+ tracker->Add(new_buffer, it->second); |
if (target_page->InNewSpace()) target_page->mutex()->Unlock(); |
it = array_buffers_.erase(it); |
} else if (result == kRemoveEntry) { |
- const size_t len = NumberToSize(heap_->isolate(), (*it)->byte_length()); |
- heap_->isolate()->array_buffer_allocator()->Free((*it)->backing_store(), |
- len); |
- freed_memory += len; |
+ heap_->isolate()->array_buffer_allocator()->Free(it->second.first, |
+ it->second.second); |
+ freed_memory += it->second.second; |
it = array_buffers_.erase(it); |
} else { |
UNREACHABLE(); |