org.mmtk.policy
Class MarkCompactCollector.RegionCursor

java.lang.Object
  extended by org.mmtk.policy.MarkCompactCollector.RegionCursor
Direct Known Subclasses:
MarkCompactCollector.FromCursor, MarkCompactCollector.ToCursor
Enclosing class:
MarkCompactCollector

private abstract static class MarkCompactCollector.RegionCursor
extends Object

Both the 'compact' and 'calculate' phases can be thought of as sweeping a pair of cursors across a linked list of regions. Each cursor requires maintaining pointers to the current region, the current address and the end of the region. The regionCursor class maintains these 3 pointers, while the subclasses ToCursor and FromCursor provide methods specific to the read and write pointers.


Field Summary
protected  Address cursor
          The current address
protected  Address limit
          The limit of the current region.
private  String name
          Name of the cursor - for debugging messages
protected  Address region
          The current region, or zero if the cursor is invalid (eg after advancing past the end of the current work list
 
Constructor Summary
MarkCompactCollector.RegionCursor(String name)
           
 
Method Summary
(package private)  void advanceToNextRegion()
          Follow the linked-list of regions to the next region.
protected  void assertCursorInBounds()
          Assert that the cursor is within the bounds of the region.
 Address get()
           
 Address getLimit()
           
 Address getRegion()
           
(package private)  void inc(int size)
          Increment the cursor.
 void incTo(Address cursor)
          Increment the cursor to a specific address
(package private) abstract  void init(Address region)
          Hook to allow subclasses to initialize the cursor in different ways.
(package private)  boolean isAvailable(int size)
           
(package private)  boolean isInRegion(ObjectReference ref)
           
(package private)  boolean isValid()
           
(package private)  void print()
          Print the cursor - for debugging
(package private)  boolean sameRegion(MarkCompactCollector.RegionCursor other)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private final String name
Name of the cursor - for debugging messages


region

protected Address region
The current region, or zero if the cursor is invalid (eg after advancing past the end of the current work list


limit

protected Address limit
The limit of the current region. When reading a populated region, this is the address of the last used byte. When writing to a fresh region, this is the last byte in the region.


cursor

protected Address cursor
The current address

Constructor Detail

MarkCompactCollector.RegionCursor

public MarkCompactCollector.RegionCursor(String name)
Parameters:
name - The name of the region - for debugging messages.
Method Detail

init

abstract void init(Address region)
Hook to allow subclasses to initialize the cursor in different ways.

Parameters:
region - The region to be processed.

assertCursorInBounds

protected void assertCursorInBounds()
Assert that the cursor is within the bounds of the region. Calls to this must be guarded by if (VM.VERIFY_ASSERTIONS)


inc

void inc(int size)
Increment the cursor.

Parameters:
size - Bytes to increment by

incTo

public void incTo(Address cursor)
Increment the cursor to a specific address

Parameters:
cursor - Destination address

sameRegion

boolean sameRegion(MarkCompactCollector.RegionCursor other)
Parameters:
other - Other region
Returns:
true if this cursor points to the same region as other

isAvailable

boolean isAvailable(int size)
Parameters:
size - Size in bytes
Returns:
true if size bytes are available in the current region

get

public Address get()
Returns:
The current cursor

getRegion

public Address getRegion()
Returns:
The current region pointer

getLimit

public Address getLimit()
Returns:
The current region limit

advanceToNextRegion

void advanceToNextRegion()
Follow the linked-list of regions to the next region.


isValid

boolean isValid()
Returns:
true if we haven't advanced beyond the end of the region list

isInRegion

boolean isInRegion(ObjectReference ref)
Parameters:
ref - The object in question
Returns:
true if the object's start address is in this region

print

void print()
Print the cursor - for debugging