org.mmtk.utility
Class Treadmill

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

public final class Treadmill
extends Object
implements Constants

FIXME The DoublyLinkedList class, upon which this depends, must be re-written as it makes the assumption that the implementation language (Java) and the language being implemented are the same. This is true in the case of Jikes RVM, but it is not true for any VM implementing a language other than Java.

Each instance of this class is a doubly-linked list, in which each item or node is a piece of memory. The first two words of each node contains the forward and backward links. The third word contains the treadmill. The remaining portion is the payload.

The treadmill object itself must not be moved.

Access to the instances may be synchronized depending on the constructor argument.


Field Summary
private  DoublyLinkedList allocNursery
           
private  DoublyLinkedList collectNursery
           
private  DoublyLinkedList fromSpace
           
private  DoublyLinkedList toSpace
           
 
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
Treadmill(int granularity, boolean shared)
           
 
Method Summary
 void addToTreadmill(Address node, boolean nursery)
          Add a node to the treadmill.
 void copy(Address node, boolean isInNursery)
          Copy a node (during gc tracing).
 void flip(boolean fullHeap)
          Flip the roles of the spaces in preparation for a collection.
 boolean fromSpaceEmpty()
          Is the from-space empty?
 void gcspyGatherData(int event, TreadmillDriver tmDriver)
          Gather data for GCSpy from the nursery
 void gcspyGatherData(int event, TreadmillDriver tmDriver, boolean tospace)
          Gather data for GCSpy
static int headerSize()
           
static Address midPayloadToNode(Address payload)
           
static Address nodeToPayload(Address payload)
           
 boolean nurseryEmpty()
          Is the nursery empty?
 Address pop()
          Remove a node from the mature list.
 Address popNursery()
          Remove a node from the nursery list.
 boolean toSpaceEmpty()
          Is the to-space empty?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fromSpace

private DoublyLinkedList fromSpace

toSpace

private DoublyLinkedList toSpace

collectNursery

private DoublyLinkedList collectNursery

allocNursery

private DoublyLinkedList allocNursery
Constructor Detail

Treadmill

public Treadmill(int granularity,
                 boolean shared)
Parameters:
granularity -
shared - true if the created instance will be shared between threads. If it is shared, accesses will be synchronized using locks.
Method Detail

addToTreadmill

public void addToTreadmill(Address node,
                           boolean nursery)
Add a node to the treadmill. This is usually performed on allocation.


popNursery

public Address popNursery()
Remove a node from the nursery list.


pop

public Address pop()
Remove a node from the mature list.


copy

public void copy(Address node,
                 boolean isInNursery)
Copy a node (during gc tracing).


toSpaceEmpty

public boolean toSpaceEmpty()
Is the to-space empty?


fromSpaceEmpty

public boolean fromSpaceEmpty()
Is the from-space empty?


nurseryEmpty

public boolean nurseryEmpty()
Is the nursery empty?


flip

public void flip(boolean fullHeap)
Flip the roles of the spaces in preparation for a collection.


headerSize

public static int headerSize()

nodeToPayload

public static Address nodeToPayload(Address payload)

midPayloadToNode

public static Address midPayloadToNode(Address payload)

gcspyGatherData

public void gcspyGatherData(int event,
                            TreadmillDriver tmDriver)
Gather data for GCSpy from the nursery

Parameters:
event - the gc event
tmDriver - the GCSpy space driver

gcspyGatherData

public void gcspyGatherData(int event,
                            TreadmillDriver tmDriver,
                            boolean tospace)
Gather data for GCSpy

Parameters:
event - the gc event
tmDriver - the GCSpy space driver
tospace - gather from tospace?