From 21d5994583c679cd5d8573b5d35dbd659bdca2c7 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Wed, 19 Jun 2019 12:58:22 -0700 Subject: Support using opaque JNI ids Currently JNI ids (jmethodID & jfieldID) are created by simply casting the corresponding ART structure pointer. This is great for simplicity but means we are prevented from performing operations that could change these pointer values. To support these use-cases add support for loading the runtime with a layer of indirection between these ids and the internal art data types. Currently the JNI id type can be toggled only by passing the new '-Xopaque-jni-ids:{true,false}' flag during startup. This changes the --debuggable test configuration to pass '-Xopaque-jni-ids:true' in order to get test coverage of this feature using the 'art-jit' configuration. Test: ./test.py --host --debuggable Test: ./test.py --host --debuggable --jit-on-first-use Test: ./test/testrunnner/run_build_test_target.py art-jit Bug: 134162467 Change-Id: Id8c8cb9a5b8ff18dc2f40892fae2d344a7214f44 --- runtime/mirror/class_ext.h | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'runtime/mirror/class_ext.h') diff --git a/runtime/mirror/class_ext.h b/runtime/mirror/class_ext.h index 70bea33c1f..6fb225fd69 100644 --- a/runtime/mirror/class_ext.h +++ b/runtime/mirror/class_ext.h @@ -46,6 +46,33 @@ class MANAGED ClassExt : public Object { ObjPtr> GetObsoleteDexCaches() REQUIRES_SHARED(Locks::mutator_lock_); + template + ObjPtr EnsureInstanceJFieldIDsArrayPresent(size_t count) + REQUIRES_SHARED(Locks::mutator_lock_); + + template + ObjPtr GetInstanceJFieldIDs() REQUIRES_SHARED(Locks::mutator_lock_); + + template + ObjPtr EnsureStaticJFieldIDsArrayPresent(size_t count) + REQUIRES_SHARED(Locks::mutator_lock_); + + template + ObjPtr GetStaticJFieldIDs() REQUIRES_SHARED(Locks::mutator_lock_); + + template + ObjPtr EnsureJMethodIDsArrayPresent(size_t count) + REQUIRES_SHARED(Locks::mutator_lock_); + + template + ObjPtr GetJMethodIDs() REQUIRES_SHARED(Locks::mutator_lock_); + template ObjPtr GetObsoleteMethods() REQUIRES_SHARED(Locks::mutator_lock_); @@ -82,19 +109,36 @@ class MANAGED ClassExt : public Object { static ObjPtr Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); private: + template + ObjPtr EnsureJniIdsArrayPresent(MemberOffset off, size_t count) + REQUIRES_SHARED(Locks::mutator_lock_); + // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". + // An array containing the jfieldIDs assigned to each field in the corresponding position in the + // classes ifields_ array or '0' if no id has been assigned to that field yet. + HeapReference instance_jfield_ids_; + + // An array containing the jmethodIDs assigned to each method in the corresponding position in + // the classes methods_ array or '0' if no id has been assigned to that method yet. + HeapReference jmethod_ids_; + HeapReference> obsolete_dex_caches_; HeapReference obsolete_methods_; HeapReference original_dex_file_; + // An array containing the jfieldIDs assigned to each field in the corresponding position in the + // classes sfields_ array or '0' if no id has been assigned to that field yet. + HeapReference static_jfield_ids_; + // The saved verification error of this class. HeapReference verify_error_; // Native pointer to DexFile and ClassDef index of this class before it was JVMTI-redefined. - int64_t pre_redefine_dex_file_ptr_; int32_t pre_redefine_class_def_index_; + int64_t pre_redefine_dex_file_ptr_; friend struct art::ClassExtOffsets; // for verifying offset information DISALLOW_IMPLICIT_CONSTRUCTORS(ClassExt); -- cgit v1.2.3-59-g8ed1b