OLD | NEW |
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 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 void ArrayBufferTracker::RegisterNew(Heap* heap, JSArrayBuffer* buffer) { | 13 void ArrayBufferTracker::RegisterNew(Heap* heap, JSArrayBuffer* buffer) { |
14 void* data = buffer->backing_store(); | 14 void* data = buffer->backing_store(); |
15 if (!data) return; | 15 if (!data) return; |
16 | 16 |
17 size_t length = NumberToSize(heap->isolate(), buffer->byte_length()); | 17 size_t length = NumberToSize(buffer->byte_length()); |
18 Page* page = Page::FromAddress(buffer->address()); | 18 Page* page = Page::FromAddress(buffer->address()); |
19 { | 19 { |
20 base::LockGuard<base::Mutex> guard(page->mutex()); | 20 base::LockGuard<base::Mutex> guard(page->mutex()); |
21 LocalArrayBufferTracker* tracker = page->local_tracker(); | 21 LocalArrayBufferTracker* tracker = page->local_tracker(); |
22 if (tracker == nullptr) { | 22 if (tracker == nullptr) { |
23 page->AllocateLocalTracker(); | 23 page->AllocateLocalTracker(); |
24 tracker = page->local_tracker(); | 24 tracker = page->local_tracker(); |
25 } | 25 } |
26 DCHECK_NOT_NULL(tracker); | 26 DCHECK_NOT_NULL(tracker); |
27 tracker->Add(buffer, length); | 27 tracker->Add(buffer, length); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 TrackingData::iterator it = array_buffers_.find(key); | 59 TrackingData::iterator it = array_buffers_.find(key); |
60 // Check that we indeed find a key to remove. | 60 // Check that we indeed find a key to remove. |
61 DCHECK(it != array_buffers_.end()); | 61 DCHECK(it != array_buffers_.end()); |
62 Value value = it->second; | 62 Value value = it->second; |
63 array_buffers_.erase(it); | 63 array_buffers_.erase(it); |
64 return value; | 64 return value; |
65 } | 65 } |
66 | 66 |
67 } // namespace internal | 67 } // namespace internal |
68 } // namespace v8 | 68 } // namespace v8 |
OLD | NEW |