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/oat_writer.cc b/src/oat_writer.cc
index 013a561..0546f2b 100644
--- a/src/oat_writer.cc
+++ b/src/oat_writer.cc
@@ -23,13 +23,14 @@
 #include "file.h"
 #include "os.h"
 #include "safe_map.h"
+#include "scoped_thread_state_change.h"
 #include "space.h"
 #include "stl_util.h"
 
 namespace art {
 
 bool OatWriter::Create(File* file,
-                       ClassLoader* class_loader,
+                       jobject class_loader,
                        const std::vector<const DexFile*>& dex_files,
                        uint32_t image_file_location_checksum,
                        const std::string& image_file_location,
@@ -45,7 +46,7 @@
 OatWriter::OatWriter(const std::vector<const DexFile*>& dex_files,
                      uint32_t image_file_location_checksum,
                      const std::string& image_file_location,
-                     ClassLoader* class_loader,
+                     jobject class_loader,
                      const Compiler& compiler) {
   compiler_ = &compiler;
   class_loader_ = class_loader;
@@ -380,8 +381,10 @@
   if (compiler_->IsImage()) {
     ClassLinker* linker = Runtime::Current()->GetClassLinker();
     DexCache* dex_cache = linker->FindDexCache(*dex_file);
-    Method* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader_,
-                                           is_direct);
+    // Unchecked as we hold mutator_lock_ on entry.
+    ScopedObjectAccessUnchecked soa(Thread::Current());
+    Method* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache,
+                                           soa.Decode<ClassLoader*>(class_loader_), is_direct);
     CHECK(method != NULL);
     method->SetFrameSizeInBytes(frame_size_in_bytes);
     method->SetCoreSpillMask(core_spill_mask);