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
          Class variables
static GenericFreeList globalPageMap
           
private static int[] linkageMap
           
private static Lock lock
           
private static Address MAP_BASE_ADDRESS
           
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
static Address allocateContiguousChunks(int descriptor, Space space, int chunks, Address previous)
          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 lastChunk)
          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 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.
private static int hashAddress(Address address)
          Hash an address to a chunk (this is simply done via bit shifting)
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.
private static Address reverseHashChunk(int chunk)
           
 
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

descriptorMap

private static final int[] descriptorMap
Class variables


linkageMap

private static final int[] linkageMap

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 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 previous)
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
previous - The previous contgiuous set of chunks for this space (to create a linked list of contiguous regions for each space)
Returns:
The address of the assigned memory. This always succeeds. If the request fails we fail right here.

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 lastChunk)
Free all chunks in a linked list of contiguous chunks. This means starting with lastChunk and then walking the chain of contiguous regions, freeing each.

Parameters:
lastChunk - The last 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.

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

hashAddress

private static int hashAddress(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

reverseHashChunk

private static Address reverseHashChunk(int chunk)