Search in sources :

Example 1 with RawMemoryFreeList

use of org.mmtk.utility.RawMemoryFreeList in project JikesRVM by JikesRVM.

the class Map64 method createFreeList.

@Override
@Interruptible
public GenericFreeList createFreeList(FreeListPageResource pr, int units, int grain) {
    Space space = pr.getSpace();
    Address start = space.getStart();
    Extent extent = space.getExtent();
    int index = spaceIndex(start);
    units = (int) (units * NON_MAP_FRACTION);
    Extent listExtent = Conversions.pagesToBytes(RawMemoryFreeList.sizeInPages(units, 1));
    if (VMLayoutConstants.VERBOSE_BUILD) {
        Log.write("Allocating free list for space ");
        Log.write(space.getName());
        Log.write(", start = ", start);
        Log.write(", extent = ", extent);
        Log.write(", units = ", units);
        Log.write("  listPages = ", RawMemoryFreeList.sizeInPages(units, 1));
        Log.writeln(", listExtent = ", listExtent);
    }
    RawMemoryFreeList list = new RawMemoryFreeList(start, start.plus(listExtent), units, grain);
    flPageResources[index] = pr;
    flMap[index] = list;
    /* Adjust the base address and highwater to account for the allocated chunks for the map */
    Address base = Conversions.chunkAlign(start.plus(listExtent), false);
    highWater.set(index, base);
    baseAddress.set(index, base);
    return list;
}
Also used : Space(org.mmtk.policy.Space) RawMemoryFreeList(org.mmtk.utility.RawMemoryFreeList) Address(org.vmmagic.unboxed.Address) Extent(org.vmmagic.unboxed.Extent) Interruptible(org.vmmagic.pragma.Interruptible)

Example 2 with RawMemoryFreeList

use of org.mmtk.utility.RawMemoryFreeList in project JikesRVM by JikesRVM.

the class Map64 method allocateContiguousChunks.

/**
 * Allocate some number of contiguous chunks within a discontiguous region.  In a 64-bit
 * model, this involves extending a contiguous region, using 'head' as the address
 * of the highest chunk allocated.
 *
 * @param descriptor The descriptor for the space to which these chunks will be assigned
 * @param space The space to which these chunks will be assigned
 * @param chunks The number of chunks required
 * @param head The previous contiguous set of chunks for this space (to create a linked list of contiguous regions for each space)
 * @return The address of the assigned memory.  If the request fails we return Address.zero().
 */
@Override
public Address allocateContiguousChunks(int descriptor, Space space, int chunks, Address head) {
    if (VM.VERIFY_ASSERTIONS)
        VM.assertions._assert(spaceIndex(space.getStart()) == SpaceDescriptor.getIndex(descriptor));
    int index = SpaceDescriptor.getIndex(descriptor);
    Address rtn = highWater.get(index);
    Extent extent = Extent.fromIntZeroExtend(chunks << LOG_BYTES_IN_CHUNK);
    highWater.set(index, rtn.plus(extent));
    /* Grow the free list to accommodate the new chunks */
    RawMemoryFreeList freeList = flMap[spaceIndex(space.getStart())];
    if (freeList != null) {
        freeList.growFreeList(Conversions.bytesToPages(extent));
        int basePage = Conversions.bytesToPages(rtn.diff(baseAddress.get(index)));
        for (int offset = 0; offset < chunks * PAGES_IN_CHUNK; offset += PAGES_IN_CHUNK) {
            freeList.setUncoalescable(basePage + offset);
            /* The 32-bit implementation requires that pages are returned allocated to the caller */
            freeList.alloc(PAGES_IN_CHUNK, basePage + offset);
        }
    }
    return rtn;
}
Also used : RawMemoryFreeList(org.mmtk.utility.RawMemoryFreeList) Address(org.vmmagic.unboxed.Address) Extent(org.vmmagic.unboxed.Extent)

Aggregations

RawMemoryFreeList (org.mmtk.utility.RawMemoryFreeList)2 Address (org.vmmagic.unboxed.Address)2 Extent (org.vmmagic.unboxed.Extent)2 Space (org.mmtk.policy.Space)1 Interruptible (org.vmmagic.pragma.Interruptible)1