Address some comments

Change-Id: I0262304cc720a0e93015955d0a7fb05dfebe213e
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 48dc88d..0886e32 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4973,8 +4973,8 @@
         LengthPrefixedArray<ArtMethod>::ComputeSize(old_method_count, method_size) : 0u;
     const size_t new_size = LengthPrefixedArray<ArtMethod>::ComputeSize(new_method_count,
                                                                         method_size);
-    auto* virtuals = new(runtime->GetLinearAlloc()->Realloc(
-        self, old_virtuals, old_size, new_size))LengthPrefixedArray<ArtMethod>(new_method_count);
+    auto* virtuals = reinterpret_cast<LengthPrefixedArray<ArtMethod>*>(
+        runtime->GetLinearAlloc()->Realloc(self, old_virtuals, old_size, new_size));
     if (UNLIKELY(virtuals == nullptr)) {
       self->AssertPendingOOMException();
       self->EndAssertNoThreadSuspension(old_cause);
@@ -5002,6 +5002,7 @@
       move_table.emplace(mir_method, &*out);
       ++out;
     }
+    virtuals->SetLength(new_method_count);
     UpdateClassVirtualMethods(klass.Get(), virtuals);
     // Done copying methods, they are all roots in the class now, so we can end the no thread
     // suspension assert.
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 59e39df..e9d9065 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2912,7 +2912,7 @@
           if (!obj->IsObjectArray()) {
             mirror::Class* klass = is_static ? obj->AsClass() : obj->GetClass();
             CHECK(klass != nullptr);
-            for (ArtField& field : is_static ? klass->GetSFields() : klass->GetIFields()) {
+            for (ArtField& field : (is_static ? klass->GetSFields() : klass->GetIFields())) {
               if (field.GetOffset().Int32Value() == offset.Int32Value()) {
                 LOG(ERROR) << (is_static ? "Static " : "") << "field in the live stack is "
                            << PrettyField(&field);
diff --git a/runtime/jit/jit_code_cache_test.cc b/runtime/jit/jit_code_cache_test.cc
index 555ad7c..a6cbb71 100644
--- a/runtime/jit/jit_code_cache_test.cc
+++ b/runtime/jit/jit_code_cache_test.cc
@@ -50,7 +50,7 @@
   ASSERT_TRUE(code_cache->ContainsCodePtr(reserved_code));
   ASSERT_EQ(code_cache->NumMethods(), 1u);
   ClassLinker* const cl = Runtime::Current()->GetClassLinker();
-  ArtMethod* method = &cl->AllocArtMethodArray(soa.Self(), 1)->At(0, 0);
+  ArtMethod* method = &cl->AllocArtMethodArray(soa.Self(), 1)->At(0);
   ASSERT_FALSE(code_cache->ContainsMethod(method));
   method->SetEntryPointFromQuickCompiledCode(reserved_code);
   ASSERT_TRUE(code_cache->ContainsMethod(method));
diff --git a/runtime/length_prefixed_array.h b/runtime/length_prefixed_array.h
index 82176e3..2b2e8d3 100644
--- a/runtime/length_prefixed_array.h
+++ b/runtime/length_prefixed_array.h
@@ -48,16 +48,22 @@
     return offsetof(LengthPrefixedArray<T>, data_) + index * element_size;
   }
 
+  // Alignment is the caller's responsibility.
   static size_t ComputeSize(size_t num_elements, size_t element_size = sizeof(T)) {
-    return sizeof(LengthPrefixedArray<T>) + num_elements * element_size;
+    return OffsetOfElement(num_elements, element_size);
   }
 
   uint64_t Length() const {
     return length_;
   }
 
+  // Update the length but does not reallocate storage.
+  void SetLength(uint64_t length) {
+    length_ = length;
+  }
+
  private:
-  uint64_t length_;  // 64 bits for padding reasons.
+  uint64_t length_;  // 64 bits for 8 byte alignment of data_.
   uint8_t data_[0];
 };
 
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index f138936..513ab37 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -1205,7 +1205,8 @@
   // listed in ifields; fields declared by a superclass are listed in
   // the superclass's Class.ifields.
   //
-  // ArtField arrays are allocated as an array of fields, and not an array of fields pointers.
+  // ArtFields are allocated as a length prefixed ArtField array, and not an array of pointers to
+  // ArtFields.
   uint64_t ifields_;
 
   // Static fields length-prefixed array.
diff --git a/runtime/stride_iterator.h b/runtime/stride_iterator.h
index c69f30e..a9da51b 100644
--- a/runtime/stride_iterator.h
+++ b/runtime/stride_iterator.h
@@ -31,7 +31,7 @@
 
   StrideIterator(T* ptr, size_t stride)
       : ptr_(reinterpret_cast<uintptr_t>(ptr)),
-        stride_(reinterpret_cast<uintptr_t>(stride)) {}
+        stride_(stride) {}
 
   bool operator==(const StrideIterator& other) const {
     DCHECK_EQ(stride_, other.stride_);
@@ -48,17 +48,22 @@
   }
 
   StrideIterator operator++(int) {
-    auto temp = *this;
+    StrideIterator<T> temp = *this;
     ptr_ += stride_;
     return temp;
   }
 
   StrideIterator operator+(ssize_t delta) const {
-    auto temp = *this;
-    temp.ptr_ += static_cast<ssize_t>(stride_) * delta;
+    StrideIterator<T> temp = *this;
+    temp += delta;
     return temp;
   }
 
+  StrideIterator& operator+=(ssize_t delta) {
+    ptr_ += static_cast<ssize_t>(stride_) * delta;
+    return *this;
+  }
+
   T& operator*() const {
     return *reinterpret_cast<T*>(ptr_);
   }