summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 7821da3397..0886e327d9 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4063,10 +4063,10 @@ bool ClassLinker::LinkClass(Thread* self, const char* descriptor, Handle<mirror:
// Retire the temporary class and create the correctly sized resolved class.
StackHandleScope<1> hs(self);
auto h_new_class = hs.NewHandle(klass->CopyOf(self, class_size, imt, image_pointer_size_));
- // Set array lengths to 0 since we don't want the GC to visit two different classes with the
- // same ArtFields with the same If this occurs, it causes bugs in remembered sets since the GC
- // may not see any references to the from space and clean the card. Though there was references
- // to the from space that got marked by the first class.
+ // Set arrays to null since we don't want to have multiple classes with the same ArtField or
+ // ArtMethod array pointers. If this occurs, it causes bugs in remembered sets since the GC
+ // may not see any references to the target space and clean the card for a class if another
+ // class had the same array pointer.
klass->SetDirectMethodsPtrUnchecked(nullptr);
klass->SetVirtualMethodsPtr(nullptr);
klass->SetSFieldsPtrUnchecked(nullptr);
@@ -4973,8 +4973,8 @@ bool ClassLinker::LinkInterfaceMethods(Thread* self, Handle<mirror::Class> klass
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 @@ bool ClassLinker::LinkInterfaceMethods(Thread* self, Handle<mirror::Class> klass
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.