• Home
  • Raw
  • Download

Lines Matching refs:heapSource

143 static void enqueueBlock(HeapSource *heapSource, size_t block);
246 static void describeBlocks(const HeapSource *heapSource) in describeBlocks() argument
248 for (size_t i = 0; i < heapSource->totalBlocks; ++i) { in describeBlocks()
250 printf("%d ", heapSource->blockSpace[i]); in describeBlocks()
282 static int isValidAddress(const HeapSource *heapSource, const u1 *addr) in isValidAddress() argument
287 return heapSource->baseBlock <= block && in isValidAddress()
288 heapSource->limitBlock > block; in isValidAddress()
296 static void *allocateBlocks(HeapSource *heapSource, size_t blocks) in allocateBlocks() argument
298 size_t allocBlocks = heapSource->allocBlocks; in allocateBlocks()
299 size_t totalBlocks = heapSource->totalBlocks; in allocateBlocks()
310 if (heapSource->blockSpace[i+j] != BLOCK_FREE) { in allocateBlocks()
320 heapSource->blockSpace[i] = BLOCK_TO_SPACE; /* why to-space? */ in allocateBlocks()
322 heapSource->blockSpace[i+j] = BLOCK_CONTINUED; in allocateBlocks()
324 heapSource->allocBlocks += blocks; in allocateBlocks()
325 void *addr = &heapSource->blockBase[i*BLOCK_SIZE]; in allocateBlocks()
328 if (heapSource->queueHead != QUEUE_TAIL) { in allocateBlocks()
329 LOG_ALLOC("allocateBlocks allocBlocks=%zu,block#=%zu", heapSource->allocBlocks, i); in allocateBlocks()
335 enqueueBlock(heapSource, i); in allocateBlocks()
342 heapSource->totalBlocks, in allocateBlocks()
343 heapSource->allocBlocks, in allocateBlocks()
344 heapSource->bytesAllocated); in allocateBlocks()
349 static size_t addressToBlock(const HeapSource *heapSource, const void *addr) in addressToBlock() argument
351 assert(heapSource != NULL); in addressToBlock()
352 assert(isValidAddress(heapSource, addr)); in addressToBlock()
353 return (((uintptr_t)addr) >> BLOCK_SHIFT) - heapSource->baseBlock; in addressToBlock()
357 static u1 *blockToAddress(const HeapSource *heapSource, size_t block) in blockToAddress() argument
361 addr = (u1 *) (((uintptr_t) heapSource->baseBlock + block) * BLOCK_SIZE); in blockToAddress()
362 assert(isValidAddress(heapSource, addr)); in blockToAddress()
366 static void clearBlock(HeapSource *heapSource, size_t block) in clearBlock() argument
368 assert(heapSource != NULL); in clearBlock()
369 assert(block < heapSource->totalBlocks); in clearBlock()
370 u1 *addr = heapSource->blockBase + block*BLOCK_SIZE; in clearBlock()
373 dvmHeapBitmapClearObjectBit(&heapSource->allocBits, addr + i); in clearBlock()
377 static void clearFromSpace(HeapSource *heapSource) in clearFromSpace() argument
379 assert(heapSource != NULL); in clearFromSpace()
382 while (i < heapSource->totalBlocks) { in clearFromSpace()
383 if (heapSource->blockSpace[i] != BLOCK_FROM_SPACE) { in clearFromSpace()
387 heapSource->blockSpace[i] = BLOCK_FREE; in clearFromSpace()
388 clearBlock(heapSource, i); in clearFromSpace()
391 while (i < heapSource->totalBlocks && in clearFromSpace()
392 heapSource->blockSpace[i] == BLOCK_CONTINUED) { in clearFromSpace()
393 heapSource->blockSpace[i] = BLOCK_FREE; in clearFromSpace()
394 clearBlock(heapSource, i); in clearFromSpace()
406 static void enqueueBlock(HeapSource *heapSource, size_t block) in enqueueBlock() argument
408 assert(heapSource != NULL); in enqueueBlock()
409 assert(block < heapSource->totalBlocks); in enqueueBlock()
410 if (heapSource->queueHead != QUEUE_TAIL) { in enqueueBlock()
411 heapSource->blockQueue[heapSource->queueTail] = block; in enqueueBlock()
413 heapSource->queueHead = block; in enqueueBlock()
415 heapSource->blockQueue[block] = QUEUE_TAIL; in enqueueBlock()
416 heapSource->queueTail = block; in enqueueBlock()
417 ++heapSource->queueSize; in enqueueBlock()
424 static void promoteBlockByAddr(HeapSource *heapSource, const void *addr) in promoteBlockByAddr() argument
428 block = addressToBlock(heapSource, (const u1 *)addr); in promoteBlockByAddr()
429 if (heapSource->blockSpace[block] != BLOCK_TO_SPACE) { in promoteBlockByAddr()
431 heapSource->blockSpace[block] = BLOCK_TO_SPACE; in promoteBlockByAddr()
432 enqueueBlock(heapSource, block); in promoteBlockByAddr()
434 heapSource->allocBlocks += 1; in promoteBlockByAddr()
443 HeapSource *heapSource; in dvmHeapSourceStartup() local
447 heapSource = calloc(1, sizeof(*heapSource)); in dvmHeapSourceStartup()
448 assert(heapSource != NULL); in dvmHeapSourceStartup()
450 heapSource->minimumSize = alignUp(startSize, BLOCK_SIZE); in dvmHeapSourceStartup()
451 heapSource->maximumSize = alignUp(absoluteMaxSize, BLOCK_SIZE); in dvmHeapSourceStartup()
453 heapSource->currentSize = heapSource->maximumSize; in dvmHeapSourceStartup()
456 heapSource->blockBase = virtualAlloc(heapSource->maximumSize); in dvmHeapSourceStartup()
457 assert(heapSource->blockBase != NULL); in dvmHeapSourceStartup()
458 heapSource->baseBlock = (uintptr_t) heapSource->blockBase >> BLOCK_SHIFT; in dvmHeapSourceStartup()
459heapSource->limitBlock = ((uintptr_t) heapSource->blockBase + heapSource->maximumSize) >> BLOCK_SH… in dvmHeapSourceStartup()
461 heapSource->allocBlocks = 0; in dvmHeapSourceStartup()
462 heapSource->totalBlocks = (heapSource->limitBlock - heapSource->baseBlock); in dvmHeapSourceStartup()
464 assert(heapSource->totalBlocks = heapSource->maximumSize / BLOCK_SIZE); in dvmHeapSourceStartup()
467 size_t size = sizeof(heapSource->blockQueue[0]); in dvmHeapSourceStartup()
468 heapSource->blockQueue = malloc(heapSource->totalBlocks*size); in dvmHeapSourceStartup()
469 assert(heapSource->blockQueue != NULL); in dvmHeapSourceStartup()
470 memset(heapSource->blockQueue, 0xCC, heapSource->totalBlocks*size); in dvmHeapSourceStartup()
471 heapSource->queueHead = QUEUE_TAIL; in dvmHeapSourceStartup()
476 size_t size = sizeof(heapSource->blockSpace[0]); in dvmHeapSourceStartup()
477 heapSource->blockSpace = calloc(1, heapSource->totalBlocks*size); in dvmHeapSourceStartup()
478 assert(heapSource->blockSpace != NULL); in dvmHeapSourceStartup()
481 dvmHeapBitmapInit(&heapSource->allocBits, in dvmHeapSourceStartup()
482 heapSource->blockBase, in dvmHeapSourceStartup()
483 heapSource->maximumSize, in dvmHeapSourceStartup()
487 heapSource->allocPtr = allocateBlocks(heapSource, 1); in dvmHeapSourceStartup()
488 heapSource->allocLimit = heapSource->allocPtr + BLOCK_SIZE; in dvmHeapSourceStartup()
492 gcHeap->heapSource = heapSource; in dvmHeapSourceStartup()
515 if (*gcHeap == NULL || (*gcHeap)->heapSource == NULL) in dvmHeapSourceShutdown()
517 free((*gcHeap)->heapSource->blockQueue); in dvmHeapSourceShutdown()
518 free((*gcHeap)->heapSource->blockSpace); in dvmHeapSourceShutdown()
519 virtualFree((*gcHeap)->heapSource->blockBase, in dvmHeapSourceShutdown()
520 (*gcHeap)->heapSource->maximumSize); in dvmHeapSourceShutdown()
521 free((*gcHeap)->heapSource); in dvmHeapSourceShutdown()
522 (*gcHeap)->heapSource = NULL; in dvmHeapSourceShutdown()
531 HeapSource *heapSource; in dvmHeapSourceGetValue() local
534 heapSource = gDvm.gcHeap->heapSource; in dvmHeapSourceGetValue()
537 value = heapSource->maximumSize; in dvmHeapSourceGetValue()
540 value = heapSource->maximumSize; in dvmHeapSourceGetValue()
543 value = heapSource->bytesAllocated; in dvmHeapSourceGetValue()
546 value = sumHeapBitmap(&heapSource->allocBits); in dvmHeapSourceGetValue()
570 return &gDvm.gcHeap->heapSource->allocBits; in dvmHeapSourceGetLiveBits()
585 HeapSource *heapSource; in dvmHeapSourceAlloc() local
589 heapSource = gDvm.gcHeap->heapSource; in dvmHeapSourceAlloc()
590 assert(heapSource != NULL); in dvmHeapSourceAlloc()
591 assert(heapSource->allocPtr != NULL); in dvmHeapSourceAlloc()
592 assert(heapSource->allocLimit != NULL); in dvmHeapSourceAlloc()
595 available = heapSource->allocLimit - heapSource->allocPtr; in dvmHeapSourceAlloc()
599 addr = heapSource->allocPtr; in dvmHeapSourceAlloc()
600 heapSource->allocPtr += aligned; in dvmHeapSourceAlloc()
601 heapSource->bytesAllocated += aligned; in dvmHeapSourceAlloc()
602 dvmHeapBitmapSetObjectBit(&heapSource->allocBits, addr); in dvmHeapSourceAlloc()
608 addr = allocateBlocks(heapSource, 1); in dvmHeapSourceAlloc()
610 heapSource->allocLimit = addr + BLOCK_SIZE; in dvmHeapSourceAlloc()
611 heapSource->allocPtr = addr + aligned; in dvmHeapSourceAlloc()
612 heapSource->bytesAllocated += aligned; in dvmHeapSourceAlloc()
613 dvmHeapBitmapSetObjectBit(&heapSource->allocBits, addr); in dvmHeapSourceAlloc()
622 addr = allocateBlocks(heapSource, blocks); in dvmHeapSourceAlloc()
625 heapSource->bytesAllocated += aligned; in dvmHeapSourceAlloc()
626 dvmHeapBitmapSetObjectBit(&heapSource->allocBits, addr); in dvmHeapSourceAlloc()
640 HeapSource *heapSource; in allocateGray() local
645 heapSource = gDvm.gcHeap->heapSource; in allocateGray()
648 block = addressToBlock(heapSource, (const u1 *)addr); in allocateGray()
649 if (heapSource->queueHead == QUEUE_TAIL) { in allocateGray()
655 enqueueBlock(heapSource, block); in allocateGray()
656 LOG_PROM("forced promoting block %zu %d @ %p", block, heapSource->blockSpace[block], addr); in allocateGray()
663 HeapSource *heapSource = gDvm.gcHeap->heapSource; in dvmHeapSourceContainsAddress() local
664 return dvmHeapBitmapCoversAddress(&heapSource->allocBits, ptr); in dvmHeapSourceContainsAddress()
673 HeapSource *heapSource; in dvmHeapSourceContains() local
676 heapSource = gDvm.gcHeap->heapSource; in dvmHeapSourceContains()
677 bitmap = &heapSource->allocBits; in dvmHeapSourceContains()
710 return gDvm.gcHeap->heapSource->currentSize; in dvmHeapSourceGetIdealFootprint()
765 HeapSource *heapSource = gDvm.gcHeap->heapSource; in dvmHeapSourceFlip() local
768 heapSource->allocBlocks = 0; in dvmHeapSourceFlip()
769 heapSource->queueSize = 0; in dvmHeapSourceFlip()
770 heapSource->queueHead = QUEUE_TAIL; in dvmHeapSourceFlip()
774 heapSource->allocPtr = NULL; in dvmHeapSourceFlip()
775 heapSource->allocLimit = NULL; in dvmHeapSourceFlip()
778 for (size_t i = 0; i < heapSource->totalBlocks; ++i) { in dvmHeapSourceFlip()
779 if (heapSource->blockSpace[i] == BLOCK_TO_SPACE) { in dvmHeapSourceFlip()
780 heapSource->blockSpace[i] = BLOCK_FROM_SPACE; in dvmHeapSourceFlip()
787 HeapSource *heapSource = gDvm.gcHeap->heapSource; in room() local
788 *total = heapSource->totalBlocks*BLOCK_SIZE; in room()
789 *alloc = heapSource->allocBlocks*BLOCK_SIZE; in room()
795 HeapSource *heapSource; in isSpaceInternal() local
800 heapSource = gDvm.gcHeap->heapSource; in isSpaceInternal()
801 base = heapSource->blockBase; in isSpaceInternal()
803 limit = heapSource->blockBase + heapSource->maximumSize; in isSpaceInternal()
806 space2 = heapSource->blockSpace[offset >> BLOCK_SHIFT]; in isSpaceInternal()
826 promoteBlockByAddr(gDvm.gcHeap->heapSource, obj); in pinObject()
1285 gDvm.gcHeap->heapSource->allocBlocks); in transportObject()
1318 fromObj, addressToBlock(gDvm.gcHeap->heapSource,fromObj), in transportObject()
1319 toObj, addressToBlock(gDvm.gcHeap->heapSource,toObj), in transportObject()
1881 static void scavengeBlock(HeapSource *heapSource, size_t block) in scavengeBlock() argument
1887 LOG_SCAV("scavengeBlock(heapSource=%p,block=%zu)", heapSource, block); in scavengeBlock()
1889 assert(heapSource != NULL); in scavengeBlock()
1890 assert(block < heapSource->totalBlocks); in scavengeBlock()
1891 assert(heapSource->blockSpace[block] == BLOCK_TO_SPACE); in scavengeBlock()
1893 cursor = blockToAddress(heapSource, block); in scavengeBlock()
1938 static void verifyBlock(HeapSource *heapSource, size_t block) in verifyBlock() argument
1946 assert(heapSource != NULL); in verifyBlock()
1947 assert(block < heapSource->totalBlocks); in verifyBlock()
1948 assert(heapSource->blockSpace[block] == BLOCK_TO_SPACE); in verifyBlock()
1950 cursor = blockToAddress(heapSource, block); in verifyBlock()
1975 static void describeBlockQueue(const HeapSource *heapSource) in describeBlockQueue() argument
1980 block = heapSource->queueHead; in describeBlockQueue()
1982 LOG_SCAV(">>> describeBlockQueue(heapSource=%p)", heapSource); in describeBlockQueue()
1985 block = heapSource->blockQueue[block]; in describeBlockQueue()
1989 count, heapSource->queueSize); in describeBlockQueue()
1990 block = heapSource->queueHead; in describeBlockQueue()
1992 space = heapSource->blockSpace[block]; in describeBlockQueue()
1993 LOG_SCAV("block=%zu@%p,space=%zu", block, blockToAddress(heapSource,block), space); in describeBlockQueue()
1994 block = heapSource->blockQueue[block]; in describeBlockQueue()
1997 LOG_SCAV("<<< describeBlockQueue(heapSource=%p)", heapSource); in describeBlockQueue()
2005 HeapSource *heapSource; in scavengeBlockQueue() local
2009 heapSource = gDvm.gcHeap->heapSource; in scavengeBlockQueue()
2010 describeBlockQueue(heapSource); in scavengeBlockQueue()
2011 while (heapSource->queueHead != QUEUE_TAIL) { in scavengeBlockQueue()
2012 block = heapSource->queueHead; in scavengeBlockQueue()
2014 scavengeBlock(heapSource, block); in scavengeBlockQueue()
2015 heapSource->queueHead = heapSource->blockQueue[block]; in scavengeBlockQueue()
2016 LOG_SCAV("New queue head is %zu", heapSource->queueHead); in scavengeBlockQueue()
2028 HeapSource *heapSource = gDvm.gcHeap->heapSource; in verifyNewSpace() local
2030 for (size_t i = 0; i < heapSource->totalBlocks; ++i) { in verifyNewSpace()
2031 switch (heapSource->blockSpace[i]) { in verifyNewSpace()
2042 for (size_t i = 0; i < heapSource->totalBlocks; ++i) { in verifyNewSpace()
2043 if (heapSource->blockSpace[i] != BLOCK_TO_SPACE) { in verifyNewSpace()
2046 verifyBlock(heapSource, i); in verifyNewSpace()
2052 HeapSource *heapSource = gDvm.gcHeap->heapSource; in describeHeap() local
2053 describeBlocks(heapSource); in describeHeap()
2097 gDvm.gcHeap->heapSource->allocPtr = allocateBlocks(gDvm.gcHeap->heapSource, 1); in dvmScavengeRoots()
2098 gDvm.gcHeap->heapSource->allocLimit = gDvm.gcHeap->heapSource->allocPtr + BLOCK_SIZE; in dvmScavengeRoots()
2105 promoteBlockByAddr(gDvm.gcHeap->heapSource, gDvm.gcHeap->heapSource->allocPtr); in dvmScavengeRoots()
2168 clearFromSpace(gcHeap->heapSource); in dvmScavengeRoots()