summaryrefslogtreecommitdiffstats
path: root/runtime/proxy_test.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-04-16 18:00:39 -0700
committerMathieu Chartier <mathieuc@google.com>2015-04-21 15:51:29 -0700
commitfc58af45e342ba9e18bbdf597f205a58ec731658 (patch)
tree3f93906235cb4d2462d237223b72ccf4eedef645 /runtime/proxy_test.cc
parentbbf02afc641a393d33342976e269218668c07386 (diff)
downloadart-fc58af45e342ba9e18bbdf597f205a58ec731658.tar.gz
art-fc58af45e342ba9e18bbdf597f205a58ec731658.tar.bz2
art-fc58af45e342ba9e18bbdf597f205a58ec731658.zip
Add AbstractMethod, Constructor, Method
Moves functionality to ART from libcore. Precursor to moving ArtMethods to native. Mostly performance improvements. N5 perf before (irrelevant results removed): Class_getConstructor 962.87 =========== Class_getDeclaredMethod 2394.37 ============================ Class_getMethod 2509.20 ============================== Class_newInstance 1999.81 ======================= Method_invokeI 1439.02 ================= Method_invokePreBoxedI 1415.82 ================ Method_invokeStaticI 1456.24 ================= Method_invokeStaticPreBoxedI 1427.32 ================= Method_invokeStaticV 814.47 ========= Method_invokeV 816.56 ========= After: benchmark ns linear runtime Class_getConstructor 1302.04 ================ Class_getDeclaredMethod 1459.01 ================== Class_getMethod 1560.40 =================== Class_newInstance 2029.94 ========================= Method_invokeI 1312.89 ================ Method_invokePreBoxedI 1255.01 =============== Method_invokeStaticI 1289.13 =============== Method_invokeStaticPreBoxedI 1196.52 ============== Method_invokeStaticV 790.82 ========= Method_invokeV 791.73 ========= Performance improvements are more than just fixing regressions introduced in: http://android-review.googlesource.com/#/c/146069/ Bug: 19264997 Change-Id: Ife79c469fdb09f30e3aefcfc3e0ce5ed32303fce
Diffstat (limited to 'runtime/proxy_test.cc')
-rw-r--r--runtime/proxy_test.cc61
1 files changed, 27 insertions, 34 deletions
diff --git a/runtime/proxy_test.cc b/runtime/proxy_test.cc
index 6061f73c19..b471293c09 100644
--- a/runtime/proxy_test.cc
+++ b/runtime/proxy_test.cc
@@ -20,6 +20,7 @@
#include "art_field-inl.h"
#include "class_linker-inl.h"
#include "common_compiler_test.h"
+#include "mirror/method.h"
#include "scoped_thread_state_change.h"
namespace art {
@@ -53,41 +54,34 @@ class ProxyTest : public CommonCompilerTest {
mirror::ObjectArray<mirror::ArtMethod>* virtual_methods = interface->GetVirtualMethods();
methods_count += (virtual_methods == nullptr) ? 0 : virtual_methods->GetLength();
}
- jclass javaLangReflectArtMethod =
- soa.AddLocalReference<jclass>(mirror::ArtMethod::GetJavaLangReflectArtMethod());
- jobjectArray proxyClassMethods = soa.Env()->NewObjectArray(methods_count,
- javaLangReflectArtMethod, nullptr);
+ jobjectArray proxyClassMethods = soa.Env()->NewObjectArray(
+ methods_count, soa.AddLocalReference<jclass>(mirror::Method::StaticClass()), nullptr);
soa.Self()->AssertNoPendingException();
- // Fill the method array
- mirror::ArtMethod* equalsMethod = javaLangObject->FindDeclaredVirtualMethod("equals",
- "(Ljava/lang/Object;)Z");
- mirror::ArtMethod* hashCodeMethod = javaLangObject->FindDeclaredVirtualMethod("hashCode",
- "()I");
- mirror::ArtMethod* toStringMethod = javaLangObject->FindDeclaredVirtualMethod("toString",
- "()Ljava/lang/String;");
- CHECK(equalsMethod != nullptr);
- CHECK(hashCodeMethod != nullptr);
- CHECK(toStringMethod != nullptr);
-
jsize array_index = 0;
- // Adds Object methods.
- soa.Env()->SetObjectArrayElement(proxyClassMethods, array_index++,
- soa.AddLocalReference<jobject>(equalsMethod));
- soa.Env()->SetObjectArrayElement(proxyClassMethods, array_index++,
- soa.AddLocalReference<jobject>(hashCodeMethod));
- soa.Env()->SetObjectArrayElement(proxyClassMethods, array_index++,
- soa.AddLocalReference<jobject>(toStringMethod));
-
+ // Fill the method array
+ mirror::ArtMethod* method = javaLangObject->FindDeclaredVirtualMethod(
+ "equals", "(Ljava/lang/Object;)Z");
+ CHECK(method != nullptr);
+ soa.Env()->SetObjectArrayElement(
+ proxyClassMethods, array_index++, soa.AddLocalReference<jobject>(
+ mirror::Method::CreateFromArtMethod(soa.Self(), method)));
+ method = javaLangObject->FindDeclaredVirtualMethod("hashCode", "()I");
+ CHECK(method != nullptr);
+ soa.Env()->SetObjectArrayElement(
+ proxyClassMethods, array_index++, soa.AddLocalReference<jobject>(
+ mirror::Method::CreateFromArtMethod(soa.Self(), method)));
+ method = javaLangObject->FindDeclaredVirtualMethod("toString", "()Ljava/lang/String;");
+ CHECK(method != nullptr);
+ soa.Env()->SetObjectArrayElement(
+ proxyClassMethods, array_index++, soa.AddLocalReference<jobject>(
+ mirror::Method::CreateFromArtMethod(soa.Self(), method)));
// Now adds all interfaces virtual methods.
for (mirror::Class* interface : interfaces) {
- mirror::ObjectArray<mirror::ArtMethod>* virtual_methods = interface->GetVirtualMethods();
- if (virtual_methods != nullptr) {
- for (int32_t mth_index = 0; mth_index < virtual_methods->GetLength(); ++mth_index) {
- mirror::ArtMethod* method = virtual_methods->Get(mth_index);
- soa.Env()->SetObjectArrayElement(proxyClassMethods, array_index++,
- soa.AddLocalReference<jobject>(method));
- }
+ for (int32_t i = 0, count = interface->NumVirtualMethods(); i < count; ++i) {
+ soa.Env()->SetObjectArrayElement(
+ proxyClassMethods, array_index++, soa.AddLocalReference<jobject>(
+ mirror::Method::CreateFromArtMethod(soa.Self(), interface->GetVirtualMethod(i))));
}
}
CHECK_EQ(array_index, methods_count);
@@ -96,10 +90,9 @@ class ProxyTest : public CommonCompilerTest {
jobjectArray proxyClassThrows = soa.Env()->NewObjectArray(0, javaLangClass, nullptr);
soa.Self()->AssertNoPendingException();
- mirror::Class* proxyClass = class_linker_->CreateProxyClass(soa,
- soa.Env()->NewStringUTF(className),
- proxyClassInterfaces, jclass_loader,
- proxyClassMethods, proxyClassThrows);
+ mirror::Class* proxyClass = class_linker_->CreateProxyClass(
+ soa, soa.Env()->NewStringUTF(className), proxyClassInterfaces, jclass_loader,
+ proxyClassMethods, proxyClassThrows);
soa.Self()->AssertNoPendingException();
return proxyClass;
}