"src/heap/store-buffer-inl.h",
"src/heap/store-buffer.cc",
"src/heap/store-buffer.h",
- "src/heap/sweeper-thread.h",
- "src/heap/sweeper-thread.cc",
"src/hydrogen-alias-analysis.h",
"src/hydrogen-bce.cc",
"src/hydrogen-bce.h",
DEFINE_BOOL(concurrent_sweeping, true, "enable concurrent sweeping")
DEFINE_INT(sweeper_threads, 0,
"number of parallel and concurrent sweeping threads")
-DEFINE_BOOL(job_based_sweeping, true, "enable job based sweeping")
#ifdef VERIFY_HEAP
DEFINE_BOOL(verify_heap, false, "verify heap pointers before and after GC")
#endif
DEFINE_NEG_IMPLICATION(predictable, concurrent_osr)
DEFINE_NEG_IMPLICATION(predictable, concurrent_sweeping)
DEFINE_NEG_IMPLICATION(predictable, parallel_sweeping)
-DEFINE_NEG_IMPLICATION(predictable, job_based_sweeping)
//
#include "src/heap/objects-visiting.h"
#include "src/heap/objects-visiting-inl.h"
#include "src/heap/spaces-inl.h"
-#include "src/heap/sweeper-thread.h"
#include "src/heap-profiler.h"
#include "src/ic/ic.h"
#include "src/ic/stub-cache.h"
DCHECK(free_list_old_pointer_space_.get()->IsEmpty());
DCHECK(free_list_old_data_space_.get()->IsEmpty());
sweeping_in_progress_ = true;
- for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
- isolate()->sweeper_threads()[i]->StartSweeping();
- }
- if (FLAG_job_based_sweeping) {
- V8::GetCurrentPlatform()->CallOnBackgroundThread(
- new SweeperTask(heap(), heap()->old_data_space()),
- v8::Platform::kShortRunningTask);
- V8::GetCurrentPlatform()->CallOnBackgroundThread(
- new SweeperTask(heap(), heap()->old_pointer_space()),
- v8::Platform::kShortRunningTask);
- }
+ V8::GetCurrentPlatform()->CallOnBackgroundThread(
+ new SweeperTask(heap(), heap()->old_data_space()),
+ v8::Platform::kShortRunningTask);
+ V8::GetCurrentPlatform()->CallOnBackgroundThread(
+ new SweeperTask(heap(), heap()->old_pointer_space()),
+ v8::Platform::kShortRunningTask);
}
void MarkCompactCollector::EnsureSweepingCompleted() {
DCHECK(sweeping_in_progress_ == true);
- // If sweeping is not completed, we try to complete it here. If we do not
- // have sweeper threads we have to complete since we do not have a good
- // indicator for a swept space in that case.
- if (!AreSweeperThreadsActivated() || !IsSweepingCompleted()) {
+ // If sweeping is not completed or not running at all, we try to complete it
+ // here.
+ if (!IsSweepingCompleted()) {
SweepInParallel(heap()->paged_space(OLD_DATA_SPACE), 0);
SweepInParallel(heap()->paged_space(OLD_POINTER_SPACE), 0);
}
-
- for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
- isolate()->sweeper_threads()[i]->WaitForSweeperThread();
- }
- if (FLAG_job_based_sweeping) {
- // Wait twice for both jobs.
- pending_sweeper_jobs_semaphore_.Wait();
- pending_sweeper_jobs_semaphore_.Wait();
- }
+ // Wait twice for both jobs.
+ pending_sweeper_jobs_semaphore_.Wait();
+ pending_sweeper_jobs_semaphore_.Wait();
ParallelSweepSpacesComplete();
sweeping_in_progress_ = false;
RefillFreeList(heap()->paged_space(OLD_DATA_SPACE));
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(
- base::TimeDelta::FromSeconds(0))) {
- return false;
- }
- pending_sweeper_jobs_semaphore_.Signal();
+ if (!pending_sweeper_jobs_semaphore_.WaitFor(
+ base::TimeDelta::FromSeconds(0))) {
+ return false;
}
-
+ pending_sweeper_jobs_semaphore_.Signal();
return true;
}
}
-bool MarkCompactCollector::AreSweeperThreadsActivated() {
- return isolate()->sweeper_threads() != NULL || FLAG_job_based_sweeping;
-}
-
-
void Marking::TransferMark(Address old_start, Address new_start) {
// This is only used when resizing an object.
DCHECK(MemoryChunk::FromAddress(old_start) ==
static bool ShouldStartSweeperThreads(MarkCompactCollector::SweeperType type) {
- return type == MarkCompactCollector::PARALLEL_SWEEPING ||
- type == MarkCompactCollector::CONCURRENT_SWEEPING;
+ return (type == MarkCompactCollector::PARALLEL_SWEEPING ||
+ type == MarkCompactCollector::CONCURRENT_SWEEPING) &&
+ !FLAG_predictable;
}
void RefillFreeList(PagedSpace* space);
- bool AreSweeperThreadsActivated();
-
// Checks if sweeping is in progress right now on any space.
bool sweeping_in_progress() { return sweeping_in_progress_; }
+++ /dev/null
-// Copyright 2012 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/heap/sweeper-thread.h"
-
-#include "src/v8.h"
-
-#include "src/isolate.h"
-#include "src/v8threads.h"
-
-namespace v8 {
-namespace internal {
-
-static const int kSweeperThreadStackSize = 64 * KB;
-
-SweeperThread::SweeperThread(Isolate* isolate)
- : Thread(Thread::Options("v8:SweeperThread", kSweeperThreadStackSize)),
- isolate_(isolate),
- heap_(isolate->heap()),
- collector_(heap_->mark_compact_collector()),
- start_sweeping_semaphore_(0),
- end_sweeping_semaphore_(0),
- stop_semaphore_(0) {
- DCHECK(!FLAG_job_based_sweeping);
- base::NoBarrier_Store(&stop_thread_, static_cast<base::AtomicWord>(false));
-}
-
-
-void SweeperThread::Run() {
- Isolate::SetIsolateThreadLocals(isolate_, NULL);
- DisallowHeapAllocation no_allocation;
- DisallowHandleAllocation no_handles;
- DisallowHandleDereference no_deref;
-
- while (true) {
- start_sweeping_semaphore_.Wait();
-
- if (base::Acquire_Load(&stop_thread_)) {
- stop_semaphore_.Signal();
- return;
- }
-
- collector_->SweepInParallel(heap_->old_data_space(), 0);
- collector_->SweepInParallel(heap_->old_pointer_space(), 0);
- end_sweeping_semaphore_.Signal();
- }
-}
-
-
-void SweeperThread::Stop() {
- base::Release_Store(&stop_thread_, static_cast<base::AtomicWord>(true));
- start_sweeping_semaphore_.Signal();
- stop_semaphore_.Wait();
- Join();
-}
-
-
-void SweeperThread::StartSweeping() { start_sweeping_semaphore_.Signal(); }
-
-
-void SweeperThread::WaitForSweeperThread() { end_sweeping_semaphore_.Wait(); }
-
-
-bool SweeperThread::SweepingCompleted() {
- bool value = end_sweeping_semaphore_.WaitFor(base::TimeDelta::FromSeconds(0));
- if (value) {
- end_sweeping_semaphore_.Signal();
- }
- return value;
-}
-
-
-int SweeperThread::NumberOfThreads(int max_available) {
- if (!FLAG_concurrent_sweeping && !FLAG_parallel_sweeping) return 0;
- if (FLAG_sweeper_threads > 0) return FLAG_sweeper_threads;
- if (FLAG_concurrent_sweeping) return max_available - 1;
- DCHECK(FLAG_parallel_sweeping);
- return max_available;
-}
-}
-} // namespace v8::internal
+++ /dev/null
-// Copyright 2012 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef V8_HEAP_SWEEPER_THREAD_H_
-#define V8_HEAP_SWEEPER_THREAD_H_
-
-#include "src/base/atomicops.h"
-#include "src/base/platform/platform.h"
-#include "src/flags.h"
-#include "src/utils.h"
-
-#include "src/heap/spaces.h"
-
-#include "src/heap/heap.h"
-
-namespace v8 {
-namespace internal {
-
-class SweeperThread : public base::Thread {
- public:
- explicit SweeperThread(Isolate* isolate);
- ~SweeperThread() {}
-
- void Run();
- void Stop();
- void StartSweeping();
- void WaitForSweeperThread();
- bool SweepingCompleted();
-
- static int NumberOfThreads(int max_available);
-
- private:
- Isolate* isolate_;
- Heap* heap_;
- MarkCompactCollector* collector_;
- base::Semaphore start_sweeping_semaphore_;
- base::Semaphore end_sweeping_semaphore_;
- base::Semaphore stop_semaphore_;
- volatile base::AtomicWord stop_thread_;
-};
-}
-} // namespace v8::internal
-
-#endif // V8_HEAP_SWEEPER_THREAD_H_
#include "src/debug.h"
#include "src/deoptimizer.h"
#include "src/heap/spaces.h"
-#include "src/heap/sweeper-thread.h"
#include "src/heap-profiler.h"
#include "src/hydrogen.h"
#include "src/ic/stub-cache.h"
function_entry_hook_(NULL),
deferred_handles_head_(NULL),
optimizing_compiler_thread_(NULL),
- sweeper_thread_(NULL),
- num_sweeper_threads_(0),
stress_deopt_count_(0),
next_optimization_id_(0),
use_counter_callback_(NULL),
optimizing_compiler_thread_ = NULL;
}
- for (int i = 0; i < num_sweeper_threads_; i++) {
- sweeper_thread_[i]->Stop();
- delete sweeper_thread_[i];
- sweeper_thread_[i] = NULL;
- }
- delete[] sweeper_thread_;
- sweeper_thread_ = NULL;
-
- if (FLAG_job_based_sweeping &&
- heap_.mark_compact_collector()->sweeping_in_progress()) {
+ if (heap_.mark_compact_collector()->sweeping_in_progress()) {
heap_.mark_compact_collector()->EnsureSweepingCompleted();
}
Max(Min(base::SysInfo::NumberOfProcessors(), 4), 1);
}
- if (!FLAG_job_based_sweeping) {
- num_sweeper_threads_ =
- SweeperThread::NumberOfThreads(max_available_threads_);
- }
-
if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) {
PrintF("Concurrent recompilation has been disabled for tracing.\n");
} else if (OptimizingCompilerThread::Enabled(max_available_threads_)) {
optimizing_compiler_thread_->Start();
}
- if (num_sweeper_threads_ > 0) {
- sweeper_thread_ = new SweeperThread*[num_sweeper_threads_];
- for (int i = 0; i < num_sweeper_threads_; i++) {
- sweeper_thread_[i] = new SweeperThread(this);
- sweeper_thread_[i]->Start();
- }
- }
-
// If we are deserializing, read the state into the now-empty heap.
if (!create_heap_objects) {
des->Deserialize(this);
return optimizing_compiler_thread_;
}
- int num_sweeper_threads() const {
- return num_sweeper_threads_;
- }
-
- SweeperThread** sweeper_threads() {
- return sweeper_thread_;
- }
-
int id() const { return static_cast<int>(id_); }
HStatistics* GetHStatistics();
DeferredHandles* deferred_handles_head_;
OptimizingCompilerThread* optimizing_compiler_thread_;
- SweeperThread** sweeper_thread_;
- int num_sweeper_threads_;
// Counts deopt points if deopt_every_n_times is enabled.
unsigned int stress_deopt_count_;
'../../src/heap/store-buffer-inl.h',
'../../src/heap/store-buffer.cc',
'../../src/heap/store-buffer.h',
- '../../src/heap/sweeper-thread.h',
- '../../src/heap/sweeper-thread.cc',
'../../src/hydrogen-alias-analysis.h',
'../../src/hydrogen-bce.cc',
'../../src/hydrogen-bce.h',