diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-03-24 13:30:28 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2015-03-29 14:13:08 -0700 |
commit | daaf3265806eb2eadb2e03302bd68022fab5ca28 (patch) | |
tree | aff5d6d53d6d2b65995aa204839f88ee66400989 /runtime/interpreter | |
parent | 68e22f3b982ff9ccbdfb3b65b7cfc16fcae907ba (diff) | |
download | art-daaf3265806eb2eadb2e03302bd68022fab5ca28.tar.gz art-daaf3265806eb2eadb2e03302bd68022fab5ca28.tar.bz2 art-daaf3265806eb2eadb2e03302bd68022fab5ca28.zip |
Add AccessibleObject and Field to mirror
Main motivation is to remove all the functionality / field access on
java side to ArtField. Also comes with some reflection speedups /
slowdowns.
Summary results:
getDeclaredField/getField are slower mostly due to JNI overhead.
However, there is a large speedup in getInt, setInt,
GetInstanceField, and GetStaticField.
Before timings (N5 --compiler-filter=everything):
benchmark ns linear runtime
Class_getDeclaredField 782.86 ===
Class_getField 832.77 ===
Field_getInt 160.17 =
Field_setInt 195.88 =
GetInstanceField 3214.38 ==============
GetStaticField 6809.49 ==============================
After:
Class_getDeclaredField 1068.15 ============
Class_getField 1180.00 ==============
Field_getInt 121.85 =
Field_setInt 139.98 =
GetInstanceField 1986.15 =======================
GetStaticField 2523.63 ==============================
Bug: 19264997
Change-Id: Ic0d0fc1b56b95cd6d60f8e76f19caeaa23045c77
Diffstat (limited to 'runtime/interpreter')
-rw-r--r-- | runtime/interpreter/interpreter_common.cc | 2 | ||||
-rw-r--r-- | runtime/interpreter/unstarted_runtime.cc | 19 |
2 files changed, 7 insertions, 14 deletions
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index a3ab026ba8..a3104525b6 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -285,7 +285,7 @@ bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction HandleWrapper<mirror::ArtField> h_f(hs.NewHandleWrapper(&f)); HandleWrapper<mirror::Object> h_reg(hs.NewHandleWrapper(®)); HandleWrapper<mirror::Object> h_obj(hs.NewHandleWrapper(&obj)); - field_class = h_f->GetType(true); + field_class = h_f->GetType<true>(); } if (!reg->VerifierInstanceOf(field_class)) { // This should never happen. diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index 98dfdbd2ea..1b08e80495 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -29,6 +29,7 @@ #include "mirror/array-inl.h" #include "mirror/art_method-inl.h" #include "mirror/class.h" +#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/string-inl.h" @@ -219,19 +220,11 @@ static void UnstartedClassGetDeclaredField( PrettyDescriptor(klass).c_str()); return; } - // TODO: getDeclaredField calls GetType once the field is found to ensure a - // NoClassDefFoundError is thrown if the field's type cannot be resolved. - mirror::Class* jlr_Field = self->DecodeJObject( - WellKnownClasses::java_lang_reflect_Field)->AsClass(); - StackHandleScope<1> hs(self); - Handle<mirror::Object> field(hs.NewHandle(jlr_Field->AllocNonMovableObject(self))); - CHECK(field.Get() != nullptr); - mirror::ArtMethod* c = jlr_Field->FindDeclaredDirectMethod("<init>", - "(Ljava/lang/reflect/ArtField;)V"); - uint32_t args[1]; - args[0] = StackReference<mirror::Object>::FromMirrorPtr(found).AsVRegValue(); - EnterInterpreterFromInvoke(self, c, field.Get(), args, nullptr); - result->SetL(field.Get()); + if (Runtime::Current()->IsActiveTransaction()) { + result->SetL(mirror::Field::CreateFromArtField<true>(self, found, true)); + } else { + result->SetL(mirror::Field::CreateFromArtField<false>(self, found, true)); + } } static void UnstartedVmClassLoaderFindLoadedClass( |