Search in sources :

Example 6 with MMTkThread

use of org.mmtk.harness.scheduler.MMTkThread in project JikesRVM by JikesRVM.

the class RawMemoryFreeListTest method testRawMemoryFreeListAddrAddrIntIntLarge.

@Test
public void testRawMemoryFreeListAddrAddrIntIntLarge() throws Throwable {
    Thread t = new MMTkThread() {

        @Override
        public void run() {
            new RawMemoryFreeList(baseAddress, mapLimit(ONE_MEG, 2), ONE_MEG, 2);
        }
    };
    runMMTkThread(t);
}
Also used : MMTkThread(org.mmtk.harness.scheduler.MMTkThread) MMTkThread(org.mmtk.harness.scheduler.MMTkThread) Test(org.junit.Test)

Example 7 with MMTkThread

use of org.mmtk.harness.scheduler.MMTkThread in project JikesRVM by JikesRVM.

the class RawMemoryFreeListTest method testMulti.

@Test
public void testMulti() throws Throwable {
    Thread t = new MMTkThread() {

        @Override
        public void run() {
            RawMemoryFreeList fl = new RawMemoryFreeList(baseAddress, mapLimit(ONE_MEG, 32), 1024, 8, 1);
            fl.growFreeList(0);
            fl.dbgPrintSummary();
            fl.dbgPrintDetail();
            fl.dbgPrintFree();
            fl.growFreeList(16);
            fl.dbgPrintDetail();
            fl.dbgPrintFree();
            assertEquals("initial 8-unit allocation", 0, fl.alloc(8));
            fl.dbgPrintDetail();
            fl.dbgPrintFree();
            for (int i = 8; i < 16; i++) {
                assertEquals("following 1-unit allocation", i, fl.alloc(1));
            }
            fl.dbgPrintDetail();
            fl.dbgPrintFree();
            assertEquals("list should be empty", -1, fl.alloc(1));
        }
    };
    runMMTkThread(t);
}
Also used : MMTkThread(org.mmtk.harness.scheduler.MMTkThread) MMTkThread(org.mmtk.harness.scheduler.MMTkThread) Test(org.junit.Test)

Example 8 with MMTkThread

use of org.mmtk.harness.scheduler.MMTkThread in project JikesRVM by JikesRVM.

the class RawMemoryFreeListTest method growFreeListMultiBlock.

protected void growFreeListMultiBlock(final int units, final int grain, final int heads, final int size) throws Throwable {
    Thread t = new MMTkThread() {

        int unit = 0;

        boolean[] allocated = new boolean[units];

        RawMemoryFreeList fl;

        @Override
        public void run() {
            int blockSize = RawMemoryFreeList.defaultBlockSize(units, heads);
            int mapSize = RawMemoryFreeList.sizeInPages(units, heads);
            if (VERBOSE)
                System.out.printf("growFreeListMultiBlock: blockSize=%d mapSize=%d%n", blockSize, mapSize);
            mapSize += mapSize % blockSize == 0 ? 0 : blockSize - mapSize % blockSize;
            fl = new RawMemoryFreeList(baseAddress, baseAddress.plus(Conversions.pagesToBytes(mapSize)), blockSize, units, grain, heads);
            fl.dbgPrintSummary();
            for (int i = 0; i < units; i++) {
                allocated[i] = false;
            }
            fl.dbgPrintSummary();
            fl.growFreeList(units);
            for (int i = 0; i < units / size; i++) {
                assertNotEquals("allocation failure at unit " + unit, GenericFreeList.FAILURE, allocate());
            }
            assertEquals("Free list should be exhausted at unit " + unit, -1, allocate());
            fl.dbgPrintSummary();
            for (int i = 0; i < units; i += size) {
                assertTrue("Unit " + (i + 1) + " is not allocated", allocated[i]);
            }
        }

        protected long allocate() {
            unit += size;
            long block = fl.alloc(size);
            if (block == -1) {
                return block;
            }
            assertFalse("Allocated same block twice, " + block, allocated[(int) block]);
            allocated[(int) block] = true;
            return block;
        }
    };
    runMMTkThread(t);
}
Also used : MMTkThread(org.mmtk.harness.scheduler.MMTkThread) MMTkThread(org.mmtk.harness.scheduler.MMTkThread)

Example 9 with MMTkThread

use of org.mmtk.harness.scheduler.MMTkThread in project JikesRVM by JikesRVM.

the class RawMemoryFreeListTest method testRawMemoryFreeListAddrAddrIntIntEmpty.

@Test
public void testRawMemoryFreeListAddrAddrIntIntEmpty() throws Throwable {
    Thread t = new MMTkThread() {

        @Override
        public void run() {
            new RawMemoryFreeList(baseAddress, baseAddress.plus(PAGE_SIZE), 0, 1);
        }
    };
    runMMTkThread(t);
}
Also used : MMTkThread(org.mmtk.harness.scheduler.MMTkThread) MMTkThread(org.mmtk.harness.scheduler.MMTkThread) Test(org.junit.Test)

Example 10 with MMTkThread

use of org.mmtk.harness.scheduler.MMTkThread in project JikesRVM by JikesRVM.

the class RawMemoryFreeListTest method testGenericFreeListIntIntInt.

@Test
public void testGenericFreeListIntIntInt() throws Throwable {
    Thread t = new MMTkThread() {

        @Override
        public void run() {
            new RawMemoryFreeList(baseAddress, mapLimit(1024, 1), 1024, 1, 1);
        }
    };
    runMMTkThread(t);
}
Also used : MMTkThread(org.mmtk.harness.scheduler.MMTkThread) MMTkThread(org.mmtk.harness.scheduler.MMTkThread) Test(org.junit.Test)

Aggregations

MMTkThread (org.mmtk.harness.scheduler.MMTkThread)29 Test (org.junit.Test)25 BaseMMTkTest (org.mmtk.harness.tests.BaseMMTkTest)7 Address (org.vmmagic.unboxed.Address)6 ArrayList (java.util.ArrayList)1 WatchAddress (org.mmtk.harness.options.WatchAddress)1 Factory (org.mmtk.harness.vm.Factory)1 Extent (org.vmmagic.unboxed.Extent)1