org.mmtk.utility
Class Memory

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

public class Memory
extends Object
implements Constants

This class implements basic memory copying, setting and clearing operations.

NOTE: Most of the operations in this class are performed at the granularity of a Java integer (ie 4-byte units)

FIXME: Why can't these operations be performed at word-granularity?


Field Summary
private static int SMALL_REGION_THRESHOLD
          zero operations greater than this size are done using the underlying OS implementation of zero()
 
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
Memory()
           
 
Method Summary
private static void assertAligned(Address value)
           
private static void assertAligned(Extent value)
           
private static void assertAligned(int value)
          Assert appropriate alignment, triggering an assertion failure if the value does not satisfy the alignment requirement of the memory operations.
private static void assertAligned(Word value)
           
static void assertIsZeroed(Address start, int bytes)
          Assert that a memory range is zeroed.
static void dumpMemory(Address addr, int beforeBytes, int afterBytes)
          Dump the contents of memory around a given address
private static boolean isSet(Address start, int bytes, boolean verbose, int value)
          Test whether a memory range is set to a given integer value
static boolean isSet(Address start, int bytes, int value)
          Verbosely check and return true if a memory range is set to some integer value
static boolean IsZeroed(Address start, int bytes)
          Check that a memory range is zeroed
static void set(Address start, int bytes, int value)
          Set a region of memory
static void zero(Address start, Extent bytes)
          Zero a region of memory
static void zeroSmall(Address start, Extent bytes)
          Zero a small region of memory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SMALL_REGION_THRESHOLD

private static final int SMALL_REGION_THRESHOLD
zero operations greater than this size are done using the underlying OS implementation of zero()

See Also:
Constant Field Values
Constructor Detail

Memory

public Memory()
Method Detail

zero

public static void zero(Address start,
                        Extent bytes)
Zero a region of memory

Parameters:
start - The start of the region to be zeroed (must be 4-byte aligned)
bytes - The number of bytes to be zeroed (must be 4-byte aligned)

zeroSmall

public static void zeroSmall(Address start,
                             Extent bytes)
Zero a small region of memory

Parameters:
start - The start of the region to be zeroed (must be 4-byte aligned)
bytes - The number of bytes to be zeroed (must be 4-byte aligned)

set

public static void set(Address start,
                       int bytes,
                       int value)
Set a region of memory

Parameters:
start - The start of the region to be zeroed (must be 4-byte aligned)
bytes - The number of bytes to be zeroed (must be 4-byte aligned)
value - The value to which the integers in the region should be set

IsZeroed

public static boolean IsZeroed(Address start,
                               int bytes)
Check that a memory range is zeroed

Parameters:
start - The start address of the range to be checked
bytes - The size of the region to be checked, in bytes
Returns:
true if the region is zeroed

assertIsZeroed

public static void assertIsZeroed(Address start,
                                  int bytes)
Assert that a memory range is zeroed. An assertion failure will occur if the region is not zeroed.

this is in the inline allocation sequence when VM.VERIFY_ASSERTIONS is true, it is carefully written to reduce the impact on code space.

Parameters:
start - The start address of the range to be checked
bytes - The size of the region to be checked, in bytes

isSet

public static boolean isSet(Address start,
                            int bytes,
                            int value)
Verbosely check and return true if a memory range is set to some integer value

Parameters:
start - The start address of the range to be checked
bytes - The size of the region to be checked, in bytes
value - The value to which this region should be set
Returns:
true if the region has been correctly set

assertAligned

private static void assertAligned(int value)
Assert appropriate alignment, triggering an assertion failure if the value does not satisfy the alignment requirement of the memory operations.

Parameters:
value - The value to be tested

assertAligned

private static void assertAligned(Word value)

assertAligned

private static void assertAligned(Extent value)

assertAligned

private static void assertAligned(Address value)

isSet

private static boolean isSet(Address start,
                             int bytes,
                             boolean verbose,
                             int value)
Test whether a memory range is set to a given integer value

Parameters:
start - The address to start checking at
bytes - The size of the region to check, in bytes
verbose - If true, produce verbose output
value - The value to which the memory should be set

dumpMemory

public static void dumpMemory(Address addr,
                              int beforeBytes,
                              int afterBytes)
Dump the contents of memory around a given address

Parameters:
addr - The address around which the memory should be dumped
beforeBytes - The number of bytes before the address to be included in the dump
afterBytes - The number of bytes after the address to be included in the dump