summaryrefslogtreecommitdiff
path: root/runtime/native_bridge_art_interface.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2015-04-22 13:56:20 -0700
committer Mathieu Chartier <mathieuc@google.com> 2015-05-29 18:45:49 -0700
commite401d146407d61eeb99f8d6176b2ac13c4df1e33 (patch)
tree17927f9bfe7d2041b5942c89832d55f9dedb24c5 /runtime/native_bridge_art_interface.cc
parent2006b7b9b8e32722bd0d640c62549d8a0ac624b6 (diff)
Move mirror::ArtMethod to native
Optimizing + quick tests are passing, devices boot. TODO: Test and fix bugs in mips64. Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS. Some of the savings are from removal of virtual methods and direct methods object arrays. Bug: 19264997 Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
Diffstat (limited to 'runtime/native_bridge_art_interface.cc')
-rw-r--r--runtime/native_bridge_art_interface.cc47
1 files changed, 20 insertions, 27 deletions
diff --git a/runtime/native_bridge_art_interface.cc b/runtime/native_bridge_art_interface.cc
index 0ad560e9eb..46cc5aaff8 100644
--- a/runtime/native_bridge_art_interface.cc
+++ b/runtime/native_bridge_art_interface.cc
@@ -20,10 +20,10 @@
#include "nativebridge/native_bridge.h"
+#include "art_method-inl.h"
#include "base/logging.h"
#include "base/macros.h"
#include "dex_file-inl.h"
-#include "mirror/art_method-inl.h"
#include "mirror/class-inl.h"
#include "scoped_thread_state_change.h"
#include "sigchain.h"
@@ -32,29 +32,24 @@ namespace art {
static const char* GetMethodShorty(JNIEnv* env, jmethodID mid) {
ScopedObjectAccess soa(env);
- mirror::ArtMethod* m = soa.DecodeMethod(mid);
+ ArtMethod* m = soa.DecodeMethod(mid);
return m->GetShorty();
}
static uint32_t GetNativeMethodCount(JNIEnv* env, jclass clazz) {
- if (clazz == nullptr)
+ if (clazz == nullptr) {
return 0;
+ }
ScopedObjectAccess soa(env);
mirror::Class* c = soa.Decode<mirror::Class*>(clazz);
uint32_t native_method_count = 0;
- for (uint32_t i = 0; i < c->NumDirectMethods(); ++i) {
- mirror::ArtMethod* m = c->GetDirectMethod(i);
- if (m->IsNative()) {
- native_method_count++;
- }
+ for (auto& m : c->GetDirectMethods(sizeof(void*))) {
+ native_method_count += m.IsNative() ? 1u : 0u;
}
- for (uint32_t i = 0; i < c->NumVirtualMethods(); ++i) {
- mirror::ArtMethod* m = c->GetVirtualMethod(i);
- if (m->IsNative()) {
- native_method_count++;
- }
+ for (auto& m : c->GetVirtualMethods(sizeof(void*))) {
+ native_method_count += m.IsNative() ? 1u : 0u;
}
return native_method_count;
}
@@ -68,29 +63,27 @@ static uint32_t GetNativeMethods(JNIEnv* env, jclass clazz, JNINativeMethod* met
mirror::Class* c = soa.Decode<mirror::Class*>(clazz);
uint32_t count = 0;
- for (uint32_t i = 0; i < c->NumDirectMethods(); ++i) {
- mirror::ArtMethod* m = c->GetDirectMethod(i);
- if (m->IsNative()) {
+ for (auto& m : c->GetDirectMethods(sizeof(void*))) {
+ if (m.IsNative()) {
if (count < method_count) {
- methods[count].name = m->GetName();
- methods[count].signature = m->GetShorty();
- methods[count].fnPtr = m->GetEntryPointFromJni();
+ methods[count].name = m.GetName();
+ methods[count].signature = m.GetShorty();
+ methods[count].fnPtr = m.GetEntryPointFromJni();
count++;
} else {
- LOG(WARNING) << "Output native method array too small. Skipping " << PrettyMethod(m);
+ LOG(WARNING) << "Output native method array too small. Skipping " << PrettyMethod(&m);
}
}
}
- for (uint32_t i = 0; i < c->NumVirtualMethods(); ++i) {
- mirror::ArtMethod* m = c->GetVirtualMethod(i);
- if (m->IsNative()) {
+ for (auto& m : c->GetVirtualMethods(sizeof(void*))) {
+ if (m.IsNative()) {
if (count < method_count) {
- methods[count].name = m->GetName();
- methods[count].signature = m->GetShorty();
- methods[count].fnPtr = m->GetEntryPointFromJni();
+ methods[count].name = m.GetName();
+ methods[count].signature = m.GetShorty();
+ methods[count].fnPtr = m.GetEntryPointFromJni();
count++;
} else {
- LOG(WARNING) << "Output native method array too small. Skipping " << PrettyMethod(m);
+ LOG(WARNING) << "Output native method array too small. Skipping " << PrettyMethod(&m);
}
}
}