Added system thread manager class.
BUG= Review URL: https://codereview.chromium.org/12207207 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13757 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
6e829ed485
commit
ddeaa4a3f2
@ -440,10 +440,10 @@ DEFINE_bool(track_gc_object_stats, false,
|
||||
"track object counts and memory usage")
|
||||
DEFINE_bool(parallel_sweeping, true, "enable parallel sweeping")
|
||||
DEFINE_bool(concurrent_sweeping, false, "enable concurrent sweeping")
|
||||
DEFINE_int(sweeper_threads, 2,
|
||||
DEFINE_int(sweeper_threads, 0,
|
||||
"number of parallel and concurrent sweeping threads")
|
||||
DEFINE_bool(parallel_marking, false, "enable parallel marking")
|
||||
DEFINE_int(marking_threads, 1, "number of parallel marking threads")
|
||||
DEFINE_int(marking_threads, 0, "number of parallel marking threads")
|
||||
#ifdef VERIFY_HEAP
|
||||
DEFINE_bool(verify_heap, false, "verify heap pointers before and after GC")
|
||||
#endif
|
||||
|
@ -131,6 +131,24 @@ v8::TryCatch* ThreadLocalTop::TryCatchHandler() {
|
||||
}
|
||||
|
||||
|
||||
int SystemThreadManager::NumberOfParallelSystemThreads(
|
||||
ParallelSystemComponent type) {
|
||||
int number_of_threads = Min(OS::NumberOfCores(), kMaxThreads);
|
||||
ASSERT(number_of_threads > 0);
|
||||
if (number_of_threads == 1) {
|
||||
return 1;
|
||||
}
|
||||
if (type == PARALLEL_SWEEPING) {
|
||||
return number_of_threads;
|
||||
} else if (type == CONCURRENT_SWEEPING) {
|
||||
return number_of_threads - 1;
|
||||
} else if (type == PARALLEL_MARKING) {
|
||||
return number_of_threads;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Create a dummy thread that will wait forever on a semaphore. The only
|
||||
// purpose for this thread is to have some stack area to save essential data
|
||||
// into for use by a stacks only core dump (aka minidump).
|
||||
@ -1754,7 +1772,7 @@ void Isolate::Deinit() {
|
||||
if (state_ == INITIALIZED) {
|
||||
TRACE_ISOLATE(deinit);
|
||||
|
||||
if (FLAG_concurrent_sweeping || FLAG_parallel_sweeping) {
|
||||
if (FLAG_sweeper_threads > 0) {
|
||||
for (int i = 0; i < FLAG_sweeper_threads; i++) {
|
||||
sweeper_thread_[i]->Stop();
|
||||
delete sweeper_thread_[i];
|
||||
@ -1762,7 +1780,7 @@ void Isolate::Deinit() {
|
||||
delete[] sweeper_thread_;
|
||||
}
|
||||
|
||||
if (FLAG_parallel_marking) {
|
||||
if (FLAG_marking_threads > 0) {
|
||||
for (int i = 0; i < FLAG_marking_threads; i++) {
|
||||
marking_thread_[i]->Stop();
|
||||
delete marking_thread_[i];
|
||||
@ -2143,10 +2161,12 @@ bool Isolate::Init(Deserializer* des) {
|
||||
|
||||
if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Start();
|
||||
|
||||
if (FLAG_parallel_marking) {
|
||||
if (FLAG_marking_threads < 1) {
|
||||
FLAG_marking_threads = 1;
|
||||
}
|
||||
if (FLAG_parallel_marking && FLAG_marking_threads == 0) {
|
||||
FLAG_marking_threads = SystemThreadManager::
|
||||
NumberOfParallelSystemThreads(
|
||||
SystemThreadManager::PARALLEL_MARKING);
|
||||
}
|
||||
if (FLAG_marking_threads > 0) {
|
||||
marking_thread_ = new MarkingThread*[FLAG_marking_threads];
|
||||
for (int i = 0; i < FLAG_marking_threads; i++) {
|
||||
marking_thread_[i] = new MarkingThread(this);
|
||||
@ -2154,10 +2174,18 @@ bool Isolate::Init(Deserializer* des) {
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAG_parallel_sweeping || FLAG_concurrent_sweeping) {
|
||||
if (FLAG_sweeper_threads < 1) {
|
||||
FLAG_sweeper_threads = 1;
|
||||
if (FLAG_sweeper_threads == 0) {
|
||||
if (FLAG_concurrent_sweeping) {
|
||||
FLAG_sweeper_threads = SystemThreadManager::
|
||||
NumberOfParallelSystemThreads(
|
||||
SystemThreadManager::CONCURRENT_SWEEPING);
|
||||
} else if (FLAG_parallel_sweeping) {
|
||||
FLAG_sweeper_threads = SystemThreadManager::
|
||||
NumberOfParallelSystemThreads(
|
||||
SystemThreadManager::PARALLEL_SWEEPING);
|
||||
}
|
||||
}
|
||||
if (FLAG_sweeper_threads > 0) {
|
||||
sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads];
|
||||
for (int i = 0; i < FLAG_sweeper_threads; i++) {
|
||||
sweeper_thread_[i] = new SweeperThread(this);
|
||||
|
@ -287,6 +287,20 @@ class ThreadLocalTop BASE_EMBEDDED {
|
||||
};
|
||||
|
||||
|
||||
class SystemThreadManager {
|
||||
public:
|
||||
enum ParallelSystemComponent {
|
||||
PARALLEL_SWEEPING,
|
||||
CONCURRENT_SWEEPING,
|
||||
PARALLEL_MARKING
|
||||
};
|
||||
|
||||
static int NumberOfParallelSystemThreads(ParallelSystemComponent type);
|
||||
|
||||
static const int kMaxThreads = 4;
|
||||
};
|
||||
|
||||
|
||||
#ifdef ENABLE_DEBUGGER_SUPPORT
|
||||
|
||||
#define ISOLATE_DEBUGGER_INIT_LIST(V) \
|
||||
|
Loading…
Reference in New Issue
Block a user