Beispiel #1
0
void assert_empty(const HeapBitmap *hb)
{
    assert(hb->bits != NULL);
    assert(hb->bitsLen >= HB_OFFSET_TO_INDEX(HEAP_SIZE));
    assert(hb->base == (uintptr_t)HEAP_BASE);
    assert(hb->max < hb->base);

    assert(is_zeroed(hb));

    assert(!dvmHeapBitmapMayContainObject(hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapMayContainObject(hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(hb,
            HEAP_BASE + HEAP_SIZE));

    assert(!dvmHeapBitmapIsObjectBitSet(hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapIsObjectBitSet(hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
}
Beispiel #2
0
/*
 * Returns true iff <ptr> was allocated from the heap source.
 */
bool dvmHeapSourceContains(const void *ptr)
{
    HS_BOILERPLATE();

    if (dvmHeapSourceContainsAddress(ptr)) {
        return dvmHeapBitmapIsObjectBitSet(&gHs->liveBits, ptr) != 0;
    }
    return false;
}
Beispiel #3
0
/* Do not cast the result of this to a boolean; the only set bit
 * may be > 1<<8.
 */
static inline long isMarked(const void *obj, const GcMarkContext *ctx)
{
    return dvmHeapBitmapIsObjectBitSet(ctx->bitmap, obj);
}
Beispiel #4
0
/*
 * Returns true if the given object is marked.
 */
static bool isMarked(const Object *obj, const GcMarkContext *ctx)
{
    return dvmHeapBitmapIsObjectBitSet(ctx->bitmap, obj);
}
Beispiel #5
0
void
test_modify()
{
    HeapBitmap hb;
    bool ok;
    unsigned long bit;

    ok = dvmHeapBitmapInit(&hb, HEAP_BASE, HEAP_SIZE, "test");
    assert(ok);
    assert_empty(&hb);

    /* Set the lowest address.
     */
    bit = dvmHeapBitmapSetAndReturnObjectBit(&hb, HEAP_BASE);
    assert(bit == 0);
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE));

    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));

    /* Set the lowest address again.
     */
    bit = dvmHeapBitmapSetAndReturnObjectBit(&hb, HEAP_BASE);
    assert(bit != 0);
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE));

    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));

    /* Set the highest address.
     */
    bit = dvmHeapBitmapSetAndReturnObjectBit(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT);
    assert(bit == 0);
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE));
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE));

    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));

    /* Set the highest address again.
     */
    bit = dvmHeapBitmapSetAndReturnObjectBit(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT);
    assert(bit != 0);
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE));
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE));

    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));

    /* Clean up.
     */
    dvmHeapBitmapDelete(&hb);
}
Beispiel #6
0
void
test_bits()
{
    HeapBitmap hb;
    bool ok;

    ok = dvmHeapBitmapInit(&hb, HEAP_BASE, HEAP_SIZE, "test");
    assert(ok);

    assert_empty(&hb);

    /* Set the lowest address.
     */
    dvmHeapBitmapSetObjectBit(&hb, HEAP_BASE);
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE));

    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));

    /* Set the highest address.
     */
    dvmHeapBitmapSetObjectBit(&hb, HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT);
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE));
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapMayContainObject(&hb,
            HEAP_BASE + HEAP_SIZE));

    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));

    /* Clear the lowest address.
     */
    dvmHeapBitmapClearObjectBit(&hb, HEAP_BASE);
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(!is_zeroed(&hb));

    /* Clear the highest address.
     */
    dvmHeapBitmapClearObjectBit(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT);
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HB_OBJECT_ALIGNMENT));
    assert(!dvmHeapBitmapIsObjectBitSet(&hb,
            HEAP_BASE + HEAP_SIZE - HB_OBJECT_ALIGNMENT));
    assert(is_zeroed(&hb));

    /* Clean up.
     */
    dvmHeapBitmapDelete(&hb);
}