diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-10-15 18:02:56 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-10-15 18:36:10 -0700 |
commit | a05e22948de8285f0157e318e9d06e562f4a9440 (patch) | |
tree | 449c059172caf3c9e0463ef0f32613dbf5875adf /libart/src/main | |
parent | a96d6871503966e8589ee8d929acc68ee1e4d59c (diff) | |
download | libcore-a05e22948de8285f0157e318e9d06e562f4a9440.zip libcore-a05e22948de8285f0157e318e9d06e562f4a9440.tar.gz libcore-a05e22948de8285f0157e318e9d06e562f4a9440.tar.bz2 |
Fix ReferenceQueueDaemon.enqueue to start at element 1 of the list
Previously we started at element 2 and had that element 1 was the
last one finalized. This caused System.runFinalzition to
occasionally finish before all of the objects were finalized.
Bug: 17932313
Change-Id: I410dc1ef97ecd30c35f0fc0c3fdfbcc9caa585dd
Diffstat (limited to 'libart/src/main')
-rw-r--r-- | libart/src/main/java/java/lang/Daemons.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/libart/src/main/java/java/lang/Daemons.java b/libart/src/main/java/java/lang/Daemons.java index 71a8d86..a414c49 100644 --- a/libart/src/main/java/java/lang/Daemons.java +++ b/libart/src/main/java/java/lang/Daemons.java @@ -143,20 +143,14 @@ public final class Daemons { } private void enqueue(Reference<?> list) { - while (list != null) { - Reference<?> reference; - // pendingNext is owned by the GC so no synchronization is required - if (list == list.pendingNext) { - reference = list; - reference.pendingNext = null; - list = null; - } else { - reference = list.pendingNext; - list.pendingNext = reference.pendingNext; - reference.pendingNext = null; - } - reference.enqueueInternal(); - } + Reference<?> start = list; + do { + // pendingNext is owned by the GC so no synchronization is required. + Reference<?> next = list.pendingNext; + list.pendingNext = null; + list.enqueueInternal(); + list = next; + } while (list != start); } } |