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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 #endif 124 #endif
125 thread_id_ = ThreadId::Current(); 125 thread_id_ = ThreadId::Current();
126 } 126 }
127 127
128 128
129 v8::TryCatch* ThreadLocalTop::TryCatchHandler() { 129 v8::TryCatch* ThreadLocalTop::TryCatchHandler() {
130 return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address()); 130 return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address());
131 } 131 }
132 132
133 133
134 int SystemThreadManager::NumberOfParallelSystemThreads(
135 ParallelSystemComponent type) {
136 int number_of_cores = OS::NumberOfCores();
137 if (type == PARALLEL_SWEEPING) {
138 return number_of_cores;
139 } else if (type == CONCURRENT_SWEEPING) {
140 return number_of_cores - 1;
141 } else if (type == PARALLEL_MARKING) {
142 return number_of_cores;
Michael Starzinger 2013/02/27 12:13:09 Let's cap the number of threads to a certain maxim
Hannes Payer (out of office) 2013/02/27 12:43:29 Done.
143 }
144 return 1;
145 }
146
147
134 // Create a dummy thread that will wait forever on a semaphore. The only 148 // Create a dummy thread that will wait forever on a semaphore. The only
135 // purpose for this thread is to have some stack area to save essential data 149 // purpose for this thread is to have some stack area to save essential data
136 // into for use by a stacks only core dump (aka minidump). 150 // into for use by a stacks only core dump (aka minidump).
137 class PreallocatedMemoryThread: public Thread { 151 class PreallocatedMemoryThread: public Thread {
138 public: 152 public:
139 char* data() { 153 char* data() {
140 if (data_ready_semaphore_ != NULL) { 154 if (data_ready_semaphore_ != NULL) {
141 // Initial access is guarded until the data has been published. 155 // Initial access is guarded until the data has been published.
142 data_ready_semaphore_->Wait(); 156 data_ready_semaphore_->Wait();
143 delete data_ready_semaphore_; 157 delete data_ready_semaphore_;
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 1760
1747 void Isolate::GlobalTearDown() { 1761 void Isolate::GlobalTearDown() {
1748 delete thread_data_table_; 1762 delete thread_data_table_;
1749 } 1763 }
1750 1764
1751 1765
1752 void Isolate::Deinit() { 1766 void Isolate::Deinit() {
1753 if (state_ == INITIALIZED) { 1767 if (state_ == INITIALIZED) {
1754 TRACE_ISOLATE(deinit); 1768 TRACE_ISOLATE(deinit);
1755 1769
1756 if (FLAG_concurrent_sweeping || FLAG_parallel_sweeping) { 1770 if (FLAG_sweeper_threads > 0) {
1757 for (int i = 0; i < FLAG_sweeper_threads; i++) { 1771 for (int i = 0; i < FLAG_sweeper_threads; i++) {
1758 sweeper_thread_[i]->Stop(); 1772 sweeper_thread_[i]->Stop();
1759 delete sweeper_thread_[i]; 1773 delete sweeper_thread_[i];
1760 } 1774 }
1761 delete[] sweeper_thread_; 1775 delete[] sweeper_thread_;
1762 } 1776 }
1763 1777
1764 if (FLAG_parallel_marking) { 1778 if (FLAG_marking_threads > 0) {
1765 for (int i = 0; i < FLAG_marking_threads; i++) { 1779 for (int i = 0; i < FLAG_marking_threads; i++) {
1766 marking_thread_[i]->Stop(); 1780 marking_thread_[i]->Stop();
1767 delete marking_thread_[i]; 1781 delete marking_thread_[i];
1768 } 1782 }
1769 delete[] marking_thread_; 1783 delete[] marking_thread_;
1770 } 1784 }
1771 1785
1772 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Stop(); 1786 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Stop();
1773 1787
1774 if (FLAG_hydrogen_stats) HStatistics::Instance()->Print(); 1788 if (FLAG_hydrogen_stats) HStatistics::Instance()->Print();
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 2146
2133 if (!Serializer::enabled()) { 2147 if (!Serializer::enabled()) {
2134 // Ensure that the stub failure trampoline has been generated. 2148 // Ensure that the stub failure trampoline has been generated.
2135 HandleScope scope(this); 2149 HandleScope scope(this);
2136 CodeStub::GenerateFPStubs(); 2150 CodeStub::GenerateFPStubs();
2137 StubFailureTrampolineStub::GenerateAheadOfTime(); 2151 StubFailureTrampolineStub::GenerateAheadOfTime();
2138 } 2152 }
2139 2153
2140 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Start(); 2154 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Start();
2141 2155
2142 if (FLAG_parallel_marking) { 2156 if (FLAG_parallel_marking && FLAG_marking_threads == 0) {
2143 if (FLAG_marking_threads < 1) { 2157 FLAG_marking_threads = SystemThreadManager::
2144 FLAG_marking_threads = 1; 2158 NumberOfParallelSystemThreads(
2145 } 2159 SystemThreadManager::PARALLEL_MARKING);
2160 }
2161 if (FLAG_marking_threads > 0) {
2146 marking_thread_ = new MarkingThread*[FLAG_marking_threads]; 2162 marking_thread_ = new MarkingThread*[FLAG_marking_threads];
2147 for (int i = 0; i < FLAG_marking_threads; i++) { 2163 for (int i = 0; i < FLAG_marking_threads; i++) {
2148 marking_thread_[i] = new MarkingThread(this); 2164 marking_thread_[i] = new MarkingThread(this);
2149 marking_thread_[i]->Start(); 2165 marking_thread_[i]->Start();
2150 } 2166 }
2151 } 2167 }
2152 2168
2153 if (FLAG_parallel_sweeping || FLAG_concurrent_sweeping) { 2169 if (FLAG_sweeper_threads == 0) {
2154 if (FLAG_sweeper_threads < 1) { 2170 if (FLAG_concurrent_sweeping) {
2155 FLAG_sweeper_threads = 1; 2171 FLAG_sweeper_threads = SystemThreadManager::
2172 NumberOfParallelSystemThreads(
2173 SystemThreadManager::CONCURRENT_SWEEPING);
2174 } else if (FLAG_parallel_sweeping) {
2175 FLAG_sweeper_threads = SystemThreadManager::
2176 NumberOfParallelSystemThreads(
2177 SystemThreadManager::PARALLEL_SWEEPING);
2156 } 2178 }
2179 }
2180 if (FLAG_sweeper_threads > 0) {
2157 sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads]; 2181 sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads];
2158 for (int i = 0; i < FLAG_sweeper_threads; i++) { 2182 for (int i = 0; i < FLAG_sweeper_threads; i++) {
2159 sweeper_thread_[i] = new SweeperThread(this); 2183 sweeper_thread_[i] = new SweeperThread(this);
2160 sweeper_thread_[i]->Start(); 2184 sweeper_thread_[i]->Start();
2161 } 2185 }
2162 } 2186 }
2163 return true; 2187 return true;
2164 } 2188 }
2165 2189
2166 2190
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 2305
2282 #ifdef DEBUG 2306 #ifdef DEBUG
2283 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 2307 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
2284 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 2308 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
2285 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 2309 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
2286 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 2310 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
2287 #undef ISOLATE_FIELD_OFFSET 2311 #undef ISOLATE_FIELD_OFFSET
2288 #endif 2312 #endif
2289 2313
2290 } } // namespace v8::internal 2314 } } // namespace v8::internal
OLDNEW
« 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