Improve performance of JNI field operations.
Change improves performance of JniField Fadden test by around 25%, we're still
2x slower than Dalvik.
Aggressively inline ScopedObjectAccess, Thread::SetState and field helpers.
If we're not contention logging don't call MilliTime (avoids a double register
spill).
Remove (broken?) thread checks in scoped object access, they are redundant with
ones being performed in check JNI.
Change-Id: I128eed1e4205d4d540d5c6f430ef9e3853745585
diff --git a/src/thread-inl.h b/src/thread-inl.h
index 93aa10e..cf92a1c 100644
--- a/src/thread-inl.h
+++ b/src/thread-inl.h
@@ -24,6 +24,16 @@
namespace art {
+inline ThreadState Thread::SetState(ThreadState new_state) {
+ // Cannot use this code to change into Runnable as changing to Runnable should fail if
+ // old_state_and_flags.suspend_request is true.
+ DCHECK_NE(new_state, kRunnable);
+ DCHECK_EQ(this, Thread::Current());
+ union StateAndFlags old_state_and_flags = state_and_flags_;
+ state_and_flags_.as_struct.state = new_state;
+ return static_cast<ThreadState>(old_state_and_flags.as_struct.state);
+}
+
inline void Thread::AssertThreadSuspensionIsAllowable(bool check_locks) const {
#ifdef NDEBUG
UNUSED(check_locks); // Keep GCC happy about unused parameters.