org.jikesrvm.mm.mmtk
Class Memory

java.lang.Object
  extended by org.mmtk.vm.Memory
      extended by org.jikesrvm.mm.mmtk.Memory
All Implemented Interfaces:
HeapLayoutConstants, SizeConstants, Constants

public class Memory
extends Memory
implements Constants, HeapLayoutConstants, SizeConstants


Field Summary
private static int BOOT_SEGMENT_MB
           
private static ImmortalSpace bootSpace
           
 
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
 
Fields inherited from interface org.jikesrvm.HeapLayoutConstants
BAD_MAP_COMPRESSION, BOOT_IMAGE_CODE_END, BOOT_IMAGE_CODE_SIZE, BOOT_IMAGE_CODE_START, BOOT_IMAGE_DATA_END, BOOT_IMAGE_DATA_SIZE, BOOT_IMAGE_DATA_START, BOOT_IMAGE_END, BOOT_IMAGE_RMAP_END, BOOT_IMAGE_RMAP_START, MAX_BOOT_IMAGE_RMAP_SIZE, MAXIMUM_MAPPABLE
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_ADDRESS, BITS_IN_BOOLEAN, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_INT, BITS_IN_LONG, BITS_IN_OFFSET, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_INT, BYTES_IN_LONG, BYTES_IN_OFFSET, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_INT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_INT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD
 
Constructor Summary
Memory()
           
 
Method Summary
 void collectorPrepareVMSpace()
          Per-collector preparation for a collection.
 void collectorReleaseVMSpace()
          Per-collector post-collection work.
 void dumpMemory(Address start, int beforeBytes, int afterBytes)
          Logs the contents of an address and the surrounding memory to the error output.
 int dzmmap(Address start, int size)
          Demand zero mmaps an area of virtual memory.
protected  int getAlignmentValueConstant()
           
protected  Address getAvailableEndConstant()
           
protected  Address getAvailableStartConstant()
           
protected  Address getHeapEndConstant()
           
protected  Address getHeapStartConstant()
           
protected  byte getLogBytesInAddressConstant()
           
protected  byte getLogBytesInPageConstant()
           
protected  byte getLogBytesInWordConstant()
           
protected  byte getLogMinAlignmentConstant()
           
protected  byte getMaxAlignmentShiftConstant()
          On Intel we align code to 16 bytes as recommended in the optimization manual.
protected  int getMaxBytesPaddingConstant()
           
 ImmortalSpace getVMSpace()
          Return the space associated with/reserved for the VM.
 void globalPrepareVMSpace()
          Global preparation for a collection.
 void globalReleaseVMSpace()
          Global post-collection work.
 void isync()
          Wait for all preceeding instructions to complete and discard any prefetched instructions on this processor.
 boolean mprotect(Address start, int size)
          Protects access to an area of virtual memory.
 boolean munprotect(Address start, int size)
          Allows access to an area of virtual memory.
 void setHeapRange(int id, Address start, Address end)
          Sets the range of addresses associated with a heap.
 void sync()
          Wait for preceeding cache flush/invalidate instructions to complete on all processors.
 void zero(boolean useNT, Address start, Extent len)
          Zero a region of memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bootSpace

private static ImmortalSpace bootSpace

BOOT_SEGMENT_MB

private static int BOOT_SEGMENT_MB
Constructor Detail

Memory

public Memory()
Method Detail

getHeapStartConstant

protected final Address getHeapStartConstant()
Specified by:
getHeapStartConstant in class Memory
Returns:
The lowest address in the virtual address space known to MMTk

getHeapEndConstant

protected final Address getHeapEndConstant()
Specified by:
getHeapEndConstant in class Memory
Returns:
The highest address in the virtual address space known to MMTk

getAvailableStartConstant

protected final Address getAvailableStartConstant()
Specified by:
getAvailableStartConstant in class Memory
Returns:
The lowest address in the contiguous address space available to MMTk

getAvailableEndConstant

protected final Address getAvailableEndConstant()
Specified by:
getAvailableEndConstant in class Memory
Returns:
The highest address in the contiguous address space available to MMTk

getLogBytesInAddressConstant

protected final byte getLogBytesInAddressConstant()
Specified by:
getLogBytesInAddressConstant in class Memory
Returns:
The log base two of the size of an address

getLogBytesInWordConstant

protected final byte getLogBytesInWordConstant()
Specified by:
getLogBytesInWordConstant in class Memory
Returns:
The log base two of the size of a word

getLogBytesInPageConstant

protected final byte getLogBytesInPageConstant()
Specified by:
getLogBytesInPageConstant in class Memory
Returns:
The log base two of the size of an OS page

getLogMinAlignmentConstant

protected final byte getLogMinAlignmentConstant()
Specified by:
getLogMinAlignmentConstant in class Memory
Returns:
The log base two of the minimum allocation alignment

getMaxBytesPaddingConstant

protected final int getMaxBytesPaddingConstant()
Specified by:
getMaxBytesPaddingConstant in class Memory
Returns:
The maximum number of bytes of padding to prepend to an object

getAlignmentValueConstant

protected final int getAlignmentValueConstant()
Specified by:
getAlignmentValueConstant in class Memory
Returns:
The value to store in alignment holes

getMaxAlignmentShiftConstant

protected final byte getMaxAlignmentShiftConstant()
On Intel we align code to 16 bytes as recommended in the optimization manual.

Specified by:
getMaxAlignmentShiftConstant in class Memory
Returns:
The log base two of (MAX_ALIGNMENT/MIN_ALIGNMENT)

getVMSpace

public final ImmortalSpace getVMSpace()
Return the space associated with/reserved for the VM. In the case of Jikes RVM this is the boot image space.

The boot image space must be mapped at the start of available virtual memory, hence we use the constructor that requests the lowest address in the address space. The address space awarded to this space depends on the order in which the request is made. If this request is not the first request for virtual memory then the Space allocator will die with an error stating that the request could not be satisfied. The remedy is to ensure it is initialized first.

Specified by:
getVMSpace in class Memory
Returns:
The space managed by the virtual machine. In this case, the boot image space is returned.

globalPrepareVMSpace

public final void globalPrepareVMSpace()
Description copied from class: Memory
Global preparation for a collection.

Specified by:
globalPrepareVMSpace in class Memory

collectorPrepareVMSpace

public final void collectorPrepareVMSpace()
Description copied from class: Memory
Per-collector preparation for a collection.

Specified by:
collectorPrepareVMSpace in class Memory

collectorReleaseVMSpace

public final void collectorReleaseVMSpace()
Description copied from class: Memory
Per-collector post-collection work.

Specified by:
collectorReleaseVMSpace in class Memory

globalReleaseVMSpace

public final void globalReleaseVMSpace()
Description copied from class: Memory
Global post-collection work.

Specified by:
globalReleaseVMSpace in class Memory

setHeapRange

public final void setHeapRange(int id,
                               Address start,
                               Address end)
Description copied from class: Memory
Sets the range of addresses associated with a heap.

Specified by:
setHeapRange in class Memory
Parameters:
id - the heap identifier
start - the address of the start of the heap
end - the address of the end of the heap

dzmmap

public final int dzmmap(Address start,
                        int size)
Description copied from class: Memory
Demand zero mmaps an area of virtual memory.

Specified by:
dzmmap in class Memory
Parameters:
start - the address of the start of the area to be mapped
size - the size, in bytes, of the area to be mapped
Returns:
0 if successful, otherwise the system errno

mprotect

public final boolean mprotect(Address start,
                              int size)
Description copied from class: Memory
Protects access to an area of virtual memory.

Specified by:
mprotect in class Memory
Parameters:
start - the address of the start of the area to be mapped
size - the size, in bytes, of the area to be mapped
Returns:
true if successful, otherwise false

munprotect

public final boolean munprotect(Address start,
                                int size)
Description copied from class: Memory
Allows access to an area of virtual memory.

Specified by:
munprotect in class Memory
Parameters:
start - the address of the start of the area to be mapped
size - the size, in bytes, of the area to be mapped
Returns:
true if successful, otherwise false

zero

public final void zero(boolean useNT,
                       Address start,
                       Extent len)
Description copied from class: Memory
Zero a region of memory.

Specified by:
zero in class Memory
Parameters:
useNT - Use non temporal instructions (if available)
start - Start of address range (inclusive)
len - Length in bytes of range to zero

dumpMemory

public final void dumpMemory(Address start,
                             int beforeBytes,
                             int afterBytes)
Description copied from class: Memory
Logs the contents of an address and the surrounding memory to the error output.

Specified by:
dumpMemory in class Memory
Parameters:
start - the address of the memory to be dumped
beforeBytes - the number of bytes before the address to be included
afterBytes - the number of bytes after the address to be included

sync

public final void sync()
Description copied from class: Memory
Wait for preceeding cache flush/invalidate instructions to complete on all processors. Ensures that all memory writes before this point are visible to all processors.

Specified by:
sync in class Memory

isync

public final void isync()
Description copied from class: Memory
Wait for all preceeding instructions to complete and discard any prefetched instructions on this processor. Also prevents the compiler from performing code motion across this point.

Specified by:
isync in class Memory