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_); |
80 void* data = buffer->backing_store(); | 81 void* data = buffer->backing_store(); |
81 | 82 |
82 // ArrayBuffer might be in the middle of being constructed. | 83 // ArrayBuffer might be in the middle of being constructed. |
83 if (data == heap()->undefined_value()) return; | 84 if (data == heap()->undefined_value()) return; |
84 if (heap()->InNewSpace(buffer)) { | 85 if (heap()->InNewSpace(buffer)) { |
85 not_yet_discovered_array_buffers_for_scavenge_.erase(data); | 86 not_yet_discovered_array_buffers_for_scavenge_.erase(data); |
86 } else { | 87 } else { |
87 not_yet_discovered_array_buffers_.erase(data); | 88 not_yet_discovered_array_buffers_.erase(data); |
88 } | 89 } |
89 } | 90 } |
(...skipping 26 matching lines...) Expand all Loading... |
116 } | 117 } |
117 | 118 |
118 | 119 |
119 void ArrayBufferTracker::PrepareDiscoveryInNewSpace() { | 120 void ArrayBufferTracker::PrepareDiscoveryInNewSpace() { |
120 not_yet_discovered_array_buffers_for_scavenge_ = | 121 not_yet_discovered_array_buffers_for_scavenge_ = |
121 live_array_buffers_for_scavenge_; | 122 live_array_buffers_for_scavenge_; |
122 } | 123 } |
123 | 124 |
124 | 125 |
125 void ArrayBufferTracker::Promote(JSArrayBuffer* buffer) { | 126 void ArrayBufferTracker::Promote(JSArrayBuffer* buffer) { |
| 127 base::LockGuard<base::Mutex> guard(&mutex_); |
| 128 |
126 if (buffer->is_external()) return; | 129 if (buffer->is_external()) return; |
127 void* data = buffer->backing_store(); | 130 void* data = buffer->backing_store(); |
128 if (!data) return; | 131 if (!data) return; |
129 // ArrayBuffer might be in the middle of being constructed. | 132 // ArrayBuffer might be in the middle of being constructed. |
130 if (data == heap()->undefined_value()) return; | 133 if (data == heap()->undefined_value()) return; |
131 DCHECK(live_array_buffers_for_scavenge_.count(data) > 0); | 134 DCHECK(live_array_buffers_for_scavenge_.count(data) > 0); |
132 live_array_buffers_[data] = live_array_buffers_for_scavenge_[data]; | 135 live_array_buffers_[data] = live_array_buffers_for_scavenge_[data]; |
133 live_array_buffers_for_scavenge_.erase(data); | 136 live_array_buffers_for_scavenge_.erase(data); |
134 not_yet_discovered_array_buffers_for_scavenge_.erase(data); | 137 not_yet_discovered_array_buffers_for_scavenge_.erase(data); |
135 } | 138 } |
136 | 139 |
137 } // namespace internal | 140 } // namespace internal |
138 } // namespace v8 | 141 } // namespace v8 |
OLD | NEW |