From f36cb5f65cb150151aa40b23937e2b0ad75cc546 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Fri, 24 Apr 2015 16:55:16 -0700 Subject: Move Class.newInstance to native MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids 1 allocation and several JNI transitions. Before: Class_classNewInstance: 4462.39 ns; σ=39.42 ns @ 3 trials After: Class_classNewInstance: 1073.39 ns; σ=24.14 ns @ 10 trials Bug: 20269715 Bug: 20566996 Change-Id: Icd52155ce79a978a4d869855bfdfd7735abd8187 --- runtime/reflection.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'runtime/reflection.h') diff --git a/runtime/reflection.h b/runtime/reflection.h index c63f858..6305d68 100644 --- a/runtime/reflection.h +++ b/runtime/reflection.h @@ -77,6 +77,15 @@ bool VerifyAccess(Thread* self, mirror::Object* obj, mirror::Class* declaring_cl uint32_t access_flags, mirror::Class** calling_class, size_t num_frames) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); +// This version takes a known calling class. +bool VerifyAccess(Thread* self, mirror::Object* obj, mirror::Class* declaring_class, + uint32_t access_flags, mirror::Class* calling_class) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + +// Get the calling class by using a stack visitor, may return null for unattached native threads. +mirror::Class* GetCallingClass(Thread* self, size_t num_frames) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void InvalidReceiverError(mirror::Object* o, mirror::Class* c) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -- cgit v1.1