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/native/java_lang_String.cc b/src/native/java_lang_String.cc
index 96fcf96..bfdc31a 100644
--- a/src/native/java_lang_String.cc
+++ b/src/native/java_lang_String.cc
@@ -16,7 +16,7 @@
 
 #include "jni_internal.h"
 #include "object.h"
-#include "scoped_jni_thread_state.h"
+#include "scoped_thread_state_change.h"
 
 #ifdef HAVE__MEMCMP16
 // "count" is in 16-bit units.
@@ -36,9 +36,9 @@
 namespace art {
 
 static jint String_compareTo(JNIEnv* env, jobject javaThis, jobject javaRhs) {
-  ScopedJniThreadState ts(env);
-  String* lhs = ts.Decode<String*>(javaThis);
-  String* rhs = ts.Decode<String*>(javaRhs);
+  ScopedObjectAccess soa(env);
+  String* lhs = soa.Decode<String*>(javaThis);
+  String* rhs = soa.Decode<String*>(javaRhs);
 
   if (rhs == NULL) {
     Thread::Current()->ThrowNewException("Ljava/lang/NullPointerException;", "rhs == null");
@@ -70,11 +70,11 @@
 }
 
 static jint String_fastIndexOf(JNIEnv* env, jobject java_this, jint ch, jint start) {
-  ScopedJniThreadState ts(env);
+  ScopedObjectAccess soa(env);
   // This method does not handle supplementary characters. They're dealt with in managed code.
   DCHECK_LE(ch, 0xffff);
 
-  String* s = ts.Decode<String*>(java_this);
+  String* s = soa.Decode<String*>(java_this);
 
   jint count = s->GetLength();
   if (start < 0) {
@@ -96,10 +96,10 @@
 }
 
 static jstring String_intern(JNIEnv* env, jobject javaThis) {
-  ScopedJniThreadState ts(env);
-  String* s = ts.Decode<String*>(javaThis);
+  ScopedObjectAccess soa(env);
+  String* s = soa.Decode<String*>(javaThis);
   String* result = s->Intern();
-  return ts.AddLocalReference<jstring>(result);
+  return soa.AddLocalReference<jstring>(result);
 }
 
 static JNINativeMethod gMethods[] = {