org.mmtk.utility.heap
Class Map

java.lang.Object
  extended by org.mmtk.utility.heap.Map

public class Map
extends Object

This class manages the mapping of spaces to virtual memory ranges.


Field Summary
private static int[] descriptorMap
           
static GenericFreeList globalPageMap
           
private static Lock lock
           
private static Address MAP_BASE_ADDRESS
          set the map base address so that we have an unused null chunk at the bottome of the space for 64 bit
private static int[] nextLink
           
private static int[] prevLink
           
private static GenericFreeList regionMap
           
private static int sharedDiscontigFLCount
           
private static FreeListPageResource[] sharedFLMap
           
private static Space[] spaceMap
           
private static int totalAvailableDiscontiguousChunks
           
 
Constructor Summary
Map()
           
 
Method Summary
private static Address addressForChunkIndex(int chunk)
           
static Address allocateContiguousChunks(int descriptor, Space space, int chunks, Address head)
          Allocate some number of contiguous chunks within a discontiguous region.
static void finalizeStaticSpaceMap()
          Finalize the space map, establishing which virtual memory is nailed down, and then placing the rest into a map to be used by discontiguous spaces.
static void freeAllChunks(Address anyChunk)
          Free all chunks in a linked list of contiguous chunks.
static int freeContiguousChunks(Address start)
          Free some set of contiguous chunks, given the chunk address
private static int freeContiguousChunks(int chunk)
          Free some set of contiguous chunks, given the chunk index
static int getAvailableDiscontiguousChunks()
          Return the total number of chunks available (unassigned) within the range of virtual memory apportioned to discontiguous spaces.
static int getChunkConsumerCount()
          Return the total number of clients contending for chunks.
private static int getChunkIndex(Address address)
          Hash an address to a chunk (this is simply done via bit shifting)
static int getContiguousRegionChunks(Address start)
          Return the size of a contiguous region in chunks.
static Extent getContiguousRegionSize(Address start)
          Return the size of a contiguous region in bytes.
static int getDescriptorForAddress(Address object)
          Return the space descriptor for the space in which this object resides.
static int getDiscontigFreeListPROrdinal(FreeListPageResource pr)
          Return the ordinal number for some free list space wishing to share a discontiguous region.
static Address getNextContiguousRegion(Address start)
          Return the address of the next contiguous region associated with some discontiguous space by following the linked list for that space.
static Space getSpaceForAddress(Address address)
          Return the space in which this address resides.
static void insert(Address start, Extent extent, int descriptor, Space space)
          Insert a space and its descriptor into the map, associating it with a particular address range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAP_BASE_ADDRESS

private static final Address MAP_BASE_ADDRESS
set the map base address so that we have an unused null chunk at the bottome of the space for 64 bit


descriptorMap

private static final int[] descriptorMap

prevLink

private static final int[] prevLink

nextLink

private static final int[] nextLink

spaceMap

private static final Space[] spaceMap

regionMap

private static final GenericFreeList regionMap

globalPageMap

public static final GenericFreeList globalPageMap

sharedDiscontigFLCount

private static int sharedDiscontigFLCount

sharedFLMap

private static final FreeListPageResource[] sharedFLMap

totalAvailableDiscontiguousChunks

private static int totalAvailableDiscontiguousChunks

lock

private static final Lock lock
Constructor Detail

Map

public Map()
Method Detail

insert

public static void insert(Address start,
                          Extent extent,
                          int descriptor,
                          Space space)
Insert a space and its descriptor into the map, associating it with a particular address range.

Parameters:
start - The start address of the region to be associated with this space.
extent - The size of the region, in bytes
descriptor - The descriptor for this space
space - The space to be associated with this region

allocateContiguousChunks

public static Address allocateContiguousChunks(int descriptor,
                                               Space space,
                                               int chunks,
                                               Address head)
Allocate some number of contiguous chunks within a discontiguous region.

Parameters:
descriptor - The descriptor for the space to which these chunks will be assigned
space - The space to which these chunks will be assigned
chunks - The number of chunks required
head - The previous contiguous set of chunks for this space (to create a linked list of contiguous regions for each space)
Returns:
The address of the assigned memory. If the request fails we return Address.zero().

getNextContiguousRegion

public static Address getNextContiguousRegion(Address start)
Return the address of the next contiguous region associated with some discontiguous space by following the linked list for that space.

Parameters:
start - The current region (return the next region in the list)
Returns:
Return the next contiguous region after start in the linked list of regions

getContiguousRegionChunks

public static int getContiguousRegionChunks(Address start)
Return the size of a contiguous region in chunks.

Parameters:
start - The start address of the region whose size is being requested
Returns:
The size of the region in question

getContiguousRegionSize

public static Extent getContiguousRegionSize(Address start)
Return the size of a contiguous region in bytes.

Parameters:
start - The start address of the region whose size is being requested
Returns:
The size of the region in question

freeAllChunks

public static void freeAllChunks(Address anyChunk)
Free all chunks in a linked list of contiguous chunks. This means starting with one and then walking the chains of contiguous regions, freeing each.

Parameters:
anyChunk - Any chunk in the linked list of chunks to be freed

freeContiguousChunks

public static int freeContiguousChunks(Address start)
Free some set of contiguous chunks, given the chunk address

Parameters:
start - The start address of the first chunk in the series
Returns:
The number of chunks which were contiguously allocated

freeContiguousChunks

private static int freeContiguousChunks(int chunk)
Free some set of contiguous chunks, given the chunk index

Parameters:
chunk - The chunk index of the region to be freed
Returns:
The number of chunks freed

finalizeStaticSpaceMap

public static void finalizeStaticSpaceMap()
Finalize the space map, establishing which virtual memory is nailed down, and then placing the rest into a map to be used by discontiguous spaces.


getDiscontigFreeListPROrdinal

public static int getDiscontigFreeListPROrdinal(FreeListPageResource pr)
Return the ordinal number for some free list space wishing to share a discontiguous region.

Returns:
The ordinal number for a free list space wishing to share a discontiguous region

getAvailableDiscontiguousChunks

public static int getAvailableDiscontiguousChunks()
Return the total number of chunks available (unassigned) within the range of virtual memory apportioned to discontiguous spaces.

Returns:
The number of available chunks for use by discontiguous spaces.

getChunkConsumerCount

public static int getChunkConsumerCount()
Return the total number of clients contending for chunks. This is useful when establishing conservative bounds on the number of remaining chunks.

Returns:
The total number of clients who may contend for chunks.

getSpaceForAddress

public static Space getSpaceForAddress(Address address)
Return the space in which this address resides.

Parameters:
address - The address in question
Returns:
The space in which the address resides

getDescriptorForAddress

public static int getDescriptorForAddress(Address object)
Return the space descriptor for the space in which this object resides.

Parameters:
object - The object in question
Returns:
The space descriptor for the space in which the object resides

getChunkIndex

private static int getChunkIndex(Address address)
Hash an address to a chunk (this is simply done via bit shifting)

Parameters:
address - The address to be hashed
Returns:
The chunk number that this address hashes into

addressForChunkIndex

private static Address addressForChunkIndex(int chunk)