diff options
| author | Barry Hayes <bhayes@google.com> | 2010-07-12 09:52:20 -0700 |
|---|---|---|
| committer | Barry Hayes <bhayes@google.com> | 2010-07-12 13:32:36 -0700 |
| commit | 4496ed9ef85e19447e697481d16842f47d265756 (patch) | |
| tree | 89d0e3fc0f36d286a1d905f11b2c6552cee946dd /vm/alloc/CardTable.c | |
| parent | 09bd8016621de77c3793ee8c4a7fe224fc73eccf (diff) | |
| download | android_dalvik-4496ed9ef85e19447e697481d16842f47d265756.tar.gz android_dalvik-4496ed9ef85e19447e697481d16842f47d265756.tar.bz2 android_dalvik-4496ed9ef85e19447e697481d16842f47d265756.zip | |
Move the biasedCardTableBase out of the non-public GcHeap structure,
and back to DvmGlobals where it can be found. Create dvmIsValidCard to
access the values hidden in the GcHeap.
This is a half-step to inlining dvmMarkCard and dvmCardFromAddr.
Change-Id: I50158915802d7f08ddadb60ca6907afd279df2a8
Diffstat (limited to 'vm/alloc/CardTable.c')
| -rw-r--r-- | vm/alloc/CardTable.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/vm/alloc/CardTable.c b/vm/alloc/CardTable.c index 49562a7f0..c8d7f0897 100644 --- a/vm/alloc/CardTable.c +++ b/vm/alloc/CardTable.c @@ -91,7 +91,7 @@ bool dvmCardTableStartup(GcHeap *gcHeap, void *heapBase) biasedBase += offset + (offset < 0 ? 0x100 : 0); } assert(((uintptr_t)biasedBase & 0xff) == GC_CARD_DIRTY); - gcHeap->biasedCardTableBase = biasedBase; + gDvm.biasedCardTableBase = biasedBase; return true; } @@ -105,15 +105,24 @@ void dvmCardTableShutdown() } /* + * Returns true iff the address is within the bounds of the card table. + */ +bool dvmIsValidCard(const u1 *cardAddr) +{ + GcHeap *h = gDvm.gcHeap; + return cardAddr >= h->cardTableBase && + cardAddr < &h->cardTableBase[h->cardTableLength]; +} + +/* * Returns the address of the relevent byte in the card table, given * an address on the heap. */ u1 *dvmCardFromAddr(const void *addr) { - GcHeap *h = gDvm.gcHeap; - u1 *cardAddr = h->biasedCardTableBase + ((uintptr_t)addr >> GC_CARD_SHIFT); - assert(cardAddr >= h->cardTableBase); - assert(cardAddr < &h->cardTableBase[h->cardTableLength]); + u1 *biasedBase = gDvm.biasedCardTableBase; + u1 *cardAddr = biasedBase + ((uintptr_t)addr >> GC_CARD_SHIFT); + assert(dvmIsValidCard(cardAddr)); return cardAddr; } @@ -122,10 +131,8 @@ u1 *dvmCardFromAddr(const void *addr) */ void *dvmAddrFromCard(const u1 *cardAddr) { - GcHeap *h = gDvm.gcHeap; - assert(cardAddr >= h->cardTableBase); - assert(cardAddr < &h->cardTableBase[h->cardTableLength]); - uintptr_t offset = cardAddr - h->biasedCardTableBase; + assert(dvmIsValidCard(cardAddr)); + uintptr_t offset = cardAddr - gDvm.biasedCardTableBase; return (void *)(offset << GC_CARD_SHIFT); } |
