| Index: runtime/vm/os_thread_macos.cc
|
| diff --git a/runtime/vm/os_thread_macos.cc b/runtime/vm/os_thread_macos.cc
|
| index 67b18513c380de9a2f94ae145cefd4ca4f3485b2..ec7b3942fa9b8a640b8418f5b06ba3b292f1b685 100644
|
| --- a/runtime/vm/os_thread_macos.cc
|
| +++ b/runtime/vm/os_thread_macos.cc
|
| @@ -7,16 +7,16 @@
|
|
|
| #include "vm/os_thread.h"
|
|
|
| -#include <sys/errno.h> // NOLINT
|
| -#include <sys/types.h> // NOLINT
|
| -#include <sys/sysctl.h> // NOLINT
|
| -#include <mach/mach_init.h> // NOLINT
|
| #include <mach/mach_host.h> // NOLINT
|
| +#include <mach/mach_init.h> // NOLINT
|
| #include <mach/mach_port.h> // NOLINT
|
| #include <mach/mach_traps.h> // NOLINT
|
| #include <mach/task_info.h> // NOLINT
|
| -#include <mach/thread_info.h> // NOLINT
|
| #include <mach/thread_act.h> // NOLINT
|
| +#include <mach/thread_info.h> // NOLINT
|
| +#include <sys/errno.h> // NOLINT
|
| +#include <sys/sysctl.h> // NOLINT
|
| +#include <sys/types.h> // NOLINT
|
|
|
| #include "platform/assert.h"
|
| #include "platform/utils.h"
|
| @@ -34,7 +34,6 @@ namespace dart {
|
| FATAL2("pthread error: %d (%s)", result, error_message); \
|
| }
|
|
|
| -
|
| #if defined(DEBUG)
|
| #define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result)
|
| #else
|
| @@ -42,7 +41,6 @@ namespace dart {
|
| #define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0)
|
| #endif
|
|
|
| -
|
| #ifdef DEBUG
|
| #define RETURN_ON_PTHREAD_FAILURE(result) \
|
| if (result != 0) { \
|
| @@ -58,7 +56,6 @@ namespace dart {
|
| if (result != 0) return result;
|
| #endif
|
|
|
| -
|
| class ThreadStartData {
|
| public:
|
| ThreadStartData(const char* name,
|
| @@ -78,7 +75,6 @@ class ThreadStartData {
|
| DISALLOW_COPY_AND_ASSIGN(ThreadStartData);
|
| };
|
|
|
| -
|
| // Dispatch to the thread start function provided by the caller. This trampoline
|
| // is used to ensure that the thread is properly destroyed if the thread just
|
| // exits.
|
| @@ -103,7 +99,6 @@ static void* ThreadStart(void* data_ptr) {
|
| return NULL;
|
| }
|
|
|
| -
|
| int OSThread::Start(const char* name,
|
| ThreadStartFunction function,
|
| uword parameter) {
|
| @@ -126,12 +121,10 @@ int OSThread::Start(const char* name,
|
| return 0;
|
| }
|
|
|
| -
|
| const ThreadId OSThread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL);
|
| const ThreadJoinId OSThread::kInvalidThreadJoinId =
|
| reinterpret_cast<ThreadJoinId>(NULL);
|
|
|
| -
|
| ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
|
| pthread_key_t key = kUnsetThreadLocalKey;
|
| int result = pthread_key_create(&key, destructor);
|
| @@ -140,39 +133,33 @@ ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
|
| return key;
|
| }
|
|
|
| -
|
| void OSThread::DeleteThreadLocal(ThreadLocalKey key) {
|
| ASSERT(key != kUnsetThreadLocalKey);
|
| int result = pthread_key_delete(key);
|
| VALIDATE_PTHREAD_RESULT(result);
|
| }
|
|
|
| -
|
| void OSThread::SetThreadLocal(ThreadLocalKey key, uword value) {
|
| ASSERT(key != kUnsetThreadLocalKey);
|
| int result = pthread_setspecific(key, reinterpret_cast<void*>(value));
|
| VALIDATE_PTHREAD_RESULT(result);
|
| }
|
|
|
| -
|
| intptr_t OSThread::GetMaxStackSize() {
|
| const int kStackSize = (128 * kWordSize * KB);
|
| return kStackSize;
|
| }
|
|
|
| -
|
| ThreadId OSThread::GetCurrentThreadId() {
|
| return pthread_self();
|
| }
|
|
|
| -
|
| #ifndef PRODUCT
|
| ThreadId OSThread::GetCurrentThreadTraceId() {
|
| return ThreadIdFromIntPtr(pthread_mach_thread_np(pthread_self()));
|
| }
|
| #endif // PRODUCT
|
|
|
| -
|
| ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) {
|
| ASSERT(thread != NULL);
|
| // Make sure we're filling in the join id for the current thread.
|
| @@ -186,36 +173,30 @@ ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) {
|
| return id;
|
| }
|
|
|
| -
|
| void OSThread::Join(ThreadJoinId id) {
|
| int result = pthread_join(id, NULL);
|
| ASSERT(result == 0);
|
| }
|
|
|
| -
|
| intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) {
|
| ASSERT(sizeof(id) == sizeof(intptr_t));
|
| return reinterpret_cast<intptr_t>(id);
|
| }
|
|
|
| -
|
| ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) {
|
| return reinterpret_cast<ThreadId>(id);
|
| }
|
|
|
| -
|
| bool OSThread::Compare(ThreadId a, ThreadId b) {
|
| return pthread_equal(a, b) != 0;
|
| }
|
|
|
| -
|
| bool OSThread::GetCurrentStackBounds(uword* lower, uword* upper) {
|
| *upper = reinterpret_cast<uword>(pthread_get_stackaddr_np(pthread_self()));
|
| *lower = *upper - pthread_get_stacksize_np(pthread_self());
|
| return true;
|
| }
|
|
|
| -
|
| Mutex::Mutex() {
|
| pthread_mutexattr_t attr;
|
| int result = pthread_mutexattr_init(&attr);
|
| @@ -239,7 +220,6 @@ Mutex::Mutex() {
|
| #endif // defined(DEBUG)
|
| }
|
|
|
| -
|
| Mutex::~Mutex() {
|
| int result = pthread_mutex_destroy(data_.mutex());
|
| // Verify that the pthread_mutex was destroyed.
|
| @@ -251,7 +231,6 @@ Mutex::~Mutex() {
|
| #endif // defined(DEBUG)
|
| }
|
|
|
| -
|
| void Mutex::Lock() {
|
| int result = pthread_mutex_lock(data_.mutex());
|
| // Specifically check for dead lock to help debugging.
|
| @@ -263,7 +242,6 @@ void Mutex::Lock() {
|
| #endif // defined(DEBUG)
|
| }
|
|
|
| -
|
| bool Mutex::TryLock() {
|
| int result = pthread_mutex_trylock(data_.mutex());
|
| // Return false if the lock is busy and locking failed.
|
| @@ -278,7 +256,6 @@ bool Mutex::TryLock() {
|
| return true;
|
| }
|
|
|
| -
|
| void Mutex::Unlock() {
|
| #if defined(DEBUG)
|
| // When running with assertions enabled we do track the owner.
|
| @@ -291,7 +268,6 @@ void Mutex::Unlock() {
|
| ASSERT_PTHREAD_SUCCESS(result); // Verify no other errors.
|
| }
|
|
|
| -
|
| Monitor::Monitor() {
|
| pthread_mutexattr_t attr;
|
| int result = pthread_mutexattr_init(&attr);
|
| @@ -317,7 +293,6 @@ Monitor::Monitor() {
|
| #endif // defined(DEBUG)
|
| }
|
|
|
| -
|
| Monitor::~Monitor() {
|
| #if defined(DEBUG)
|
| // When running with assertions enabled we track the owner.
|
| @@ -331,7 +306,6 @@ Monitor::~Monitor() {
|
| VALIDATE_PTHREAD_RESULT(result);
|
| }
|
|
|
| -
|
| bool Monitor::TryEnter() {
|
| int result = pthread_mutex_trylock(data_.mutex());
|
| // Return false if the lock is busy and locking failed.
|
| @@ -347,7 +321,6 @@ bool Monitor::TryEnter() {
|
| return true;
|
| }
|
|
|
| -
|
| void Monitor::Enter() {
|
| int result = pthread_mutex_lock(data_.mutex());
|
| VALIDATE_PTHREAD_RESULT(result);
|
| @@ -359,7 +332,6 @@ void Monitor::Enter() {
|
| #endif // defined(DEBUG)
|
| }
|
|
|
| -
|
| void Monitor::Exit() {
|
| #if defined(DEBUG)
|
| // When running with assertions enabled we track the owner.
|
| @@ -371,12 +343,10 @@ void Monitor::Exit() {
|
| VALIDATE_PTHREAD_RESULT(result);
|
| }
|
|
|
| -
|
| Monitor::WaitResult Monitor::Wait(int64_t millis) {
|
| return WaitMicros(millis * kMicrosecondsPerMillisecond);
|
| }
|
|
|
| -
|
| Monitor::WaitResult Monitor::WaitMicros(int64_t micros) {
|
| #if defined(DEBUG)
|
| // When running with assertions enabled we track the owner.
|
| @@ -418,7 +388,6 @@ Monitor::WaitResult Monitor::WaitMicros(int64_t micros) {
|
| return retval;
|
| }
|
|
|
| -
|
| void Monitor::Notify() {
|
| // When running with assertions enabled we track the owner.
|
| ASSERT(IsOwnedByCurrentThread());
|
| @@ -426,7 +395,6 @@ void Monitor::Notify() {
|
| VALIDATE_PTHREAD_RESULT(result);
|
| }
|
|
|
| -
|
| void Monitor::NotifyAll() {
|
| // When running with assertions enabled we track the owner.
|
| ASSERT(IsOwnedByCurrentThread());
|
|
|