libcorkscrew native stacks, mutex ranking, and better ScopedThreadListLock.
This change uses libcorkscrew to show native stacks for threads in kNative or,
unlike dalvikvm, kVmWait --- working on the runtime directly I've found it
somewhat useful to be able to see _which_ internal resource we're waiting on.
We can always take that back out (or make it oatexecd-only) if it turns out to
be too noisy/confusing for app developers.
This change also lets us rank mutexes and enforce -- in oatexecd -- that you
take locks in a specific order.
Both of these helped me test the third novelty: removing the heap locking from
ScopedThreadListLock. I've manually inspected all the callers and added a
ScopedHeapLock where I think one is necessary. In manual testing, this makes
jdb a lot less prone to locking us up. There still seems to be a problem with
the JDWP VirtualMachine.Resume command, but I'll look at that separately. This
is a big enough and potentially disruptive enough change already.
Change-Id: Iad974358919d0e00674662dc8a69cc65878cfb5c
diff --git a/src/mutex.h b/src/mutex.h
index f4658fb..b4774d7 100644
--- a/src/mutex.h
+++ b/src/mutex.h
@@ -19,6 +19,8 @@
#include <pthread.h>
#include <stdint.h>
+
+#include <iosfwd>
#include <string>
#include "logging.h"
@@ -26,9 +28,18 @@
namespace art {
+enum MutexRank {
+ kNoMutexRank = -1,
+ kHeapLock = 0,
+ kThreadListLock = 1,
+ kThreadSuspendCountLock = 2,
+ kMaxMutexRank = kThreadSuspendCountLock,
+};
+std::ostream& operator<<(std::ostream& os, const MutexRank& rhs);
+
class Mutex {
public:
- explicit Mutex(const char* name);
+ explicit Mutex(const char* name, MutexRank rank = kNoMutexRank);
~Mutex();
void Lock();
@@ -70,9 +81,9 @@
uint32_t GetDepth();
- std::string name_;
-
pthread_mutex_t mutex_;
+ std::string name_;
+ MutexRank rank_;
DISALLOW_COPY_AND_ASSIGN(Mutex);
};