summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2011-04-04 12:15:17 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-04-04 12:15:17 -0700
commit91f8ba6b40719d383fac6368ecf0904cfa817d1b (patch)
tree26d6d69ec6a4ca815fa1ac9e93601ccea2953a45
parent84b58fd621a148d8273776ec42cbc827f34b8a62 (diff)
parentc26cd1ae75aa947b452ebe208b1ceaa06f292378 (diff)
downloadandroid_dalvik-91f8ba6b40719d383fac6368ecf0904cfa817d1b.tar.gz
android_dalvik-91f8ba6b40719d383fac6368ecf0904cfa817d1b.tar.bz2
android_dalvik-91f8ba6b40719d383fac6368ecf0904cfa817d1b.zip
am c26cd1ae: Merge "Fix sizing of the modunion table on small heaps"
* commit 'c26cd1ae75aa947b452ebe208b1ceaa06f292378': Fix sizing of the modunion table on small heaps
-rw-r--r--vm/Misc.c8
-rw-r--r--vm/alloc/CardTable.c11
-rw-r--r--vm/alloc/MarkSweep.c17
3 files changed, 19 insertions, 17 deletions
diff --git a/vm/Misc.c b/vm/Misc.c
index f5fd34a5b..2c3926c16 100644
--- a/vm/Misc.c
+++ b/vm/Misc.c
@@ -571,16 +571,16 @@ size_t strlcpy(char *dst, const char *src, size_t size) {
* zero. Actual allocation rounded up to page multiple. Returns
* NULL on failure.
*/
-void *dvmAllocRegion(size_t size, int prot, const char *name) {
+void *dvmAllocRegion(size_t byteCount, int prot, const char *name) {
void *base;
int fd, ret;
- size = ALIGN_UP_TO_PAGE_SIZE(size);
- fd = ashmem_create_region(name, size);
+ byteCount = ALIGN_UP_TO_PAGE_SIZE(byteCount);
+ fd = ashmem_create_region(name, byteCount);
if (fd == -1) {
return NULL;
}
- base = mmap(NULL, size, prot, MAP_PRIVATE, fd, 0);
+ base = mmap(NULL, byteCount, prot, MAP_PRIVATE, fd, 0);
ret = close(fd);
if (base == MAP_FAILED) {
return NULL;
diff --git a/vm/alloc/CardTable.c b/vm/alloc/CardTable.c
index 2de586e90..533d5bc8a 100644
--- a/vm/alloc/CardTable.c
+++ b/vm/alloc/CardTable.c
@@ -80,18 +80,19 @@ static bool allocCardTable(size_t heapMaximumSize)
return true;
}
-static bool allocModUnionTable(size_t heapMaximumSize)
+static bool allocModUnionTable(size_t heapSize)
{
- size_t length = heapMaximumSize / GC_CARD_SIZE / HB_BITS_PER_WORD;
- assert(length * GC_CARD_SIZE * HB_BITS_PER_WORD == heapMaximumSize);
+ size_t cardsPerHeap = heapSize / GC_CARD_SIZE;
+ size_t byteLength = cardsPerHeap / CHAR_BIT;
+ assert(byteLength * GC_CARD_SIZE * CHAR_BIT == heapSize);
int prot = PROT_READ | PROT_WRITE;
- void *allocBase = dvmAllocRegion(length, prot, "dalvik-modunion-table");
+ void *allocBase = dvmAllocRegion(byteLength, prot, "dalvik-modunion-table");
if (allocBase == NULL) {
return false;
}
GcHeap *gcHeap = gDvm.gcHeap;
gcHeap->modUnionTableBase = (u1*)allocBase;
- gcHeap->modUnionTableLength = length;
+ gcHeap->modUnionTableLength = byteLength;
return true;
}
diff --git a/vm/alloc/MarkSweep.c b/vm/alloc/MarkSweep.c
index e26394c85..85a4a8e91 100644
--- a/vm/alloc/MarkSweep.c
+++ b/vm/alloc/MarkSweep.c
@@ -192,11 +192,12 @@ static void visitModUnionTable(Visitor *visitor, u1 *base, u1 *limit, void *arg)
assert(base >= heapBase);
u4 *bits = (u4*)gDvm.gcHeap->modUnionTableBase;
/* compute the end address in the bit table */
- size_t length = (limit - base) / GC_CARD_SIZE;
- assert(length % sizeof(*bits) == 0);
- length /= 4;
+ size_t byteLength = (limit - base) / GC_CARD_SIZE;
+ assert(byteLength <= gDvm.gcHeap->modUnionTableLength);
+ assert(byteLength % sizeof(*bits) == 0);
+ size_t wordLength = byteLength / sizeof(*bits);
size_t i;
- for (i = 0; i < length; ++i) {
+ for (i = 0; i < wordLength; ++i) {
if (bits[i] == 0) {
continue;
}
@@ -693,12 +694,12 @@ static void scanGrayObjects(GcMarkContext *ctx)
*/
void dvmHeapScanImmuneObjects(const GcMarkContext *ctx)
{
- ScanImmuneObjectContext ctx2;
- memset(&ctx2, 0, sizeof(ctx2));
- ctx2.threatenBoundary = (Object*)ctx->immuneLimit;
+ ScanImmuneObjectContext scanCtx;
+ memset(&scanCtx, 0, sizeof(scanCtx));
+ scanCtx.threatenBoundary = (Object*)ctx->immuneLimit;
visitModUnionTable(scanImmuneObject,
(u1*)ctx->bitmap->base, (u1*)ctx->immuneLimit,
- (void *)&ctx2);
+ (void *)&scanCtx);
if (gDvm.verifyCardTable) {
verifyImmuneObjects();
}