summaryrefslogtreecommitdiffstats
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-04-14 15:43:10 -0700
committerMathieu Chartier <mathieuc@google.com>2015-04-14 15:43:10 -0700
commitf3f2a7a0dac552593825807605c98f3910f3e557 (patch)
treedad6d3821a562f7c26f9518002a7ed27716205be /runtime/class_linker.cc
parente689c8a41355621e1a4c738ffb9d527e2a567b80 (diff)
downloadandroid_art-f3f2a7a0dac552593825807605c98f3910f3e557.tar.gz
android_art-f3f2a7a0dac552593825807605c98f3910f3e557.tar.bz2
android_art-f3f2a7a0dac552593825807605c98f3910f3e557.zip
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
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc6
1 files changed, 3 insertions, 3 deletions
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