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

Unified Diff: src/heap/mark-compact.cc

Issue 2442443003: [heap] Uncommit marking deque in concurrent task. (Closed)
Patch Set: use cancelable task Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/mark-compact.h ('k') | test/cctest/heap/test-mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 4c12ec05dee7c0a5682f8cca8d43c6b462c39a8e..356c4d5b6606e3944421417d6fecd5fadff475e7 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -58,6 +58,7 @@ MarkCompactCollector::MarkCompactCollector(Heap* heap)
compacting_(false),
black_allocation_(false),
have_code_to_deoptimize_(false),
+ marking_deque_(heap),
code_flusher_(nullptr),
sweeper_(heap) {
}
@@ -2115,9 +2116,13 @@ void MarkingDeque::SetUp() {
}
}
-void MarkingDeque::TearDown() { delete backing_store_; }
+void MarkingDeque::TearDown() {
+ CancelOrWaitForUncommitTask();
+ delete backing_store_;
+}
void MarkingDeque::StartUsing() {
+ base::LockGuard<base::Mutex> guard(&mutex_);
if (in_use_) {
// This can happen in mark-compact GC if the incremental marker already
// started using the marking deque.
Michael Lippautz 2016/10/24 13:34:03 nit: This comment requires updating.
@@ -2137,11 +2142,16 @@ void MarkingDeque::StartUsing() {
}
void MarkingDeque::StopUsing() {
+ base::LockGuard<base::Mutex> guard(&mutex_);
DCHECK(IsEmpty());
DCHECK(!overflowed_);
top_ = bottom_ = mask_ = 0;
- Uncommit();
in_use_ = false;
+ if (FLAG_concurrent_sweeping) {
+ StartUncommitTask();
+ } else {
+ Uncommit();
+ }
}
void MarkingDeque::Clear() {
@@ -2151,7 +2161,7 @@ void MarkingDeque::Clear() {
}
void MarkingDeque::Uncommit() {
- DCHECK(in_use_);
+ DCHECK(!in_use_);
bool success = backing_store_->Uncommit(backing_store_->address(),
backing_store_committed_size_);
backing_store_committed_size_ = 0;
@@ -2173,6 +2183,28 @@ void MarkingDeque::EnsureCommitted() {
}
}
+void MarkingDeque::StartUncommitTask() {
+ if (!uncommit_task_pending_) {
+ UncommitTask* task = new UncommitTask(heap_->isolate(), this);
+ uncommit_task_id_ = task->id();
+ uncommit_task_pending_ = true;
+ V8::GetCurrentPlatform()->CallOnBackgroundThread(
+ task, v8::Platform::kShortRunningTask);
+ }
+}
+
+void MarkingDeque::CancelOrWaitForUncommitTask() {
+ base::LockGuard<base::Mutex> guard(&mutex_);
+ if (!uncommit_task_pending_ ||
+ heap_->isolate()->cancelable_task_manager()->TryAbort(
+ uncommit_task_id_)) {
+ return;
+ }
+ while (uncommit_task_pending_) {
+ uncommit_task_barrier_.Wait(&mutex_);
+ }
+}
+
class MarkCompactCollector::ObjectStatsVisitor
: public MarkCompactCollector::HeapObjectVisitor {
public:
« no previous file with comments | « src/heap/mark-compact.h ('k') | test/cctest/heap/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698