OLD | NEW |
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/heap.h" | 6 #include "src/heap/heap.h" |
7 #include "src/isolate.h" | 7 #include "src/isolate.h" |
8 #include "src/objects.h" | 8 #include "src/objects.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 size_t length = (*live_buffers)[data]; | 70 size_t length = (*live_buffers)[data]; |
71 live_buffers->erase(data); | 71 live_buffers->erase(data); |
72 not_yet_discovered_buffers->erase(data); | 72 not_yet_discovered_buffers->erase(data); |
73 | 73 |
74 heap()->update_amount_of_external_allocated_memory( | 74 heap()->update_amount_of_external_allocated_memory( |
75 -static_cast<int64_t>(length)); | 75 -static_cast<int64_t>(length)); |
76 } | 76 } |
77 | 77 |
78 | 78 |
79 void ArrayBufferTracker::MarkLive(JSArrayBuffer* buffer) { | 79 void ArrayBufferTracker::MarkLive(JSArrayBuffer* buffer) { |
80 base::LockGuard<base::Mutex> guard(&mutex_); | |
81 void* data = buffer->backing_store(); | 80 void* data = buffer->backing_store(); |
82 | 81 |
83 // ArrayBuffer might be in the middle of being constructed. | 82 // ArrayBuffer might be in the middle of being constructed. |
84 if (data == heap()->undefined_value()) return; | 83 if (data == heap()->undefined_value()) return; |
85 if (heap()->InNewSpace(buffer)) { | 84 if (heap()->InNewSpace(buffer)) { |
86 not_yet_discovered_array_buffers_for_scavenge_.erase(data); | 85 not_yet_discovered_array_buffers_for_scavenge_.erase(data); |
87 } else { | 86 } else { |
88 not_yet_discovered_array_buffers_.erase(data); | 87 not_yet_discovered_array_buffers_.erase(data); |
89 } | 88 } |
90 } | 89 } |
(...skipping 26 matching lines...) Expand all Loading... |
117 } | 116 } |
118 | 117 |
119 | 118 |
120 void ArrayBufferTracker::PrepareDiscoveryInNewSpace() { | 119 void ArrayBufferTracker::PrepareDiscoveryInNewSpace() { |
121 not_yet_discovered_array_buffers_for_scavenge_ = | 120 not_yet_discovered_array_buffers_for_scavenge_ = |
122 live_array_buffers_for_scavenge_; | 121 live_array_buffers_for_scavenge_; |
123 } | 122 } |
124 | 123 |
125 | 124 |
126 void ArrayBufferTracker::Promote(JSArrayBuffer* buffer) { | 125 void ArrayBufferTracker::Promote(JSArrayBuffer* buffer) { |
127 base::LockGuard<base::Mutex> guard(&mutex_); | |
128 | |
129 if (buffer->is_external()) return; | 126 if (buffer->is_external()) return; |
130 void* data = buffer->backing_store(); | 127 void* data = buffer->backing_store(); |
131 if (!data) return; | 128 if (!data) return; |
132 // ArrayBuffer might be in the middle of being constructed. | 129 // ArrayBuffer might be in the middle of being constructed. |
133 if (data == heap()->undefined_value()) return; | 130 if (data == heap()->undefined_value()) return; |
134 DCHECK(live_array_buffers_for_scavenge_.count(data) > 0); | 131 DCHECK(live_array_buffers_for_scavenge_.count(data) > 0); |
135 live_array_buffers_[data] = live_array_buffers_for_scavenge_[data]; | 132 live_array_buffers_[data] = live_array_buffers_for_scavenge_[data]; |
136 live_array_buffers_for_scavenge_.erase(data); | 133 live_array_buffers_for_scavenge_.erase(data); |
137 not_yet_discovered_array_buffers_for_scavenge_.erase(data); | 134 not_yet_discovered_array_buffers_for_scavenge_.erase(data); |
138 } | 135 } |
139 | 136 |
140 } // namespace internal | 137 } // namespace internal |
141 } // namespace v8 | 138 } // namespace v8 |
OLD | NEW |