| Index: runtime/vm/thread_macos.cc
|
| ===================================================================
|
| --- runtime/vm/thread_macos.cc (revision 39381)
|
| +++ runtime/vm/thread_macos.cc (working copy)
|
| @@ -19,6 +19,7 @@
|
| #include <mach/thread_act.h> // NOLINT
|
|
|
| #include "platform/assert.h"
|
| +#include "vm/isolate.h"
|
|
|
| namespace dart {
|
|
|
| @@ -198,6 +199,11 @@
|
|
|
| result = pthread_mutexattr_destroy(&attr);
|
| VALIDATE_PTHREAD_RESULT(result);
|
| +
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + owner_ = NULL;
|
| +#endif // defined(DEBUG)
|
| }
|
|
|
|
|
| @@ -205,6 +211,11 @@
|
| int result = pthread_mutex_destroy(data_.mutex());
|
| // Verify that the pthread_mutex was destroyed.
|
| VALIDATE_PTHREAD_RESULT(result);
|
| +
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + ASSERT(owner_ == NULL);
|
| +#endif // defined(DEBUG)
|
| }
|
|
|
|
|
| @@ -213,7 +224,10 @@
|
| // Specifically check for dead lock to help debugging.
|
| ASSERT(result != EDEADLK);
|
| ASSERT(result == 0); // Verify no other errors.
|
| - // TODO(iposva): Do we need to track lock owners?
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + owner_ = Isolate::Current();
|
| +#endif // defined(DEBUG)
|
| }
|
|
|
|
|
| @@ -224,13 +238,20 @@
|
| return false;
|
| }
|
| ASSERT(result == 0); // Verify no other errors.
|
| - // TODO(iposva): Do we need to track lock owners?
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + owner_ = Isolate::Current();
|
| +#endif // defined(DEBUG)
|
| return true;
|
| }
|
|
|
|
|
| void Mutex::Unlock() {
|
| - // TODO(iposva): Do we need to track lock owners?
|
| + // When running with assertions enabled we do track the owner.
|
| +#if defined(DEBUG)
|
| + ASSERT(owner_ == Isolate::Current());
|
| + owner_ = NULL;
|
| +#endif // defined(DEBUG)
|
| int result = pthread_mutex_unlock(data_.mutex());
|
| // Specifically check for wrong thread unlocking to aid debugging.
|
| ASSERT(result != EPERM);
|
|
|