Initialize the rest of libcore's native code.

This native code requires NewGlobalRef, so this patch also implements
NewLocalRef/DeleteLocalRef, NewGlobalRef/DeleteGlobalRef, and
NewWeakGlobalRef/DeleteWeakGlobalRef.

(The assembler change is because "math.h" also defines OVERFLOW. A slight
change in #include ordering caused the names to conflict.)

Change-Id: Ifbf3b532ec3b0896bd7507d2881c6b77b64f01e7
diff --git a/src/runtime.cc b/src/runtime.cc
index 335396d..864b257 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7,6 +7,7 @@
 #include <limits>
 #include <vector>
 
+#include "JniConstants.h"
 #include "class_linker.h"
 #include "heap.h"
 #include "jni_internal.h"
@@ -312,7 +313,12 @@
 
   // Most JNI libraries can just use System.loadLibrary, but you can't
   // if you're the library that implements System.loadLibrary!
+  Thread* self = Thread::Current();
+  Thread::State old_state = self->GetState();
+  self->SetState(Thread::kNative);
+  JniConstants::init(self->GetJniEnv());
   LoadJniLibrary(instance_->GetJavaVM(), "javacore");
+  self->SetState(old_state);
 
   return instance_;
 }