org.mmtk.utility.heap
Class Mmapper

java.lang.Object
  extended by org.mmtk.utility.heap.Mmapper
All Implemented Interfaces:
Constants

public final class Mmapper
extends Object
implements Constants

This class implements mmapping and protection of virtual memory.


Field Summary
static Lock lock
           
static int LOG_MMAP_CHUNK_BYTES
           
private static byte[] mapped
           
static byte MAPPED
           
static int MMAP_CHUNK_BYTES
           
private static int MMAP_CHUNK_MASK
           
private static int MMAP_NUM_CHUNKS
           
static byte PROTECTED
           
static byte UNMAPPED
           
static boolean verbose
           
 
Fields inherited from interface org.mmtk.utility.Constants
ALIGNMENT_VALUE, ARRAY_ELEMENT, BITS_IN_ADDRESS, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_INT, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_INT, BYTES_IN_KBYTE, BYTES_IN_MBYTE, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, CARD_MASK, CARD_META_PAGES_PER_REGION, INSTANCE_FIELD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_INT, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_ADDRESS_SPACE, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_INT, LOG_BYTES_IN_KBYTE, LOG_BYTES_IN_MBYTE, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD, LOG_CARD_BYTES, LOG_CARD_GRAIN, LOG_CARD_META_BYTES, LOG_CARD_META_PAGES, LOG_CARD_META_SIZE, LOG_CARD_UNITS, LOG_MIN_ALIGNMENT, MAX_ALIGNMENT, MAX_BYTES_PADDING, MAX_INT, MIN_ALIGNMENT, MIN_INT, SUPPORT_CARD_SCANNING
 
Constructor Summary
Mmapper()
           
 
Method Summary
static boolean addressIsMapped(Address addr)
          Return true if the given address has been mmapped
private static Address chunkAlignDown(Address addr)
          Return a given address rounded down to an mmap chunk size
private static Address chunkAlignUp(Address addr)
          Return a given address rounded up to an mmap chunk size
static void eagerlyMmapAllSpaces(AddressArray spaceMap)
          Given an address array describing the regions of virtual memory to be used by MMTk, demand zero map all of them if they are not already mapped.
static void ensureMapped(Address start, int pages)
          Ensure that a range of pages is mmapped (or equivalent).
static void markAsMapped(Address start, int bytes)
          Mark a range of pages as having (already) been mapped.
static boolean objectIsMapped(ObjectReference object)
          Return true if the given object has been mmapped
static void protect(Address start, int pages)
          Memory protect a range of pages (using mprotect or equivalent).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNMAPPED

public static final byte UNMAPPED
See Also:
Constant Field Values

MAPPED

public static final byte MAPPED
See Also:
Constant Field Values

PROTECTED

public static final byte PROTECTED
See Also:
Constant Field Values

LOG_MMAP_CHUNK_BYTES

public static final int LOG_MMAP_CHUNK_BYTES
See Also:
Constant Field Values

MMAP_CHUNK_BYTES

public static final int MMAP_CHUNK_BYTES
See Also:
Constant Field Values

MMAP_CHUNK_MASK

private static final int MMAP_CHUNK_MASK
See Also:
Constant Field Values

MMAP_NUM_CHUNKS

private static final int MMAP_NUM_CHUNKS

verbose

public static final boolean verbose
See Also:
Constant Field Values

lock

public static final Lock lock

mapped

private static byte[] mapped
Constructor Detail

Mmapper

public Mmapper()
Method Detail

eagerlyMmapAllSpaces

public static void eagerlyMmapAllSpaces(AddressArray spaceMap)
Given an address array describing the regions of virtual memory to be used by MMTk, demand zero map all of them if they are not already mapped.

Parameters:
spaceMap - An address array containing a pairs of start and end addresses for each of the regions to be mappe3d

markAsMapped

public static void markAsMapped(Address start,
                                int bytes)
Mark a range of pages as having (already) been mapped. This is useful where the VM has performed the mapping of the pages itself.

Parameters:
start - The start of the range to be marked as mapped
bytes - The size of the range, in bytes.

ensureMapped

public static void ensureMapped(Address start,
                                int pages)
Ensure that a range of pages is mmapped (or equivalent). If the pages are not yet mapped, demand-zero map them. Note that mapping occurs at chunk granularity, not page granularity.

NOTE: There is a monotonicity assumption so that only updates require lock acquisition. TODO: Fix the above to support unmapping.

Parameters:
start - The start of the range to be mapped.
pages - The size of the range to be mapped, in pages

protect

public static void protect(Address start,
                           int pages)
Memory protect a range of pages (using mprotect or equivalent). Note that protection occurs at chunk granularity, not page granularity.

Parameters:
start - The start of the range to be protected.
pages - The size of the range to be protected, in pages

addressIsMapped

public static boolean addressIsMapped(Address addr)
Return true if the given address has been mmapped

Parameters:
addr - The address in question.
Returns:
true if the given address has been mmapped

objectIsMapped

public static boolean objectIsMapped(ObjectReference object)
Return true if the given object has been mmapped

Parameters:
object - The object in question.
Returns:
true if the given object has been mmapped

chunkAlignUp

private static Address chunkAlignUp(Address addr)
Return a given address rounded up to an mmap chunk size

Parameters:
addr - The address to be aligned
Returns:
The given address rounded up to an mmap chunk size

chunkAlignDown

private static Address chunkAlignDown(Address addr)
Return a given address rounded down to an mmap chunk size

Parameters:
addr - The address to be aligned
Returns:
The given address rounded down to an mmap chunk size