diff options
author | 2019-06-19 12:58:22 -0700 | |
---|---|---|
committer | 2019-06-26 20:22:39 +0000 | |
commit | 21d5994583c679cd5d8573b5d35dbd659bdca2c7 (patch) | |
tree | 521906398a2f04048cc51b4f409b6a3ebc0c6ffa /runtime/mirror/class.h | |
parent | 5dfbe7ae9ed9a1a82446d32118190105a211a2d2 (diff) |
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
Diffstat (limited to 'runtime/mirror/class.h')
-rw-r--r-- | runtime/mirror/class.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 09d5532deb..144350f02e 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -1229,6 +1229,23 @@ class MANAGED Class final : public Object { void FixupNativePointers(Class* dest, PointerSize pointer_size, const Visitor& visitor) REQUIRES_SHARED(Locks::mutator_lock_); + // Get or create the various jni id arrays in a lock-less thread safe manner. + ObjPtr<PointerArray> GetOrCreateMethodIds() REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<PointerArray> GetMethodIds() REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<PointerArray> GetOrCreateStaticFieldIds() REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<PointerArray> GetStaticFieldIds() REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<PointerArray> GetOrCreateInstanceFieldIds() REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<PointerArray> GetInstanceFieldIds() REQUIRES_SHARED(Locks::mutator_lock_); + + // Calculate the index in the ifields_, methods_ or sfields_ arrays a method is located at. This + // is to be used with the above Get{,OrCreate}...Ids functions. + size_t GetStaticFieldIdOffset(ArtField* field) + REQUIRES_SHARED(Locks::mutator_lock_); + size_t GetInstanceFieldIdOffset(ArtField* field) + REQUIRES_SHARED(Locks::mutator_lock_); + size_t GetMethodIdOffset(ArtMethod* method, PointerSize pointer_size) + REQUIRES_SHARED(Locks::mutator_lock_); + private: template <typename T, VerifyObjectFlags kVerifyFlags, typename Visitor> void FixupNativePointer( |