public final class Treadmill extends Object
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.
Modifier and Type | Field and Description |
---|---|
private DoublyLinkedList |
allocNursery |
private DoublyLinkedList |
collectNursery |
private DoublyLinkedList |
fromSpace |
private DoublyLinkedList |
toSpace |
Constructor and Description |
---|
Treadmill(int granularity,
boolean shared) |
Modifier and Type | Method and Description |
---|---|
void |
addToTreadmill(Address node,
boolean nursery)
Adds a node to the treadmill.
|
void |
copy(Address node,
boolean isInNursery)
Copies a node (during gc tracing).
|
void |
flip(boolean fullHeap)
Flips the roles of the spaces in preparation for a collection.
|
boolean |
fromSpaceEmpty() |
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() |
Address |
pop()
Removes a node from the mature list.
|
Address |
popNursery()
Removes a node from the nursery list.
|
boolean |
toSpaceEmpty() |
private DoublyLinkedList fromSpace
private DoublyLinkedList toSpace
private DoublyLinkedList collectNursery
private DoublyLinkedList allocNursery
public Treadmill(int granularity, boolean shared)
granularity
- TODO needs documentationshared
- true
if the created instance will be shared between threads. If it is shared, accesses will be synchronized using locks.public void addToTreadmill(Address node, boolean nursery)
node
- the node to addnursery
- whether to add to the nursery or to the to-spacepublic Address popNursery()
public void copy(Address node, boolean isInNursery)
node
- the node to copyisInNursery
- whether the node is in the nursery or the
from-spacepublic boolean toSpaceEmpty()
public boolean fromSpaceEmpty()
public boolean nurseryEmpty()
public void flip(boolean fullHeap)
fullHeap
- whether the collection is full heappublic static int headerSize()
public static Address nodeToPayload(Address payload)
public static Address midPayloadToNode(Address payload)
public void gcspyGatherData(int event, TreadmillDriver tmDriver)
event
- the gc eventtmDriver
- the GCSpy space driverpublic void gcspyGatherData(int event, TreadmillDriver tmDriver, boolean tospace)
event
- the gc eventtmDriver
- the GCSpy space drivertospace
- gather from tospace?