From 0cd81352a7c06e381951cea1b104fd73516f4341 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 22 May 2014 16:48:55 -0700 Subject: Revert "Revert "Fix an outstanding compaction bug in interpreter."" Fixed the generic trampoline to not use ToJObject when unnecessary. Bug: 15167269 This reverts commit 3bdb873122964da7937eb070cbcf2ef638a8e459. Change-Id: I0525d0e0f3afb753c770e1572070a0fa22b02271 --- runtime/handle.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'runtime/handle.h') diff --git a/runtime/handle.h b/runtime/handle.h index 3127864..b70f651 100644 --- a/runtime/handle.h +++ b/runtime/handle.h @@ -53,29 +53,48 @@ class Handle { reference_->Assign(reference); return old; } - jobject ToJObject() const ALWAYS_INLINE { + jobject ToJObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE { + if (UNLIKELY(reference_->AsMirrorPtr() == nullptr)) { + // Special case so that we work with NullHandles. + return nullptr; + } return reinterpret_cast(reference_); } - private: + protected: StackReference* reference_; template explicit Handle(StackReference* reference) : reference_(reinterpret_cast*>(reference)) { } - template explicit Handle(const Handle& handle) : reference_(reinterpret_cast*>(handle.reference_)) { } + StackReference* GetReference() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE { + return reference_; + } + + private: + friend class BuildGenericJniFrameVisitor; template friend class Handle; friend class HandleScope; template friend class HandleWrapper; template friend class StackHandleScope; }; +template +class NullHandle : public Handle { + public: + NullHandle() : Handle(&null_ref_) { + } + + private: + StackReference null_ref_; +}; + } // namespace art #endif // ART_RUNTIME_HANDLE_H_ -- cgit v1.1