From f3f2a7a0dac552593825807605c98f3910f3e557 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 14 Apr 2015 15:43:10 -0700 Subject: Remove suspend point from field loading The error was that we had a partially constructed field array when we got suspended by moving GC. This caused the already allocated fields to not get updated, and be stale roots the next GC. Fixes test 125 with GSS collector. Change-Id: I7278def915f540b6a9d12677a6ba61637f5949a2 --- runtime/class_linker.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/class_linker.cc') diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 935c401825..0d92fc215c 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -1927,7 +1927,6 @@ void ClassLinker::LoadClassMembers(Thread* self, const DexFile& dex_file, ArtField* sfields = num_sfields != 0 ? AllocArtFieldArray(self, num_sfields) : nullptr; for (size_t i = 0; it.HasNextStaticField(); i++, it.Next()) { CHECK_LT(i, num_sfields); - self->AllowThreadSuspension(); LoadField(it, klass, &sfields[i]); } klass->SetSFields(sfields); @@ -1938,13 +1937,14 @@ void ClassLinker::LoadClassMembers(Thread* self, const DexFile& dex_file, ArtField* ifields = num_ifields != 0 ? AllocArtFieldArray(self, num_ifields) : nullptr; for (size_t i = 0; it.HasNextInstanceField(); i++, it.Next()) { CHECK_LT(i, num_ifields); - self->AllowThreadSuspension(); LoadField(it, klass, &ifields[i]); } klass->SetIFields(ifields); klass->SetNumInstanceFields(num_ifields); DCHECK_EQ(klass->NumInstanceFields(), num_ifields); - + // Note: We cannot have thread suspension until the field arrays are setup or else + // Class::VisitFieldRoots may miss some fields. + self->AllowThreadSuspension(); // Load methods. if (it.NumDirectMethods() != 0) { // TODO: append direct methods to class object -- cgit v1.2.3