Commit 728aabfc authored by hpayer@chromium.org's avatar hpayer@chromium.org

Wait for sweeper threads in incremental marking step when sweeper threads are done sweeping.

BUG=
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/252123006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21058 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9ca2fc30
...@@ -886,6 +886,10 @@ void IncrementalMarking::Step(intptr_t allocated_bytes, ...@@ -886,6 +886,10 @@ void IncrementalMarking::Step(intptr_t allocated_bytes,
} }
if (state_ == SWEEPING) { if (state_ == SWEEPING) {
if (heap_->mark_compact_collector()->IsConcurrentSweepingInProgress() &&
heap_->mark_compact_collector()->IsSweepingCompleted()) {
heap_->mark_compact_collector()->WaitUntilSweepingCompleted();
}
if (!heap_->mark_compact_collector()->IsConcurrentSweepingInProgress()) { if (!heap_->mark_compact_collector()->IsConcurrentSweepingInProgress()) {
bytes_scanned_ = 0; bytes_scanned_ = 0;
StartMarking(PREVENT_COMPACTION); StartMarking(PREVENT_COMPACTION);
......
...@@ -608,6 +608,22 @@ void MarkCompactCollector::WaitUntilSweepingCompleted() { ...@@ -608,6 +608,22 @@ void MarkCompactCollector::WaitUntilSweepingCompleted() {
} }
bool MarkCompactCollector::IsSweepingCompleted() {
for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
if (!isolate()->sweeper_threads()[i]->SweepingCompleted()) {
return false;
}
}
if (FLAG_job_based_sweeping) {
if (!pending_sweeper_jobs_semaphore_.WaitFor(TimeDelta::FromSeconds(0))) {
return false;
}
pending_sweeper_jobs_semaphore_.Signal();
}
return true;
}
void MarkCompactCollector::RefillFreeList(PagedSpace* space) { void MarkCompactCollector::RefillFreeList(PagedSpace* space) {
FreeList* free_list; FreeList* free_list;
......
...@@ -671,6 +671,8 @@ class MarkCompactCollector { ...@@ -671,6 +671,8 @@ class MarkCompactCollector {
void WaitUntilSweepingCompleted(); void WaitUntilSweepingCompleted();
bool IsSweepingCompleted();
void RefillFreeList(PagedSpace* space); void RefillFreeList(PagedSpace* space);
bool AreSweeperThreadsActivated(); bool AreSweeperThreadsActivated();
......
...@@ -66,6 +66,15 @@ void SweeperThread::WaitForSweeperThread() { ...@@ -66,6 +66,15 @@ void SweeperThread::WaitForSweeperThread() {
} }
bool SweeperThread::SweepingCompleted() {
bool value = end_sweeping_semaphore_.WaitFor(TimeDelta::FromSeconds(0));
if (value) {
end_sweeping_semaphore_.Signal();
}
return value;
}
int SweeperThread::NumberOfThreads(int max_available) { int SweeperThread::NumberOfThreads(int max_available) {
if (!FLAG_concurrent_sweeping && !FLAG_parallel_sweeping) return 0; if (!FLAG_concurrent_sweeping && !FLAG_parallel_sweeping) return 0;
if (FLAG_sweeper_threads > 0) return FLAG_sweeper_threads; if (FLAG_sweeper_threads > 0) return FLAG_sweeper_threads;
......
...@@ -26,6 +26,7 @@ class SweeperThread : public Thread { ...@@ -26,6 +26,7 @@ class SweeperThread : public Thread {
void Stop(); void Stop();
void StartSweeping(); void StartSweeping();
void WaitForSweeperThread(); void WaitForSweeperThread();
bool SweepingCompleted();
static int NumberOfThreads(int max_available); static int NumberOfThreads(int max_available);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment