diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-11-10 11:08:06 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-11-18 12:27:37 -0800 |
commit | 2d7210188805292e463be4bcf7a133b654d7e0ea (patch) | |
tree | 7705a3bf841ae44b2396728fa22ed0b5dcb44dbf /runtime/interpreter | |
parent | e0491682d101c69bf88c3c24a965312129cbfa38 (diff) | |
download | art-2d7210188805292e463be4bcf7a133b654d7e0ea.zip art-2d7210188805292e463be4bcf7a133b654d7e0ea.tar.gz art-2d7210188805292e463be4bcf7a133b654d7e0ea.tar.bz2 |
Change 64 bit ArtMethod fields to be pointer sized
Changed the 64 bit entrypoint and gc map fields in ArtMethod to be
pointer sized. This saves a large amount of memory on 32 bit systems.
Reduces ArtMethod size by 16 bytes on 32 bit.
Total number of ArtMethod on low memory mako: 169957
Image size: 49203 methods -> 787248 image size reduction.
Zygote space size: 1070 methods -> 17120 size reduction.
App methods: ~120k -> 2 MB savings.
Savings per app on low memory mako: 125K+ per app
(less active apps -> more image methods per app).
Savings depend on how often the shared methods are on dirty pages vs
shared.
TODO in another CL, delete gc map field from ArtMethod since we
should be able to get it from the Oat method header.
Bug: 17643507
Change-Id: Ie9508f05907a9f693882d4d32a564460bf273ee8
(cherry picked from commit e832e64a7e82d7f72aedbd7d798fb929d458ee8f)
Diffstat (limited to 'runtime/interpreter')
-rw-r--r-- | runtime/interpreter/interpreter.cc | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index 18de133..b17f303 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -138,7 +138,7 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s if (method->IsStatic()) { if (shorty == "L") { typedef jobject (fntype)(JNIEnv*, jclass); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); jobject jresult; @@ -149,35 +149,35 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s result->SetL(soa.Decode<Object*>(jresult)); } else if (shorty == "V") { typedef void (fntype)(JNIEnv*, jclass); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedThreadStateChange tsc(self, kNative); fn(soa.Env(), klass.get()); } else if (shorty == "Z") { typedef jboolean (fntype)(JNIEnv*, jclass); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedThreadStateChange tsc(self, kNative); result->SetZ(fn(soa.Env(), klass.get())); } else if (shorty == "BI") { typedef jbyte (fntype)(JNIEnv*, jclass, jint); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedThreadStateChange tsc(self, kNative); result->SetB(fn(soa.Env(), klass.get(), args[0])); } else if (shorty == "II") { typedef jint (fntype)(JNIEnv*, jclass, jint); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedThreadStateChange tsc(self, kNative); result->SetI(fn(soa.Env(), klass.get(), args[0])); } else if (shorty == "LL") { typedef jobject (fntype)(JNIEnv*, jclass, jobject); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedLocalRef<jobject> arg0(soa.Env(), @@ -190,14 +190,15 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s result->SetL(soa.Decode<Object*>(jresult)); } else if (shorty == "IIZ") { typedef jint (fntype)(JNIEnv*, jclass, jint, jboolean); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedThreadStateChange tsc(self, kNative); result->SetI(fn(soa.Env(), klass.get(), args[0], args[1])); } else if (shorty == "ILI") { typedef jint (fntype)(JNIEnv*, jclass, jobject, jint); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>( + method->GetEntryPointFromJni())); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedLocalRef<jobject> arg0(soa.Env(), @@ -206,21 +207,21 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s result->SetI(fn(soa.Env(), klass.get(), arg0.get(), args[1])); } else if (shorty == "SIZ") { typedef jshort (fntype)(JNIEnv*, jclass, jint, jboolean); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetEntryPointFromJni())); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedThreadStateChange tsc(self, kNative); result->SetS(fn(soa.Env(), klass.get(), args[0], args[1])); } else if (shorty == "VIZ") { typedef void (fntype)(JNIEnv*, jclass, jint, jboolean); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedThreadStateChange tsc(self, kNative); fn(soa.Env(), klass.get(), args[0], args[1]); } else if (shorty == "ZLL") { typedef jboolean (fntype)(JNIEnv*, jclass, jobject, jobject); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedLocalRef<jobject> arg0(soa.Env(), @@ -231,7 +232,7 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s result->SetZ(fn(soa.Env(), klass.get(), arg0.get(), arg1.get())); } else if (shorty == "ZILL") { typedef jboolean (fntype)(JNIEnv*, jclass, jint, jobject, jobject); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedLocalRef<jobject> arg1(soa.Env(), @@ -242,7 +243,7 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s result->SetZ(fn(soa.Env(), klass.get(), args[0], arg1.get(), arg2.get())); } else if (shorty == "VILII") { typedef void (fntype)(JNIEnv*, jclass, jint, jobject, jint, jint); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedLocalRef<jobject> arg1(soa.Env(), @@ -251,7 +252,7 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s fn(soa.Env(), klass.get(), args[0], arg1.get(), args[2], args[3]); } else if (shorty == "VLILII") { typedef void (fntype)(JNIEnv*, jclass, jobject, jint, jobject, jint, jint); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jclass> klass(soa.Env(), soa.AddLocalReference<jclass>(method->GetDeclaringClass())); ScopedLocalRef<jobject> arg0(soa.Env(), @@ -267,7 +268,7 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s } else { if (shorty == "L") { typedef jobject (fntype)(JNIEnv*, jobject); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jobject> rcvr(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jobject jresult; @@ -278,14 +279,14 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s result->SetL(soa.Decode<Object*>(jresult)); } else if (shorty == "V") { typedef void (fntype)(JNIEnv*, jobject); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jobject> rcvr(soa.Env(), soa.AddLocalReference<jobject>(receiver)); ScopedThreadStateChange tsc(self, kNative); fn(soa.Env(), rcvr.get()); } else if (shorty == "LL") { typedef jobject (fntype)(JNIEnv*, jobject, jobject); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jobject> rcvr(soa.Env(), soa.AddLocalReference<jobject>(receiver)); ScopedLocalRef<jobject> arg0(soa.Env(), @@ -299,7 +300,7 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s ScopedThreadStateChange tsc(self, kNative); } else if (shorty == "III") { typedef jint (fntype)(JNIEnv*, jobject, jint, jint); - fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod())); + fntype* const fn = reinterpret_cast<fntype*>(method->GetEntryPointFromJni()); ScopedLocalRef<jobject> rcvr(soa.Env(), soa.AddLocalReference<jobject>(receiver)); ScopedThreadStateChange tsc(self, kNative); |