diff options
Diffstat (limited to 'runtime/scoped_thread_state_change.h')
-rw-r--r-- | runtime/scoped_thread_state_change.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/runtime/scoped_thread_state_change.h b/runtime/scoped_thread_state_change.h index 5f03741d1f..02b6124118 100644 --- a/runtime/scoped_thread_state_change.h +++ b/runtime/scoped_thread_state_change.h @@ -17,17 +17,23 @@ #ifndef ART_RUNTIME_SCOPED_THREAD_STATE_CHANGE_H_ #define ART_RUNTIME_SCOPED_THREAD_STATE_CHANGE_H_ -#include "art_field.h" -#include "base/casts.h" +#include "jni.h" + +#include "base/macros.h" +#include "base/mutex.h" #include "base/value_object.h" -#include "java_vm_ext.h" #include "thread_state.h" -#include "verify_object.h" namespace art { +class JavaVMExt; struct JNIEnvExt; template<class MirrorType> class ObjPtr; +class Thread; + +namespace mirror { +class Object; +} // namespace mirror // Scoped change into and out of a particular state. Handles Runnable transitions that require // more complicated suspension checking. The subclasses ScopedObjectAccessUnchecked and @@ -74,9 +80,7 @@ class ScopedObjectAccessAlreadyRunnable : public ValueObject { return vm_; } - bool ForceCopy() const { - return vm_->ForceCopy(); - } + bool ForceCopy() const; /* * Add a local reference for an object to the indirect reference table associated with the @@ -105,12 +109,17 @@ class ScopedObjectAccessAlreadyRunnable : public ValueObject { // Used when we want a scoped JNI thread state but have no thread/JNIEnv. Consequently doesn't // change into Runnable or acquire a share on the mutator_lock_. + // Note: The reinterpret_cast is backed by a static_assert in the cc file. Avoid a down_cast, + // as it prevents forward declaration of JavaVMExt. explicit ScopedObjectAccessAlreadyRunnable(JavaVM* vm) - : self_(nullptr), env_(nullptr), vm_(down_cast<JavaVMExt*>(vm)) {} + : self_(nullptr), env_(nullptr), vm_(reinterpret_cast<JavaVMExt*>(vm)) {} // Here purely to force inlining. ALWAYS_INLINE ~ScopedObjectAccessAlreadyRunnable() {} + static void DCheckObjIsNotClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) + REQUIRES_SHARED(Locks::mutator_lock_); + // Self thread, can be null. Thread* const self_; // The full JNIEnv. |