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

Side by Side Diff: platform/thread_macos.cc

Issue 10544170: Have the stack overflow code use the correct stack size set by the platform/thread.h (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 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 | « platform/thread_linux.cc ('k') | platform/thread_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/thread.h" 5 #include "platform/thread.h"
6 6
7 #include <sys/errno.h> 7 #include <sys/errno.h>
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 65
66 int Thread::Start(ThreadStartFunction function, uword parameter) { 66 int Thread::Start(ThreadStartFunction function, uword parameter) {
67 pthread_attr_t attr; 67 pthread_attr_t attr;
68 int result = pthread_attr_init(&attr); 68 int result = pthread_attr_init(&attr);
69 RETURN_ON_PTHREAD_FAILURE(result); 69 RETURN_ON_PTHREAD_FAILURE(result);
70 70
71 result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 71 result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
72 RETURN_ON_PTHREAD_FAILURE(result); 72 RETURN_ON_PTHREAD_FAILURE(result);
73 73
74 #if DEBUG 74 result = pthread_attr_setstacksize(&attr, Thread::GetMaxStackSize());
75 const int kStackSize = (128 * KB);
76 #else
77 const int kStackSize = (64 * KB);
78 #endif
79 result = pthread_attr_setstacksize(&attr, kStackSize);
80 RETURN_ON_PTHREAD_FAILURE(result); 75 RETURN_ON_PTHREAD_FAILURE(result);
81 76
82 ThreadStartData* data = new ThreadStartData(function, parameter); 77 ThreadStartData* data = new ThreadStartData(function, parameter);
83 78
84 pthread_t tid; 79 pthread_t tid;
85 result = pthread_create(&tid, &attr, ThreadStart, data); 80 result = pthread_create(&tid, &attr, ThreadStart, data);
86 RETURN_ON_PTHREAD_FAILURE(result); 81 RETURN_ON_PTHREAD_FAILURE(result);
87 82
88 result = pthread_attr_destroy(&attr); 83 result = pthread_attr_destroy(&attr);
89 RETURN_ON_PTHREAD_FAILURE(result); 84 RETURN_ON_PTHREAD_FAILURE(result);
(...skipping 21 matching lines...) Expand all
111 } 106 }
112 107
113 108
114 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { 109 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) {
115 ASSERT(key != kUnsetThreadLocalKey); 110 ASSERT(key != kUnsetThreadLocalKey);
116 int result = pthread_setspecific(key, reinterpret_cast<void*>(value)); 111 int result = pthread_setspecific(key, reinterpret_cast<void*>(value));
117 VALIDATE_PTHREAD_RESULT(result); 112 VALIDATE_PTHREAD_RESULT(result);
118 } 113 }
119 114
120 115
116 intptr_t Thread::GetMaxStackSize() {
117 const int kStackSize = (256 * KB);
118 return kStackSize;
119 }
120
121
121 Mutex::Mutex() { 122 Mutex::Mutex() {
122 pthread_mutexattr_t attr; 123 pthread_mutexattr_t attr;
123 int result = pthread_mutexattr_init(&attr); 124 int result = pthread_mutexattr_init(&attr);
124 VALIDATE_PTHREAD_RESULT(result); 125 VALIDATE_PTHREAD_RESULT(result);
125 126
126 #if defined(DEBUG) 127 #if defined(DEBUG)
127 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 128 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
128 VALIDATE_PTHREAD_RESULT(result); 129 VALIDATE_PTHREAD_RESULT(result);
129 #endif // defined(DEBUG) 130 #endif // defined(DEBUG)
130 131
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 251 }
251 252
252 253
253 void Monitor::NotifyAll() { 254 void Monitor::NotifyAll() {
254 // TODO(iposva): Do we need to track lock owners? 255 // TODO(iposva): Do we need to track lock owners?
255 int result = pthread_cond_broadcast(data_.cond()); 256 int result = pthread_cond_broadcast(data_.cond());
256 VALIDATE_PTHREAD_RESULT(result); 257 VALIDATE_PTHREAD_RESULT(result);
257 } 258 }
258 259
259 } // namespace dart 260 } // namespace dart
OLDNEW
« no previous file with comments | « platform/thread_linux.cc ('k') | platform/thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698