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

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

Issue 2637403011: Reland "[heap] Provide ObjectMarking with marking transitions" (Closed)
Patch Set: Add comment Created 3 years, 11 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 | « no previous file | src/heap/heap.cc » ('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 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 {
11 11
12 LocalArrayBufferTracker::~LocalArrayBufferTracker() { 12 LocalArrayBufferTracker::~LocalArrayBufferTracker() {
13 CHECK(array_buffers_.empty()); 13 CHECK(array_buffers_.empty());
14 } 14 }
15 15
16 template <LocalArrayBufferTracker::FreeMode free_mode> 16 template <LocalArrayBufferTracker::FreeMode free_mode>
17 void LocalArrayBufferTracker::Free() { 17 void LocalArrayBufferTracker::Free() {
18 size_t freed_memory = 0; 18 size_t freed_memory = 0;
19 for (TrackingData::iterator it = array_buffers_.begin(); 19 for (TrackingData::iterator it = array_buffers_.begin();
20 it != array_buffers_.end();) { 20 it != array_buffers_.end();) {
21 JSArrayBuffer* buffer = reinterpret_cast<JSArrayBuffer*>(it->first); 21 JSArrayBuffer* buffer = reinterpret_cast<JSArrayBuffer*>(it->first);
22 if ((free_mode == kFreeAll) || 22 if ((free_mode == kFreeAll) || ObjectMarking::IsWhite(buffer)) {
23 Marking::IsWhite(ObjectMarking::MarkBitFrom(buffer))) {
24 const size_t len = it->second; 23 const size_t len = it->second;
25 heap_->isolate()->array_buffer_allocator()->Free(buffer->backing_store(), 24 heap_->isolate()->array_buffer_allocator()->Free(buffer->backing_store(),
26 len); 25 len);
27 freed_memory += len; 26 freed_memory += len;
28 it = array_buffers_.erase(it); 27 it = array_buffers_.erase(it);
29 } else { 28 } else {
30 ++it; 29 ++it;
31 } 30 }
32 } 31 }
33 if (freed_memory > 0) { 32 if (freed_memory > 0) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 { 129 {
131 base::LockGuard<base::Mutex> guard(page->mutex()); 130 base::LockGuard<base::Mutex> guard(page->mutex());
132 LocalArrayBufferTracker* tracker = page->local_tracker(); 131 LocalArrayBufferTracker* tracker = page->local_tracker();
133 if (tracker == nullptr) return false; 132 if (tracker == nullptr) return false;
134 return tracker->IsTracked(buffer); 133 return tracker->IsTracked(buffer);
135 } 134 }
136 } 135 }
137 136
138 } // namespace internal 137 } // namespace internal
139 } // namespace v8 138 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698