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

Unified Diff: src/heap/array-buffer-tracker-inl.h

Issue 2122603004: [heap] Track length for array buffers to avoid free-ing dependency (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix exception Created 4 years, 5 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.cc ('k') | test/mjsunit/regress/regress-625752.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/array-buffer-tracker-inl.h
diff --git a/src/heap/array-buffer-tracker-inl.h b/src/heap/array-buffer-tracker-inl.h
index a6a0f54a0900f6b9eac96feafacfc0a44576f542..27c593d0f073e9d35e7b1a97da65da5473b64aef 100644
--- a/src/heap/array-buffer-tracker-inl.h
+++ b/src/heap/array-buffer-tracker-inl.h
@@ -24,7 +24,7 @@ void ArrayBufferTracker::RegisterNew(Heap* heap, JSArrayBuffer* buffer) {
tracker = page->local_tracker();
}
DCHECK_NOT_NULL(tracker);
- tracker->Add(buffer);
+ tracker->Add(buffer, length);
}
// We may go over the limit of externally allocated memory here. We call the
// api function to trigger a GC in this case.
@@ -37,29 +37,31 @@ void ArrayBufferTracker::Unregister(Heap* heap, JSArrayBuffer* buffer) {
if (!data) return;
Page* page = Page::FromAddress(buffer->address());
- size_t length = NumberToSize(heap->isolate(), buffer->byte_length());
+ size_t length = 0;
{
base::LockGuard<base::Mutex> guard(page->mutex());
LocalArrayBufferTracker* tracker = page->local_tracker();
DCHECK_NOT_NULL(tracker);
- tracker->Remove(buffer);
+ length = tracker->Remove(buffer);
}
heap->update_external_memory(-static_cast<intptr_t>(length));
}
-void LocalArrayBufferTracker::Add(Key key) {
- auto ret = array_buffers_.insert(key);
+void LocalArrayBufferTracker::Add(Key key, const Value& value) {
+ auto ret = array_buffers_.insert(std::make_pair(key, value));
USE(ret);
// Check that we indeed inserted a new value and did not overwrite an existing
// one (which would be a bug).
DCHECK(ret.second);
}
-void LocalArrayBufferTracker::Remove(Key key) {
+LocalArrayBufferTracker::Value LocalArrayBufferTracker::Remove(Key key) {
TrackingData::iterator it = array_buffers_.find(key);
// Check that we indeed find a key to remove.
DCHECK(it != array_buffers_.end());
+ Value value = it->second;
array_buffers_.erase(it);
+ return value;
}
} // namespace internal
« no previous file with comments | « src/heap/array-buffer-tracker.cc ('k') | test/mjsunit/regress/regress-625752.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698