diff options
| author | 2021-11-22 16:31:57 +0000 | |
|---|---|---|
| committer | 2021-11-25 09:26:35 +0000 | |
| commit | ddf4fd3c37af160b5a1f7e83212b837f50e13e81 (patch) | |
| tree | 61f9223f33f3191f6e6416d717a3a13405235413 /runtime/interpreter/interpreter.cc | |
| parent | c3e004d1c8c58c1311beb1bcdd8211f5d4d5a009 (diff) | |
Always access Thread state and flags as 32-bit location.
Rewrite access to Thread's state and flags to use 32-bit
atomic operations. Avoid `volatile` accesses that prevent
compiler optimizations.
Change `ThreadState` and `ThreadFlag` to `enum class`es.
Golem results for art-opt-cc (higher is better):
linux-ia32 before after
NativeDowncallStaticNormal 28.162 35.323 (+25.43%)
NativeDowncallStaticNormal6 26.447 32.951 (+24.59%)
NativeDowncallStaticNormalRefs6
NativeDowncallVirtualNormal 27.972 35.027 (+25.22%)
NativeDowncallVirtualNormal6 26.096 32.131 (+23.13%)
NativeDowncallVirtualNormalRefs6 25.922 31.873 (+22.95%)
linux-x64 before after
NativeDowncallStaticNormal 26.987 34.380 (+27.40%)
NativeDowncallStaticNormal6 25.424 31.096 (+22.31%)
NativeDowncallStaticNormalRefs6 25.086 30.602 (+21.99%)
NativeDowncallVirtualNormal 26.812 33.234 (+23.95%)
NativeDowncallVirtualNormal6 25.086 30.617 (+22.05%)
NativeDowncallVirtualNormalRefs6 25.086 30.602 (+21.99%)
linux-armv7 before after
NativeDowncallStaticNormal 7.2394 7.9523 (+9.848%)
NativeDowncallStaticNormal6 6.8527 7.4888 (+9.283%)
NativeDowncallStaticNormalRefs6 6.3976 6.9444 (+8.547%)
NativeDowncallVirtualNormal 7.2081 7.9130 (+9.779%)
NativeDowncallVirtualNormal6 6.8527 7.4888 (+9.283%)
NativeDowncallVirtualNormalRefs6 6.3168 6.8527 (+8.483%)
linux-armv8 before after
NativeDowncallStaticNormal 7.0389 7.5973 (+7.933%)
NativeDowncallStaticNormal6 6.8527 7.3783 (+7.670%)
NativeDowncallStaticNormalRefs6 6.2924 6.8226 (+8.427%)
NativeDowncallVirtualNormal 6.8527 7.3783 (+7.670%)
NativeDowncallVirtualNormal6 6.5604 7.0423 (+7.344%)
NativeDowncallVirtualNormalRefs6 6.1408 6.5329 (+6.386%)
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: run-gtests.sh
Test: testrunner.py --target --optimizing --interpreter
Bug: 172332525
Bug: 143299880
Change-Id: Ib55d457ad8f5d9e1159b681dfd279d1f9cfb2af7
Diffstat (limited to 'runtime/interpreter/interpreter.cc')
| -rw-r--r-- | runtime/interpreter/interpreter.cc | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index 299892ec92..0cce09ee9e 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -61,7 +61,7 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jclass>(method->GetDeclaringClass())); jobject jresult; { - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); jresult = fn(soa.Env(), klass.get()); } result->SetL(soa.Decode<mirror::Object>(jresult)); @@ -70,28 +70,28 @@ static void InterpreterJni(Thread* self, fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); fn(soa.Env(), klass.get()); } else if (shorty == "Z") { using fntype = jboolean(JNIEnv*, jclass); fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetZ(fn(soa.Env(), klass.get())); } else if (shorty == "BI") { using fntype = jbyte(JNIEnv*, jclass, jint); fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetB(fn(soa.Env(), klass.get(), args[0])); } else if (shorty == "II") { using fntype = jint(JNIEnv*, jclass, jint); fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetI(fn(soa.Env(), klass.get(), args[0])); } else if (shorty == "LL") { using fntype = jobject(JNIEnv*, jclass, jobject); @@ -102,7 +102,7 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jobject>(ObjArg(args[0]))); jobject jresult; { - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); jresult = fn(soa.Env(), klass.get(), arg0.get()); } result->SetL(soa.Decode<mirror::Object>(jresult)); @@ -111,7 +111,7 @@ static void InterpreterJni(Thread* self, fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetI(fn(soa.Env(), klass.get(), args[0], args[1])); } else if (shorty == "ILI") { using fntype = jint(JNIEnv*, jclass, jobject, jint); @@ -121,7 +121,7 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedLocalRef<jobject> arg0(soa.Env(), soa.AddLocalReference<jobject>(ObjArg(args[0]))); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetI(fn(soa.Env(), klass.get(), arg0.get(), args[1])); } else if (shorty == "SIZ") { using fntype = jshort(JNIEnv*, jclass, jint, jboolean); @@ -129,14 +129,14 @@ static void InterpreterJni(Thread* self, reinterpret_cast<fntype*>(const_cast<void*>(method->GetEntryPointFromJni())); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetS(fn(soa.Env(), klass.get(), args[0], args[1])); } else if (shorty == "VIZ") { using fntype = void(JNIEnv*, jclass, jint, jboolean); fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); fn(soa.Env(), klass.get(), args[0], args[1]); } else if (shorty == "ZLL") { using fntype = jboolean(JNIEnv*, jclass, jobject, jobject); @@ -147,7 +147,7 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jobject>(ObjArg(args[0]))); ScopedLocalRef<jobject> arg1(soa.Env(), soa.AddLocalReference<jobject>(ObjArg(args[1]))); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetZ(fn(soa.Env(), klass.get(), arg0.get(), arg1.get())); } else if (shorty == "ZILL") { using fntype = jboolean(JNIEnv*, jclass, jint, jobject, jobject); @@ -158,7 +158,7 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jobject>(ObjArg(args[1]))); ScopedLocalRef<jobject> arg2(soa.Env(), soa.AddLocalReference<jobject>(ObjArg(args[2]))); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetZ(fn(soa.Env(), klass.get(), args[0], arg1.get(), arg2.get())); } else if (shorty == "VILII") { using fntype = void(JNIEnv*, jclass, jint, jobject, jint, jint); @@ -167,7 +167,7 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedLocalRef<jobject> arg1(soa.Env(), soa.AddLocalReference<jobject>(ObjArg(args[1]))); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); fn(soa.Env(), klass.get(), args[0], arg1.get(), args[2], args[3]); } else if (shorty == "VLILII") { using fntype = void(JNIEnv*, jclass, jobject, jint, jobject, jint, jint); @@ -178,7 +178,7 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jobject>(ObjArg(args[0]))); ScopedLocalRef<jobject> arg2(soa.Env(), soa.AddLocalReference<jobject>(ObjArg(args[2]))); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); fn(soa.Env(), klass.get(), arg0.get(), args[1], arg2.get(), args[3], args[4]); } else { LOG(FATAL) << "Do something with static native method: " << method->PrettyMethod() @@ -192,7 +192,7 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jobject>(receiver)); jobject jresult; { - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); jresult = fn(soa.Env(), rcvr.get()); } result->SetL(soa.Decode<mirror::Object>(jresult)); @@ -201,7 +201,7 @@ static void InterpreterJni(Thread* self, fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jobject> rcvr(soa.Env(), soa.AddLocalReference<jobject>(receiver)); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); fn(soa.Env(), rcvr.get()); } else if (shorty == "LL") { using fntype = jobject(JNIEnv*, jobject, jobject); @@ -212,17 +212,17 @@ static void InterpreterJni(Thread* self, soa.AddLocalReference<jobject>(ObjArg(args[0]))); jobject jresult; { - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); jresult = fn(soa.Env(), rcvr.get(), arg0.get()); } result->SetL(soa.Decode<mirror::Object>(jresult)); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); } else if (shorty == "III") { using fntype = jint(JNIEnv*, jobject, jint, jint); fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jobject> rcvr(soa.Env(), soa.AddLocalReference<jobject>(receiver)); - ScopedThreadStateChange tsc(self, kNative); + ScopedThreadStateChange tsc(self, ThreadState::kNative); result->SetI(fn(soa.Env(), rcvr.get(), args[0], args[1])); } else { LOG(FATAL) << "Do something with native method: " << method->PrettyMethod() |