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

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

Issue 2085893002: [heap] Internalize kExternalAllocationLimit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Initialize limit 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 unified diff | Download patch
« no previous file with comments | « src/heap/array-buffer-tracker.cc ('k') | src/heap/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/conversions-inl.h" 5 #include "src/conversions-inl.h"
6 #include "src/heap/array-buffer-tracker.h" 6 #include "src/heap/array-buffer-tracker.h"
7 #include "src/heap/heap.h" 7 #include "src/heap/heap.h"
8 #include "src/objects.h" 8 #include "src/objects.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 26 matching lines...) Expand all
37 if (!data) return; 37 if (!data) return;
38 38
39 Page* page = Page::FromAddress(buffer->address()); 39 Page* page = Page::FromAddress(buffer->address());
40 size_t length = 0; 40 size_t length = 0;
41 { 41 {
42 base::LockGuard<base::Mutex> guard(page->mutex()); 42 base::LockGuard<base::Mutex> guard(page->mutex());
43 LocalArrayBufferTracker* tracker = page->local_tracker(); 43 LocalArrayBufferTracker* tracker = page->local_tracker();
44 DCHECK_NOT_NULL(tracker); 44 DCHECK_NOT_NULL(tracker);
45 length = tracker->Remove(buffer).second; 45 length = tracker->Remove(buffer).second;
46 } 46 }
47 heap->update_amount_of_external_allocated_memory( 47 heap->update_external_memory(-static_cast<intptr_t>(length));
48 -static_cast<intptr_t>(length));
49 } 48 }
50 49
51 void LocalArrayBufferTracker::Add(Key key, const Value& value) { 50 void LocalArrayBufferTracker::Add(Key key, const Value& value) {
52 auto ret = array_buffers_.insert(std::make_pair(key, value)); 51 auto ret = array_buffers_.insert(std::make_pair(key, value));
53 USE(ret); 52 USE(ret);
54 // Check that we indeed inserted a new value and did not overwrite an existing 53 // Check that we indeed inserted a new value and did not overwrite an existing
55 // one (which would be a bug). 54 // one (which would be a bug).
56 DCHECK(ret.second); 55 DCHECK(ret.second);
57 } 56 }
58 57
59 LocalArrayBufferTracker::Value LocalArrayBufferTracker::Remove(Key key) { 58 LocalArrayBufferTracker::Value LocalArrayBufferTracker::Remove(Key key) {
60 TrackingMap::iterator it = array_buffers_.find(key); 59 TrackingMap::iterator it = array_buffers_.find(key);
61 DCHECK(it != array_buffers_.end()); 60 DCHECK(it != array_buffers_.end());
62 Value value = it->second; 61 Value value = it->second;
63 array_buffers_.erase(it); 62 array_buffers_.erase(it);
64 return value; 63 return value;
65 } 64 }
66 65
67 } // namespace internal 66 } // namespace internal
68 } // namespace v8 67 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/array-buffer-tracker.cc ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698