Move ArtFields and ArtMethods to be a length prefixed array
Fixes race conditions between changing method and fields arrays
being seen in the wrong order by the GC.
Bug: 22832610
Change-Id: Ia21d6698f73ba207a6392c3d6b9be2658933073f
diff --git a/runtime/stride_iterator.h b/runtime/stride_iterator.h
index d8d21aa..c69f30e 100644
--- a/runtime/stride_iterator.h
+++ b/runtime/stride_iterator.h
@@ -29,11 +29,12 @@
StrideIterator& operator=(const StrideIterator&) = default;
StrideIterator& operator=(StrideIterator&&) = default;
- StrideIterator(uintptr_t ptr, size_t stride)
- : ptr_(ptr), stride_(stride) {
- }
+ StrideIterator(T* ptr, size_t stride)
+ : ptr_(reinterpret_cast<uintptr_t>(ptr)),
+ stride_(reinterpret_cast<uintptr_t>(stride)) {}
bool operator==(const StrideIterator& other) const {
+ DCHECK_EQ(stride_, other.stride_);
return ptr_ == other.ptr_;
}
@@ -52,6 +53,12 @@
return temp;
}
+ StrideIterator operator+(ssize_t delta) const {
+ auto temp = *this;
+ temp.ptr_ += static_cast<ssize_t>(stride_) * delta;
+ return temp;
+ }
+
T& operator*() const {
return *reinterpret_cast<T*>(ptr_);
}