Fix Object::Clone()'s pre-fence barrier.
Pass in a pre-fence barrier object that sets in the array length
instead of setting it after returning from AllocObject().
Fix another potential bug due to the wrong default pre-fence barrier
parameter value. Since this appears error-prone, removed the default
parameter value and make it an explicit parameter.
Fix another potential moving GC bug due to a lack of a SirtRef.
Bug: 13097759
Change-Id: I466aa0e50f9e1a5dbf20be5a195edee619c7514e
diff --git a/runtime/sirt_ref.h b/runtime/sirt_ref.h
index 2226e17..cf23891 100644
--- a/runtime/sirt_ref.h
+++ b/runtime/sirt_ref.h
@@ -28,7 +28,7 @@
template<class T>
class SirtRef {
public:
- SirtRef(Thread* self, T* object);
+ SirtRef(Thread* self, T* object, bool should_verify = true);
~SirtRef();
T& operator*() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -42,7 +42,8 @@
}
// Returns the old reference.
- T* reset(T* object = nullptr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ T* reset(T* object = nullptr, bool should_verify = true)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
private:
Thread* const self_;
@@ -51,6 +52,17 @@
DISALLOW_COPY_AND_ASSIGN(SirtRef);
};
+// A version of SirtRef which disables the object verification.
+template<class T>
+class SirtRefNoVerify : public SirtRef<T> {
+ public:
+ SirtRefNoVerify(Thread* self, T* object) : SirtRef<T>(self, object, false) {}
+ // Returns the old reference.
+ T* reset(T* object = nullptr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ return SirtRef<T>::reset(object, false);
+ }
+};
+
} // namespace art
#endif // ART_RUNTIME_SIRT_REF_H_