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

Side by Side Diff: runtime/vm/os_thread_linux.cc

Issue 2680123004: VM: Teach GetAndValidateIsolateStackBounds(...) to fallback to OS thread stack bounds. (Closed)
Patch Set: Done Created 3 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
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/globals.h" // NOLINT 5 #include "platform/globals.h" // NOLINT
6 6
7 #if defined(TARGET_OS_LINUX) 7 #if defined(TARGET_OS_LINUX)
8 8
9 #include "vm/os_thread.h" 9 #include "vm/os_thread.h"
10 10
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { 227 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) {
228 return static_cast<ThreadId>(id); 228 return static_cast<ThreadId>(id);
229 } 229 }
230 230
231 231
232 bool OSThread::Compare(ThreadId a, ThreadId b) { 232 bool OSThread::Compare(ThreadId a, ThreadId b) {
233 return pthread_equal(a, b) != 0; 233 return pthread_equal(a, b) != 0;
234 } 234 }
235 235
236 236
237 bool OSThread::GetCurrentStackBounds(uword* lower, uword* upper) {
238 pthread_attr_t attr;
239 if (pthread_getattr_np(pthread_self(), &attr)) {
240 return false;
241 }
242
243 void* base;
244 size_t size;
245 int error = pthread_attr_getstack(&attr, &base, &size);
246 pthread_attr_destroy(&attr);
247 if (error) {
248 return false;
249 }
250
251 *lower = reinterpret_cast<uword>(base);
252 *upper = *lower + size;
253 return true;
254 }
255
256
237 Mutex::Mutex() { 257 Mutex::Mutex() {
238 pthread_mutexattr_t attr; 258 pthread_mutexattr_t attr;
239 int result = pthread_mutexattr_init(&attr); 259 int result = pthread_mutexattr_init(&attr);
240 VALIDATE_PTHREAD_RESULT(result); 260 VALIDATE_PTHREAD_RESULT(result);
241 261
242 #if defined(DEBUG) 262 #if defined(DEBUG)
243 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 263 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
244 VALIDATE_PTHREAD_RESULT(result); 264 VALIDATE_PTHREAD_RESULT(result);
245 #endif // defined(DEBUG) 265 #endif // defined(DEBUG)
246 266
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 void Monitor::NotifyAll() { 470 void Monitor::NotifyAll() {
451 // When running with assertions enabled we track the owner. 471 // When running with assertions enabled we track the owner.
452 ASSERT(IsOwnedByCurrentThread()); 472 ASSERT(IsOwnedByCurrentThread());
453 int result = pthread_cond_broadcast(data_.cond()); 473 int result = pthread_cond_broadcast(data_.cond());
454 VALIDATE_PTHREAD_RESULT(result); 474 VALIDATE_PTHREAD_RESULT(result);
455 } 475 }
456 476
457 } // namespace dart 477 } // namespace dart
458 478
459 #endif // defined(TARGET_OS_LINUX) 479 #endif // defined(TARGET_OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698