diff options
author | Ian Rogers <irogers@google.com> | 2014-03-13 23:45:53 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-03-14 11:28:10 -0700 |
commit | 53b8b09fc80329539585dcf43657bc5f4ecefdff (patch) | |
tree | cac0f82fbb89bd907104e3fed6c36203e11a3de0 /runtime/gc | |
parent | 0dea9872082bc3e576ed6cefed86b0d6c0c45ffd (diff) | |
download | art-53b8b09fc80329539585dcf43657bc5f4ecefdff.zip art-53b8b09fc80329539585dcf43657bc5f4ecefdff.tar.gz art-53b8b09fc80329539585dcf43657bc5f4ecefdff.tar.bz2 |
Refactor reflective method invocation.
Move invocation code out of JNI internal into reflection, including ArgArray
code. Make reflective invocation use the ArgArray to build arguments rather
than allocating a jvalue[] and unboxing arguments into that.
Move reflection part of jni_internal_test into reflection_test.
Make greater use of fast JNI.
Change-Id: Ib381372df5f9a83679e30e7275de24fa0e6b1057
Diffstat (limited to 'runtime/gc')
-rw-r--r-- | runtime/gc/heap.cc | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 76b94fd..45904ff 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -48,7 +48,6 @@ #include "entrypoints/quick/quick_alloc_entrypoints.h" #include "heap-inl.h" #include "image.h" -#include "invoke_arg_array_builder.h" #include "mirror/art_field-inl.h" #include "mirror/class-inl.h" #include "mirror/object.h" @@ -57,6 +56,7 @@ #include "mirror/reference-inl.h" #include "object_utils.h" #include "os.h" +#include "reflection.h" #include "runtime.h" #include "ScopedLocalRef.h" #include "scoped_thread_state_change.h" @@ -2453,11 +2453,10 @@ void Heap::ClearGrowthLimit() { void Heap::AddFinalizerReference(Thread* self, mirror::Object* object) { ScopedObjectAccess soa(self); - JValue result; - ArgArray arg_array("VL", 2); - arg_array.Append(object); - soa.DecodeMethod(WellKnownClasses::java_lang_ref_FinalizerReference_add)->Invoke(self, - arg_array.GetArray(), arg_array.GetNumBytes(), &result, "VL"); + ScopedLocalRef<jobject> arg(self->GetJniEnv(), soa.AddLocalReference<jobject>(object)); + jvalue args[1]; + args[0].l = arg.get(); + InvokeWithJValues(soa, nullptr, WellKnownClasses::java_lang_ref_FinalizerReference_add, args); } void Heap::EnqueueClearedReferences() { @@ -2467,11 +2466,11 @@ void Heap::EnqueueClearedReferences() { // When a runtime isn't started there are no reference queues to care about so ignore. if (LIKELY(Runtime::Current()->IsStarted())) { ScopedObjectAccess soa(self); - JValue result; - ArgArray arg_array("VL", 2); - arg_array.Append(cleared_references_.GetList()); - soa.DecodeMethod(WellKnownClasses::java_lang_ref_ReferenceQueue_add)->Invoke(soa.Self(), - arg_array.GetArray(), arg_array.GetNumBytes(), &result, "VL"); + ScopedLocalRef<jobject> arg(self->GetJniEnv(), + soa.AddLocalReference<jobject>(cleared_references_.GetList())); + jvalue args[1]; + args[0].l = arg.get(); + InvokeWithJValues(soa, nullptr, WellKnownClasses::java_lang_ref_ReferenceQueue_add, args); } cleared_references_.Clear(); } |