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

Unified Diff: src/isolate.cc

Issue 12207207: Added system thread manager class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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/isolate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 556dde0718fa6962ff3d8aeddaa4cbf958dc7df6..3267a796c1de0e23a19a37e94e0e0f650efa1b0d 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -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).
@@ -1753,7 +1771,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];
@@ -1761,7 +1779,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];
@@ -2139,10 +2157,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);
@@ -2150,10 +2170,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);
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698