diff options
author | Elliott Hughes <enh@google.com> | 2011-07-11 16:44:34 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2011-07-11 18:25:39 -0700 |
commit | 259a8a5154c63a793ea0ee438d146acda7d990b6 (patch) | |
tree | a5fb236ebb92b24b1c1784ed7d88a05a8b8d0fae /vm/alloc/MarkSweep.cpp | |
parent | ea333384b92db9c400be1b4c8cb6992d9ba5f14d (diff) | |
download | android_dalvik-259a8a5154c63a793ea0ee438d146acda7d990b6.tar.gz android_dalvik-259a8a5154c63a793ea0ee438d146acda7d990b6.tar.bz2 android_dalvik-259a8a5154c63a793ea0ee438d146acda7d990b6.zip |
Fix the jweak implementation.
We need to distinguish between "cleared weak global" and "deleted weak global".
Previously we used NULL for both. Now we add a magic value for cleared weak
globals. I've also switched the GC over to using iterators, so IndirectRefTable
itself becomes responsible for not showing bad pointers to the GC.
I've also improved the reference table dumping to cope with the new scheme and
to be a bit easier to read (through extra indentation).
Bug: 4260055
Change-Id: I26af301fb2b46d014c6f6b0915a8f8a7fb6d7c5b
Diffstat (limited to 'vm/alloc/MarkSweep.cpp')
-rw-r--r-- | vm/alloc/MarkSweep.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/vm/alloc/MarkSweep.cpp b/vm/alloc/MarkSweep.cpp index 19fadc13e..3868909bd 100644 --- a/vm/alloc/MarkSweep.cpp +++ b/vm/alloc/MarkSweep.cpp @@ -996,15 +996,15 @@ static int isUnmarkedObject(void *obj) return !isMarked((Object *)obj, &gDvm.gcHeap->markContext); } -void sweepWeakJniGlobals() +static void sweepWeakJniGlobals() { - IndirectRefTable *table = &gDvm.jniWeakGlobalRefTable; - Object **entry = table->table; - GcMarkContext *ctx = &gDvm.gcHeap->markContext; - int numEntries = table->capacity(); - for (int i = 0; i < numEntries; ++i) { - if (entry[i] != NULL && !isMarked(entry[i], ctx)) { - entry[i] = NULL; + IndirectRefTable* table = &gDvm.jniWeakGlobalRefTable; + GcMarkContext* ctx = &gDvm.gcHeap->markContext; + typedef IndirectRefTable::iterator It; // TODO: C++0x auto + for (It it = table->begin(), end = table->end(); it != end; ++it) { + Object** entry = *it; + if (!isMarked(*entry, ctx)) { + *entry = kClearedJniWeakGlobal; } } } |