OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 | 2112 |
2113 void MarkingDeque::SetUp() { | 2113 void MarkingDeque::SetUp() { |
2114 backing_store_ = new base::VirtualMemory(kMaxSize); | 2114 backing_store_ = new base::VirtualMemory(kMaxSize); |
2115 backing_store_committed_size_ = 0; | 2115 backing_store_committed_size_ = 0; |
2116 if (backing_store_ == nullptr) { | 2116 if (backing_store_ == nullptr) { |
2117 V8::FatalProcessOutOfMemory("MarkingDeque::SetUp"); | 2117 V8::FatalProcessOutOfMemory("MarkingDeque::SetUp"); |
2118 } | 2118 } |
2119 } | 2119 } |
2120 | 2120 |
2121 void MarkingDeque::TearDown() { | 2121 void MarkingDeque::TearDown() { |
2122 CancelOrWaitForUncommitTask(); | |
2123 delete backing_store_; | 2122 delete backing_store_; |
2124 } | 2123 } |
2125 | 2124 |
2126 void MarkingDeque::StartUsing() { | 2125 void MarkingDeque::StartUsing() { |
2127 base::LockGuard<base::Mutex> guard(&mutex_); | 2126 base::LockGuard<base::Mutex> guard(&mutex_); |
2128 if (in_use_) { | 2127 if (in_use_) { |
2129 // This can happen in mark-compact GC if the incremental marker already | 2128 // This can happen in mark-compact GC if the incremental marker already |
2130 // started using the marking deque. | 2129 // started using the marking deque. |
2131 return; | 2130 return; |
2132 } | 2131 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2180 break; | 2179 break; |
2181 } | 2180 } |
2182 } | 2181 } |
2183 if (backing_store_committed_size_ == 0) { | 2182 if (backing_store_committed_size_ == 0) { |
2184 V8::FatalProcessOutOfMemory("MarkingDeque::EnsureCommitted"); | 2183 V8::FatalProcessOutOfMemory("MarkingDeque::EnsureCommitted"); |
2185 } | 2184 } |
2186 } | 2185 } |
2187 | 2186 |
2188 void MarkingDeque::StartUncommitTask() { | 2187 void MarkingDeque::StartUncommitTask() { |
2189 if (!uncommit_task_pending_) { | 2188 if (!uncommit_task_pending_) { |
| 2189 uncommit_task_pending_ = true; |
2190 UncommitTask* task = new UncommitTask(heap_->isolate(), this); | 2190 UncommitTask* task = new UncommitTask(heap_->isolate(), this); |
2191 uncommit_task_id_ = task->id(); | |
2192 uncommit_task_pending_ = true; | |
2193 V8::GetCurrentPlatform()->CallOnBackgroundThread( | 2191 V8::GetCurrentPlatform()->CallOnBackgroundThread( |
2194 task, v8::Platform::kShortRunningTask); | 2192 task, v8::Platform::kShortRunningTask); |
2195 } | 2193 } |
2196 } | 2194 } |
2197 | 2195 |
2198 void MarkingDeque::CancelOrWaitForUncommitTask() { | |
2199 base::LockGuard<base::Mutex> guard(&mutex_); | |
2200 if (!uncommit_task_pending_ || | |
2201 heap_->isolate()->cancelable_task_manager()->TryAbort( | |
2202 uncommit_task_id_) != CancelableTaskManager::kTaskRunning) { | |
2203 return; | |
2204 } | |
2205 while (uncommit_task_pending_) { | |
2206 uncommit_task_barrier_.Wait(&mutex_); | |
2207 } | |
2208 } | |
2209 | |
2210 class MarkCompactCollector::ObjectStatsVisitor | 2196 class MarkCompactCollector::ObjectStatsVisitor |
2211 : public MarkCompactCollector::HeapObjectVisitor { | 2197 : public MarkCompactCollector::HeapObjectVisitor { |
2212 public: | 2198 public: |
2213 ObjectStatsVisitor(Heap* heap, ObjectStats* live_stats, | 2199 ObjectStatsVisitor(Heap* heap, ObjectStats* live_stats, |
2214 ObjectStats* dead_stats) | 2200 ObjectStats* dead_stats) |
2215 : live_collector_(heap, live_stats), dead_collector_(heap, dead_stats) { | 2201 : live_collector_(heap, live_stats), dead_collector_(heap, dead_stats) { |
2216 DCHECK_NOT_NULL(live_stats); | 2202 DCHECK_NOT_NULL(live_stats); |
2217 DCHECK_NOT_NULL(dead_stats); | 2203 DCHECK_NOT_NULL(dead_stats); |
2218 // Global objects are roots and thus recorded as live. | 2204 // Global objects are roots and thus recorded as live. |
2219 live_collector_.CollectGlobalStatistics(); | 2205 live_collector_.CollectGlobalStatistics(); |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3926 // The target is always in old space, we don't have to record the slot in | 3912 // The target is always in old space, we don't have to record the slot in |
3927 // the old-to-new remembered set. | 3913 // the old-to-new remembered set. |
3928 DCHECK(!heap()->InNewSpace(target)); | 3914 DCHECK(!heap()->InNewSpace(target)); |
3929 RecordRelocSlot(host, &rinfo, target); | 3915 RecordRelocSlot(host, &rinfo, target); |
3930 } | 3916 } |
3931 } | 3917 } |
3932 } | 3918 } |
3933 | 3919 |
3934 } // namespace internal | 3920 } // namespace internal |
3935 } // namespace v8 | 3921 } // namespace v8 |
OLD | NEW |