summaryrefslogtreecommitdiffstats
path: root/runtime/reflection.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/reflection.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/reflection.cc')
-rw-r--r--runtime/reflection.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index 3e1315c73e..e54673831f 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -22,6 +22,7 @@
#include "dex_file-inl.h"
#include "entrypoints/entrypoint_utils.h"
#include "jni_internal.h"
+#include "mirror/abstract_method.h"
#include "mirror/art_method-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object_array-inl.h"
@@ -537,7 +538,7 @@ void InvokeWithShadowFrame(Thread* self, ShadowFrame* shadow_frame, uint16_t arg
}
jobject InvokeMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject javaMethod,
- jobject javaReceiver, jobject javaArgs, bool accessible) {
+ jobject javaReceiver, jobject javaArgs, size_t num_frames) {
// We want to make sure that the stack is not within a small distance from the
// protected region in case we are calling into a leaf function whose stack
// check has been elided.
@@ -547,7 +548,9 @@ jobject InvokeMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject javaM
return nullptr;
}
- mirror::ArtMethod* m = mirror::ArtMethod::FromReflectedMethod(soa, javaMethod);
+ auto* abstract_method = soa.Decode<mirror::AbstractMethod*>(javaMethod);
+ const bool accessible = abstract_method->IsAccessible();
+ mirror::ArtMethod* m = abstract_method->GetArtMethod();
mirror::Class* declaring_class = m->GetDeclaringClass();
if (UNLIKELY(!declaring_class->IsInitialized())) {
@@ -572,8 +575,7 @@ jobject InvokeMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject javaM
}
// Get our arrays of arguments and their types, and check they're the same size.
- mirror::ObjectArray<mirror::Object>* objects =
- soa.Decode<mirror::ObjectArray<mirror::Object>*>(javaArgs);
+ auto* objects = soa.Decode<mirror::ObjectArray<mirror::Object>*>(javaArgs);
const DexFile::TypeList* classes = m->GetParameterTypeList();
uint32_t classes_size = (classes == nullptr) ? 0 : classes->Size();
uint32_t arg_count = (objects != nullptr) ? objects->GetLength() : 0;
@@ -586,7 +588,7 @@ jobject InvokeMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject javaM
// If method is not set to be accessible, verify it can be accessed by the caller.
mirror::Class* calling_class = nullptr;
if (!accessible && !VerifyAccess(soa.Self(), receiver, declaring_class, m->GetAccessFlags(),
- &calling_class, 2)) {
+ &calling_class, num_frames)) {
ThrowIllegalAccessException(
StringPrintf("Class %s cannot access %s method %s of class %s",
calling_class == nullptr ? "null" : PrettyClass(calling_class).c_str(),