Fast JNI support.

Use a modifier to signal a native method is a fast JNI method. If the
modifier is set then don't perform runnable transitions.

Change-Id: I7835b4d837bfdd1cb8e2d54b919c0d5e6cf90499
diff --git a/runtime/mirror/art_method.cc b/runtime/mirror/art_method.cc
index cd05f41..f5c0e9f 100644
--- a/runtime/mirror/art_method.cc
+++ b/runtime/mirror/art_method.cc
@@ -306,11 +306,15 @@
 }
 
 extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject);
-void ArtMethod::RegisterNative(Thread* self, const void* native_method) {
+void ArtMethod::RegisterNative(Thread* self, const void* native_method, bool is_fast) {
   DCHECK(Thread::Current() == self);
   CHECK(IsNative()) << PrettyMethod(this);
+  CHECK(!IsFastNative()) << PrettyMethod(this);
   CHECK(native_method != NULL) << PrettyMethod(this);
   if (!self->GetJniEnv()->vm->work_around_app_jni_bugs) {
+    if (is_fast) {
+      SetAccessFlags(GetAccessFlags() | kAccFastNative);
+    }
     SetNativeMethod(native_method);
   } else {
     // We've been asked to associate this method with the given native method but are working
@@ -328,9 +332,9 @@
 }
 
 void ArtMethod::UnregisterNative(Thread* self) {
-  CHECK(IsNative()) << PrettyMethod(this);
+  CHECK(IsNative() && !IsFastNative()) << PrettyMethod(this);
   // restore stub to lookup native pointer via dlsym
-  RegisterNative(self, GetJniDlsymLookupStub());
+  RegisterNative(self, GetJniDlsymLookupStub(), false);
 }
 
 void ArtMethod::SetNativeMethod(const void* native_method) {