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

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, 9 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_threads = Min(OS::NumberOfCores(), kMaxThreads);
137 ASSERT(number_of_threads > 0);
138 if (number_of_threads == 1) {
139 return 1;
140 }
141 if (type == PARALLEL_SWEEPING) {
142 return number_of_threads;
143 } else if (type == CONCURRENT_SWEEPING) {
144 return number_of_threads - 1;
145 } else if (type == PARALLEL_MARKING) {
146 return number_of_threads;
147 }
148 return 1;
149 }
150
151
134 // Create a dummy thread that will wait forever on a semaphore. The only 152 // 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 153 // 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). 154 // into for use by a stacks only core dump (aka minidump).
137 class PreallocatedMemoryThread: public Thread { 155 class PreallocatedMemoryThread: public Thread {
138 public: 156 public:
139 char* data() { 157 char* data() {
140 if (data_ready_semaphore_ != NULL) { 158 if (data_ready_semaphore_ != NULL) {
141 // Initial access is guarded until the data has been published. 159 // Initial access is guarded until the data has been published.
142 data_ready_semaphore_->Wait(); 160 data_ready_semaphore_->Wait();
143 delete data_ready_semaphore_; 161 delete data_ready_semaphore_;
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 1764
1747 void Isolate::GlobalTearDown() { 1765 void Isolate::GlobalTearDown() {
1748 delete thread_data_table_; 1766 delete thread_data_table_;
1749 } 1767 }
1750 1768
1751 1769
1752 void Isolate::Deinit() { 1770 void Isolate::Deinit() {
1753 if (state_ == INITIALIZED) { 1771 if (state_ == INITIALIZED) {
1754 TRACE_ISOLATE(deinit); 1772 TRACE_ISOLATE(deinit);
1755 1773
1756 if (FLAG_concurrent_sweeping || FLAG_parallel_sweeping) { 1774 if (FLAG_sweeper_threads > 0) {
1757 for (int i = 0; i < FLAG_sweeper_threads; i++) { 1775 for (int i = 0; i < FLAG_sweeper_threads; i++) {
1758 sweeper_thread_[i]->Stop(); 1776 sweeper_thread_[i]->Stop();
1759 delete sweeper_thread_[i]; 1777 delete sweeper_thread_[i];
1760 } 1778 }
1761 delete[] sweeper_thread_; 1779 delete[] sweeper_thread_;
1762 } 1780 }
1763 1781
1764 if (FLAG_parallel_marking) { 1782 if (FLAG_marking_threads > 0) {
1765 for (int i = 0; i < FLAG_marking_threads; i++) { 1783 for (int i = 0; i < FLAG_marking_threads; i++) {
1766 marking_thread_[i]->Stop(); 1784 marking_thread_[i]->Stop();
1767 delete marking_thread_[i]; 1785 delete marking_thread_[i];
1768 } 1786 }
1769 delete[] marking_thread_; 1787 delete[] marking_thread_;
1770 } 1788 }
1771 1789
1772 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Stop(); 1790 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Stop();
1773 1791
1774 if (FLAG_hydrogen_stats) HStatistics::Instance()->Print(); 1792 if (FLAG_hydrogen_stats) HStatistics::Instance()->Print();
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 2150
2133 if (!Serializer::enabled()) { 2151 if (!Serializer::enabled()) {
2134 // Ensure that the stub failure trampoline has been generated. 2152 // Ensure that the stub failure trampoline has been generated.
2135 HandleScope scope(this); 2153 HandleScope scope(this);
2136 CodeStub::GenerateFPStubs(); 2154 CodeStub::GenerateFPStubs();
2137 StubFailureTrampolineStub::GenerateAheadOfTime(); 2155 StubFailureTrampolineStub::GenerateAheadOfTime();
2138 } 2156 }
2139 2157
2140 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Start(); 2158 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Start();
2141 2159
2142 if (FLAG_parallel_marking) { 2160 if (FLAG_parallel_marking && FLAG_marking_threads == 0) {
2143 if (FLAG_marking_threads < 1) { 2161 FLAG_marking_threads = SystemThreadManager::
2144 FLAG_marking_threads = 1; 2162 NumberOfParallelSystemThreads(
2145 } 2163 SystemThreadManager::PARALLEL_MARKING);
2164 }
2165 if (FLAG_marking_threads > 0) {
2146 marking_thread_ = new MarkingThread*[FLAG_marking_threads]; 2166 marking_thread_ = new MarkingThread*[FLAG_marking_threads];
2147 for (int i = 0; i < FLAG_marking_threads; i++) { 2167 for (int i = 0; i < FLAG_marking_threads; i++) {
2148 marking_thread_[i] = new MarkingThread(this); 2168 marking_thread_[i] = new MarkingThread(this);
2149 marking_thread_[i]->Start(); 2169 marking_thread_[i]->Start();
2150 } 2170 }
2151 } 2171 }
2152 2172
2153 if (FLAG_parallel_sweeping || FLAG_concurrent_sweeping) { 2173 if (FLAG_sweeper_threads == 0) {
2154 if (FLAG_sweeper_threads < 1) { 2174 if (FLAG_concurrent_sweeping) {
2155 FLAG_sweeper_threads = 1; 2175 FLAG_sweeper_threads = SystemThreadManager::
2176 NumberOfParallelSystemThreads(
2177 SystemThreadManager::CONCURRENT_SWEEPING);
2178 } else if (FLAG_parallel_sweeping) {
2179 FLAG_sweeper_threads = SystemThreadManager::
2180 NumberOfParallelSystemThreads(
2181 SystemThreadManager::PARALLEL_SWEEPING);
2156 } 2182 }
2183 }
2184 if (FLAG_sweeper_threads > 0) {
2157 sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads]; 2185 sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads];
2158 for (int i = 0; i < FLAG_sweeper_threads; i++) { 2186 for (int i = 0; i < FLAG_sweeper_threads; i++) {
2159 sweeper_thread_[i] = new SweeperThread(this); 2187 sweeper_thread_[i] = new SweeperThread(this);
2160 sweeper_thread_[i]->Start(); 2188 sweeper_thread_[i]->Start();
2161 } 2189 }
2162 } 2190 }
2163 return true; 2191 return true;
2164 } 2192 }
2165 2193
2166 2194
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 2309
2282 #ifdef DEBUG 2310 #ifdef DEBUG
2283 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 2311 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
2284 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 2312 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
2285 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 2313 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
2286 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 2314 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
2287 #undef ISOLATE_FIELD_OFFSET 2315 #undef ISOLATE_FIELD_OFFSET
2288 #endif 2316 #endif
2289 2317
2290 } } // namespace v8::internal 2318 } } // 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