org.mmtk.utility.gcspy.drivers
Class AbstractDriver

java.lang.Object
  extended by org.mmtk.utility.gcspy.drivers.AbstractDriver
Direct Known Subclasses:
LinearSpaceDriver, TreadmillDriver

public abstract class AbstractDriver
extends Object

Abstract GCspy driver for MMTk collectors.

This class implements for the MMTk a base driver for a GCspy space. All drivers for GCspy spaces should inherit from this class.


Field Summary
protected  int blockSize
          The GCspy space's block size
protected  boolean changed
          Has this space changed?
protected  byte[] control
          control values for tiles in this space
protected static byte CONTROL_BACKGROUND
          The tile is a background tile
protected static byte CONTROL_LINK
          The tile is a link
protected static byte CONTROL_SEPARATOR
          The tile is a separator
protected static byte CONTROL_UNUSED
          The tile is unused
protected static byte CONTROL_USED
          The tile is used
private static boolean DEBUG
           
private static int MAX_STREAMS
           
protected  int maxTileNum
          The maximum number of tiles in this GCspy space
protected  Space mmtkSpace
          The MMTK space
protected  String myClass
           
protected  String name
          The name of the GCspy space driver
protected  ServerInterpreter server
          The owning GCspy server
protected  ServerSpace serverSpace
          The GCspy space abstraction
protected  Stream[] streams
          This space's streams
 
Constructor Summary
AbstractDriver(ServerInterpreter server, String name, Space mmtkSpace, int blockSize, boolean mainSpace)
          Create a new driver for this collector.
 
Method Summary
protected  void addControl(int index, byte value)
          Add a control to the tile
 void addStream(Stream stream)
          Add a stream to the driver.
protected static boolean controlIsBackground(byte val)
          Is a tile a background pseudo-tile?
protected static boolean controlIsSeparator(byte val)
          Is this a separator?
protected static boolean controlIsUnused(byte val)
          Is a tile unused?
protected static boolean controlIsUsed(byte val)
          Is a tile used?
protected  void controlValues(byte tag, int start, int len)
          Set the control value in each tile in a region.
protected  int countTileNum(Address start, Address end, int tileSize)
          Count number of tiles in an address range.
protected  int countTileNum(Extent extent, int tileSize)
          Count number of tiles in an address range.
private  int countTileNum(int diff, int tileSize)
           
protected  ServerSpace createServerSpace(ServerInterpreter server, String spaceName, int maxTileNum, boolean mainSpace)
          Create a new GCspy ServerSpace and add it to the ServerInterpreter.
protected  Subspace createSubspace(Space mmtkSpace)
          Create a subspace for this space.
 byte getControl(int index)
          Get the controls for a tile.
protected abstract  String getDriverName()
          Get the name of this driver type.
 int getMaxTileNum()
          Get the maximum number of tiles in this space.
 ServerSpace getServerSpace()
          The GCspy space managed by this driver.
 boolean handleReferenceFromImmortalSpace(Address addr)
          Handle a direct reference from the immortal space.
protected  void initControl(int index, byte value)
          Initialise the value of a control.
protected  void initControls()
          Initialise control values in all tiles
 boolean isConnected(int event)
          Is the server connected to a GCspy client?
 int maxObjectsPerBlock(int blockSize)
          The "typical" maximum number of objects in each tile.
protected  void resetData()
          Reset the statistics for a space.
 void scan(Address obj)
          Scan an object found at a location.
 void scan(Address obj, boolean total)
          Scan an object found at a location.
 void scan(ObjectReference obj)
          Scan an object found at a location.
 void scan(ObjectReference obj, boolean total)
          Scan an object found at a location.
protected  void send(int event, int numTiles)
          Send all the streams for this space if it has changed.
protected  void setControl(int index, byte value)
          Set the control
 void setRange(Address start, Address end)
          Indicate the limits of a space.
 void setRange(Address start, Extent extent)
          Indicate the limits of a space.
protected  void setSpaceInfo(Offset size)
          Set space info.
protected  void setTilenames(Subspace subspace, int numTiles)
          Setup the tile names in a subspace.
abstract  void transmit(int event)
          Transmit the streams for this space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTROL_USED

protected static final byte CONTROL_USED
The tile is used

See Also:
Constant Field Values

CONTROL_BACKGROUND

protected static final byte CONTROL_BACKGROUND
The tile is a background tile

See Also:
Constant Field Values

CONTROL_UNUSED

protected static final byte CONTROL_UNUSED
The tile is unused

See Also:
Constant Field Values

CONTROL_SEPARATOR

protected static final byte CONTROL_SEPARATOR
The tile is a separator

See Also:
Constant Field Values

CONTROL_LINK

protected static final byte CONTROL_LINK
The tile is a link

See Also:
Constant Field Values

MAX_STREAMS

private static final int MAX_STREAMS
See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

myClass

protected String myClass

server

protected final ServerInterpreter server
The owning GCspy server


name

protected final String name
The name of the GCspy space driver


serverSpace

protected final ServerSpace serverSpace
The GCspy space abstraction


mmtkSpace

protected final Space mmtkSpace
The MMTK space


blockSize

protected int blockSize
The GCspy space's block size


maxTileNum

protected int maxTileNum
The maximum number of tiles in this GCspy space


streams

protected Stream[] streams
This space's streams


control

protected byte[] control
control values for tiles in this space


changed

protected boolean changed
Has this space changed?

Constructor Detail

AbstractDriver

public AbstractDriver(ServerInterpreter server,
                      String name,
                      Space mmtkSpace,
                      int blockSize,
                      boolean mainSpace)
Create a new driver for this collector.

Parameters:
server - The ServerInterpreter that owns this GCspy space.
name - The name of this driver.
mmtkSpace - The MMTk space represented by this driver.
blockSize - The tile size.
mainSpace - Is this the main space?
Method Detail

createSubspace

protected Subspace createSubspace(Space mmtkSpace)
Create a subspace for this space. Subspace provide useful facilities for contiguous spaces, even if a space contains only one.

Parameters:
mmtkSpace - The MMTk space

createServerSpace

protected ServerSpace createServerSpace(ServerInterpreter server,
                                        String spaceName,
                                        int maxTileNum,
                                        boolean mainSpace)
Create a new GCspy ServerSpace and add it to the ServerInterpreter.

Parameters:
server - the GCspy ServerInterpreter.
spaceName - The name of this driver.
maxTileNum - the maximum number of tiles in this space.
mainSpace - Is this the main space?

getDriverName

protected abstract String getDriverName()
Get the name of this driver type.

Returns:
The name of this driver.

getMaxTileNum

public int getMaxTileNum()
Get the maximum number of tiles in this space.

Returns:
the maximum number of tiles in the space.

getServerSpace

public ServerSpace getServerSpace()
The GCspy space managed by this driver.

Returns:
the GCspy server space.

addStream

public void addStream(Stream stream)
Add a stream to the driver. This also sets the stream's id (unique for this space).

Parameters:
stream - The stream
Throws:
IndexOutOfBoundsException - if more than MAX_STREAMS are added

countTileNum

protected int countTileNum(Address start,
                           Address end,
                           int tileSize)
Count number of tiles in an address range.

Parameters:
start - The start of the range.
end - The end of the range.
tileSize - The size of each tile.
Returns:
The number of tiles in this range.

countTileNum

protected int countTileNum(Extent extent,
                           int tileSize)
Count number of tiles in an address range.

Parameters:
extent - The extent of the range.
tileSize - The size of each tile.
Returns:
The number of tiles in this range.

countTileNum

private int countTileNum(int diff,
                         int tileSize)

setRange

public void setRange(Address start,
                     Address end)
Indicate the limits of a space.

Parameters:
start - the Address of the start of the space.
end - the Address of the end of the space.

setRange

public void setRange(Address start,
                     Extent extent)
Indicate the limits of a space.

Parameters:
start - the Address of the start of the space.
extent - the extent of the space.

setTilenames

protected void setTilenames(Subspace subspace,
                            int numTiles)
Setup the tile names in a subspace. Tile names are typically address ranges but may be anything (e.g. a size class if the space is a segregated free-list manager, or a class name if the space represents the class instances loaded).

Parameters:
subspace - the Subspace
numTiles - the number of tiles to name

maxObjectsPerBlock

public int maxObjectsPerBlock(int blockSize)
The "typical" maximum number of objects in each tile.

Parameters:
blockSize - The size of a tile
Returns:
The maximum number of objects in a tile

isConnected

public boolean isConnected(int event)
Is the server connected to a GCspy client?

Parameters:
event - The current event

resetData

protected void resetData()
Reset the statistics for a space. In this base driver, we simply note that the data has changed.


scan

public void scan(ObjectReference obj,
                 boolean total)
Scan an object found at a location. Collectors typically call this method to update GCspy statistics. The driver may or may not accumulate values found, depending on the value of total.

Parameters:
obj - the reference to the object found
total - Whether to total the statistics

scan

public void scan(ObjectReference obj)
Scan an object found at a location. Collectors typically call this method to update GCspy statistics The driver will accumulate values found.

Parameters:
obj - the reference to the object found

scan

public void scan(Address obj,
                 boolean total)
Scan an object found at a location. Collectors typically call this method to update GCspy statistics. The driver may or may not accumulate values found, depending on the value of total.

Parameters:
obj - the reference to the object found
total - Whether to total the statistics

scan

public void scan(Address obj)
Scan an object found at a location. Collectors typically call this method to update GCspy statistics The driver will accumulate values found.

Parameters:
obj - the reference to the object found

handleReferenceFromImmortalSpace

public boolean handleReferenceFromImmortalSpace(Address addr)
Handle a direct reference from the immortal space.

This is an empty implementation. Subclasses may override this method to increment their refFromImmortal Stream.

Parameters:
addr - The Address
Returns:
true if the given Address is in this subspace. Always false here.

setSpaceInfo

protected void setSpaceInfo(Offset size)
Set space info. This simply reports the size of the current space. Drivers that want to send something more complex than "Current Size: size\n" must override this method.

Parameters:
size - the size of the space

controlIsUsed

protected static boolean controlIsUsed(byte val)
Is a tile used?

Parameters:
val - the control value.
Returns:
true if the tile is used

controlIsBackground

protected static boolean controlIsBackground(byte val)
Is a tile a background pseudo-tile?

Parameters:
val - the control value.
Returns:
true if the tile is a background tile

controlIsUnused

protected static boolean controlIsUnused(byte val)
Is a tile unused?

Parameters:
val - the control value.
Returns:
true if the tile is unused

controlIsSeparator

protected static boolean controlIsSeparator(byte val)
Is this a separator?

Parameters:
val - the control value.
Returns:
true if this is a separator

initControl

protected void initControl(int index,
                           byte value)
Initialise the value of a control.

Parameters:
index - The index of the tile.
value - The new value of the control

addControl

protected void addControl(int index,
                          byte value)
Add a control to the tile

Parameters:
index - The index of the tile.
value - The control to add.

setControl

protected void setControl(int index,
                          byte value)
Set the control

Parameters:
value - The value to set

getControl

public byte getControl(int index)
Get the controls for a tile.

Parameters:
index - The index of the tile.
Returns:
The value of the controls

initControls

protected void initControls()
Initialise control values in all tiles


controlValues

protected void controlValues(byte tag,
                             int start,
                             int len)
Set the control value in each tile in a region.

Parameters:
tag - The control tag.
start - The start index of the region.
len - The number of tiles in the region.

transmit

public abstract void transmit(int event)
Transmit the streams for this space. A driver will typically
  1. Determine whether a GCspy client is connected and interested in this event, e.g.
    server.isConnected(event)
  2. Setup the summaries for each stream, e.g.
    stream.setSummary(values...);
  3. Setup the control information for each tile. e.g.
    controlValues(CONTROL_USED, start, numBlocks);
    controlValues(CONTROL_UNUSED, end, remainingBlocks);
  4. Set up the space information, e.g.
    setSpace(info);
  5. Send the data for all streams, e.g.
    send(event, numTiles);
    Note that AbstractDriver.send takes care of sending the information for all streams (including control data).

    Parameters:
    event - The event

send

protected void send(int event,
                    int numTiles)
Send all the streams for this space if it has changed. Assume that the data has been gathered and that summary info and control values have been set before this is called.

Parameters:
event - the event
numTiles - the number of blocks in this space