Global lock levels.

Introduce the notion of the mutators/GC being a shared-exclusive (aka
reader-writer) lock. Introduce globally ordered locks, analysable by
annotalysis, statically at compile time. Add locking attributes to
methods.

More subtly, remove the heap_lock_ and split between various locks that
are held for smaller periods (where work doesn't get blocked). Remove
buggy Dalvik style thread transitions. Make GC use CMS in all cases when
concurrent is enabled. Fix bug where suspend counts rather than debug
suspend counts were sent to JDWP. Move the PathClassLoader to
WellKnownClasses. In debugger refactor calls to send request and
possibly suspend. Break apart different VmWait thread states. Move
identity hash code to a shared method.

Change-Id: Icdbfc3ce3fcccd14341860ac7305d8e97b51f5c6
diff --git a/src/trace.h b/src/trace.h
index 0042fc2..c60ae15 100644
--- a/src/trace.h
+++ b/src/trace.h
@@ -65,7 +65,7 @@
 
   static void Start(const char* trace_filename, int trace_fd, int buffer_size, int flags, bool direct_to_ddms);
   static void Stop();
-  static void Shutdown();
+  static void Shutdown() NO_THREAD_SAFETY_ANALYSIS;  // TODO: implement appropriate locking.
 
   bool UseWallClock();
   bool UseThreadCpuClock();
@@ -83,18 +83,18 @@
   explicit Trace(File* trace_file, int buffer_size, int flags);
 
   void BeginTracing();
-  void FinishTracing();
+  void FinishTracing() SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
 
   // Replaces code of each method with a pointer to a stub for method tracing.
   void InstallStubs();
 
   // Restores original code for each method and fixes the return values of each thread's stack.
-  void UninstallStubs();
+  void UninstallStubs() LOCKS_EXCLUDED(GlobalSynchronization::thread_list_lock_);
 
   // Methods to output traced methods and threads.
   void GetVisitedMethods(size_t end_offset);
-  void DumpMethodList(std::ostream& os);
-  void DumpThreadList(std::ostream& os);
+  void DumpMethodList(std::ostream& os) SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+  void DumpThreadList(std::ostream& os) LOCKS_EXCLUDED(GlobalSynchronization::thread_list_lock_);
 
   // Maps a method to its original code pointer.
   SafeMap<const Method*, const void*> saved_code_map_;