Remove the useless "suspend count already zero" message for new threads.
We can actually detect the expected case of this warning ourselves, and
not emit it. Then we can upgrade the WARNING to a FATAL.
I also tripped over the fact that the operator<< for Thread::State was out
of date, so I've moved the Thread enums up to namespace scope so the script
can automatically generate correct operator<< implementations for us. (All
the high-numbered thread states have been off by one for a couple of weeks.)
Change-Id: I5de573d33d641e5a3cba87b370e9620c8c66e633
diff --git a/src/runtime.cc b/src/runtime.cc
index 1d0ab8f..12f7c8b 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -175,7 +175,7 @@
void Runtime::CallExitHook(jint status) {
if (exit_ != NULL) {
- ScopedThreadStateChange tsc(Thread::Current(), Thread::kNative);
+ ScopedThreadStateChange tsc(Thread::Current(), kNative);
exit_(status);
LOG(WARNING) << "Exit hook returned instead of exiting!";
}
@@ -499,7 +499,7 @@
Thread* self = Thread::Current();
// Must be in the kNative state for calling native methods.
- CHECK_EQ(self->GetState(), Thread::kNative);
+ CHECK_EQ(self->GetState(), kNative);
JNIEnv* env = self->GetJniEnv();
ScopedLocalRef<jclass> ClassLoader_class(env, env->FindClass("java/lang/ClassLoader"));
@@ -533,7 +533,7 @@
class_linker_->RelocateExecutable();
// Restore main thread state to kNative as expected by native code
- Thread::Current()->SetState(Thread::kNative);
+ Thread::Current()->SetState(kNative);
started_ = true;
@@ -578,7 +578,7 @@
Thread* self = Thread::Current();
// Must be in the kNative state for calling native methods.
- CHECK_EQ(self->GetState(), Thread::kNative);
+ CHECK_EQ(self->GetState(), kNative);
JNIEnv* env = self->GetJniEnv();
ScopedLocalRef<jclass> c(env, env->FindClass("java/lang/Daemons"));
@@ -649,7 +649,7 @@
Thread::Attach("main", false, NULL);
// Set us to runnable so tools using a runtime can allocate and GC by default
- Thread::Current()->SetState(Thread::kRunnable);
+ Thread::Current()->SetState(kRunnable);
// Now we're attached, we can take the heap lock and validate the heap.
GetHeap()->EnableObjectValidation();
@@ -682,7 +682,7 @@
JNIEnv* env = self->GetJniEnv();
// Must be in the kNative state for calling native methods (JNI_OnLoad code).
- CHECK_EQ(self->GetState(), Thread::kNative);
+ CHECK_EQ(self->GetState(), kNative);
// First set up JniConstants, which is used by both the runtime's built-in native
// methods and libcore.