org.mmtk.utility.gcspy
Class Subspace

java.lang.Object
  extended by org.mmtk.utility.gcspy.Subspace

public class Subspace
extends Object

This class is an abstraction of a contiguous region of a Space. For example, a semispace collector might choose to model the heap as a single Space, but within that Space it could model each semispace by a Subspace.

Subspace provides a number of useful facilities to many drivers, and is useful even if the Space comprises just a single contiguous region.

A subspace keeps track of the start and end address of the region, the index of its first block, the size of the blocks in this space, and the number of blocks in this subspace.


Field Summary
private  int blockNum_
          the number of blocks in this space
private  int blockSize_
          the block size
private static boolean DEBUG
           
private  Address end_
          end address of the subspace.
private  int firstIndex_
          The index of the block in which start_ lies
private  Address start_
          start address of the subspace.
 
Constructor Summary
Subspace(Address start, Address end, int firstIndex, int blockSize, int blockNum)
          Create a new subspace
 
Method Summary
 boolean addressInRange(Address addr)
          Is address in the range of this subspace?
private  void dump()
          Dump a representation of the subspace
 Address getAddress(int index)
          Get the address of start of block from its index
 int getBlockNum()
          Get the number of tiles in this subspace
 int getBlockSize()
          Get the blocksize for this subspace
 Address getEnd()
          Get the end of this subspace
 int getFirstIndex()
          Get the first index of subspace
 int getIndex(Address addr)
          Get the block index from an address
 Address getStart()
          Get the start of the subspace
 boolean indexInRange(int index)
          Is an index in the range of this subspace?
 void reset(Address start, Address end, int blockNum)
          Reset a new subspace.
 void reset(Address start, Address end, int firstIndex, int blockNum)
          Reset a new subspace
private  void reset(Address start, Address end, int firstIndex, int blockSize, int blockNum)
          Reset a subspace.
 void reset(int firstIndex, int blockNum)
          Reset a new subspace.
 int spaceRemaining(Address addr)
          Calculate the space remaining in a block after this address
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start_

private Address start_
start address of the subspace. A subspace spans the address range [start_, end_)


end_

private Address end_
end address of the subspace. A subspace spans the address range [start_, end_)


firstIndex_

private int firstIndex_
The index of the block in which start_ lies


blockSize_

private int blockSize_
the block size


blockNum_

private int blockNum_
the number of blocks in this space


DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values
Constructor Detail

Subspace

public Subspace(Address start,
                Address end,
                int firstIndex,
                int blockSize,
                int blockNum)
Create a new subspace

Parameters:
start - The address of the start of the subspace
end - The address of the end of the subspace
firstIndex - The index of the first block of the subspace
blockSize - The size of blocks in this space
blockNum - The number of blocks in this subspace
Method Detail

reset

private void reset(Address start,
                   Address end,
                   int firstIndex,
                   int blockSize,
                   int blockNum)
Reset a subspace.

Parameters:
start - The address of the start of the subspace
end - The address of the end of the subspace
firstIndex - The index of the first block of the subspace
blockSize - The size of blocks in this subspace
blockNum - The number of blocks in this subspace

reset

public void reset(Address start,
                  Address end,
                  int firstIndex,
                  int blockNum)
Reset a new subspace

Parameters:
start - The address of the start of the subspace
end - The address of the end of the subspace
firstIndex - The index of the first block of the subspace
blockNum - The number of blocks in this subspace

reset

public void reset(Address start,
                  Address end,
                  int blockNum)
Reset a new subspace.

Parameters:
start - The address of the start of the subspace
end - The address of the end of the subspace
blockNum - The number of blocks in this subspace

reset

public void reset(int firstIndex,
                  int blockNum)
Reset a new subspace.

Parameters:
firstIndex - The index of the first block of the subspace
blockNum - The number of blocks in this subspace

indexInRange

public boolean indexInRange(int index)
Is an index in the range of this subspace?

Parameters:
index - The index of the block
Returns:
true if this block lies in this subspace

addressInRange

public boolean addressInRange(Address addr)
Is address in the range of this subspace?

Parameters:
addr - An address
Returns:
true if this address is in a block in this subspace

getIndex

public int getIndex(Address addr)
Get the block index from an address

Parameters:
addr - The address
Returns:
The index of the block holding this address

getAddress

public Address getAddress(int index)
Get the address of start of block from its index

Parameters:
index - The index of the block
Returns:
The address of the start of the block

getStart

public Address getStart()
Get the start of the subspace

Returns:
The start of this subspace

getEnd

public Address getEnd()
Get the end of this subspace

Returns:
The address of the end of this subspace

getFirstIndex

public int getFirstIndex()
Get the first index of subspace

Returns:
the firstIndex of this subspace

getBlockSize

public int getBlockSize()
Get the blocksize for this subspace

Returns:
The size of a tile

getBlockNum

public int getBlockNum()
Get the number of tiles in this subspace

Returns:
The number of tiles in this subspace

spaceRemaining

public int spaceRemaining(Address addr)
Calculate the space remaining in a block after this address

Parameters:
addr - the Address
Returns:
the remainder

dump

private void dump()
Dump a representation of the subspace