|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mmtk.policy.Space
public abstract class Space
This class defines and manages spaces. Each policy is an instance of a space. A space is a region of virtual memory (contiguous or discontigous) which is subject to the same memory management regime. Multiple spaces (instances of this class or its descendants) may have the same policy (eg there could be numerous instances of CopySpace, each with different roles). Spaces are defined in terms of a unique region of virtual memory, so no two space instances ever share any virtual memory.
In addition to tracking virtual memory use and the mapping to policy, spaces also manage memory consumption (used virtual memory).
Nested Class Summary | |
---|---|
static interface |
Space.SpaceVisitor
Interface to use to implement the Visitor Pattern for Spaces. |
Field Summary | |
---|---|
static Extent |
AVAILABLE_BYTES
|
static Address |
AVAILABLE_END
|
static int |
AVAILABLE_PAGES
|
static Address |
AVAILABLE_START
|
static int |
BYTES_IN_CHUNK
|
protected boolean |
contiguous
|
private static boolean |
DEBUG
|
protected int |
descriptor
|
protected Extent |
extent
|
private static boolean |
FORCE_SLOW_MAP_LOOKUP
|
protected Address |
headDiscontiguousRegion
|
static Address |
HEAP_END
|
static Address |
HEAP_START
|
private static Address |
heapCursor
|
private static Address |
heapLimit
|
protected boolean |
immortal
|
private int |
index
|
static int |
LOG_ADDRESS_SPACE
|
static int |
LOG_BYTES_IN_CHUNK
|
private static int |
LOG_MAX_CHUNKS
|
static int |
MAX_CHUNKS
|
static int |
MAX_SPACES
|
private static int |
MB
|
private static int |
MB_PAGES
|
protected boolean |
movable
|
private String |
name
|
private int |
nameLength
|
private static int |
PAGES
|
static int |
PAGES_IN_CHUNK
|
private static int |
PAGES_MB
|
protected PageResource |
pr
|
private static int |
spaceCount
|
private static Space[] |
spaces
|
protected Address |
start
|
private VMRequest |
vmRequest
|
protected boolean |
zeroed
|
Constructor Summary | |
---|---|
protected |
Space(String name,
boolean movable,
boolean immortal,
boolean zeroed,
VMRequest vmRequest)
This is the base constructor for all spaces. |
Method Summary | |
---|---|
Address |
acquire(int pages)
Acquire a number of pages from the page resource, returning either the address of the first page, or zero on failure. |
int |
availablePhysicalPages()
AvailablePages getter @return The number of pages available for allocation |
static Address |
chunkAlign(Address addr,
boolean down)
Align an address to a space chunk |
static Extent |
chunkAlign(Extent bytes,
boolean down)
Align an extent to a space chunk |
int |
committedPages()
CommittedPages getter @return The number of committed pages |
static long |
cumulativeCommittedPages()
Cumulative committed pages getter @return Cumulative committed pages. |
static void |
eagerlyMmapMMTkContiguousSpaces()
Ensure that all contiguous MMTk spaces are mapped. |
static void |
eagerlyMmapMMTkDiscontiguousSpaces()
Ensure that all discontiguous MMTk spaces are mapped. |
static void |
eagerlyMmapMMTkSpaces()
Ensure that all MMTk spaces (all spaces aside from the VM space) are mapped. |
int |
getDescriptor()
Descriptor method @return The integer descriptor for this space |
static Address |
getDiscontigEnd()
End of discontig getter @return The end of the discontiguous space |
static Address |
getDiscontigStart()
Start of discontig getter @return The start of the discontiguous space |
Extent |
getExtent()
Extent getter @return The size (extent) of this space |
static Extent |
getFracAvailable(float frac)
Convert a fraction into a number of bytes according to the fraction of available bytes. |
Address |
getHeadDiscontiguousRegion()
|
int |
getIndex()
Index getter @return The index (ordinal number) of this space |
String |
getName()
Name getter @return The name of this space |
private static int |
getPagesReserved()
Get the total number of pages reserved by all of the spaces |
static Space |
getSpaceForAddress(Address addr)
Return the space for a given address, not necessarily the start address of an object. |
static Space |
getSpaceForObject(ObjectReference object)
Return the space for a given object |
Address |
getStart()
Start getter @return The start address of this space |
Address |
growDiscontiguousSpace(int chunks)
Extend the virtual memory associated with a particular discontiguous space. |
void |
growSpace(Address start,
Extent bytes,
boolean newChunk)
This hook is called by page resources each time a space grows. |
boolean |
isImmortal()
Immortal getter @return true if this space is never collected |
static boolean |
isImmortal(ObjectReference object)
Return true if the given object is in an immortal (uncollected) space. |
static boolean |
isInSpace(int descriptor,
Address address)
Return true if the given address is the space associated with the
given descriptor. |
static boolean |
isInSpace(int descriptor,
ObjectReference object)
Return true if the given object is the space associated with the
given descriptor. |
abstract boolean |
isLive(ObjectReference object)
Is the object in this space alive? |
static boolean |
isMappedAddress(Address address)
Return true if the given address is in a space managed by MMTk. |
static boolean |
isMappedObject(ObjectReference object)
Return true if the given object is in a space managed by MMTk. |
boolean |
isMovable()
Movable getter @return true if objects in this space may move |
static boolean |
isMovable(ObjectReference object)
Return true if the given object is in space that moves objects. |
boolean |
isReachable(ObjectReference object)
Has the object in this space been reached during the current collection. |
private static void |
printPages(int pages,
int mode)
Print out the number of pages and or megabytes, depending on the mode. |
private static void |
printUsage(int mode)
Print out the memory used by all spaces in either megabytes or pages. |
static void |
printUsageMB()
Print out the memory used by all spaces, in megabytes |
static void |
printUsagePages()
Print out the memory used by all spaces, in megabytes |
static void |
printVMMap()
Print out a map of virtual memory useage by all spaces |
abstract void |
release(Address start)
Release a unit of allocation (a page or pages) |
void |
releaseAllChunks()
|
int |
releaseDiscontiguousChunks(Address chunk)
Release one or more contiguous chunks associated with a discontiguous space. |
static int |
requiredChunks(int pages)
Return the number of chunks required to satisfy a request for a certain number of pages |
int |
reservedPages()
ReservedPages getter @return The number of reserved pages |
void |
setZeroingApproach(boolean useNT,
boolean concurrent)
Update the zeroing approach for this space. |
void |
skipConcurrentZeroing()
Skip concurrent zeroing (fall back to bulk zeroing). |
abstract ObjectReference |
traceObject(TransitiveClosure trace,
ObjectReference object)
Trace an object as part of a collection and return the object, which may have been forwarded (if a copying collector). |
void |
triggerConcurrentZeroing()
Trigger concurrent zeroing. |
static void |
visitSpaces(Space.SpaceVisitor v)
Implement the Visitor Pattern for Spaces. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static boolean DEBUG
public static final int LOG_ADDRESS_SPACE
public static final int LOG_BYTES_IN_CHUNK
public static final int BYTES_IN_CHUNK
public static final int PAGES_IN_CHUNK
private static final int LOG_MAX_CHUNKS
public static final int MAX_CHUNKS
public static final int MAX_SPACES
public static final Address HEAP_START
public static final Address AVAILABLE_START
public static final Address AVAILABLE_END
public static final Extent AVAILABLE_BYTES
public static final int AVAILABLE_PAGES
public static final Address HEAP_END
private static final boolean FORCE_SLOW_MAP_LOOKUP
private static final int PAGES
private static final int MB
private static final int PAGES_MB
private static final int MB_PAGES
private static int spaceCount
private static Space[] spaces
private static Address heapCursor
private static Address heapLimit
private final String name
private final int nameLength
protected final int descriptor
private final int index
private final VMRequest vmRequest
protected final boolean immortal
protected final boolean movable
protected final boolean contiguous
protected final boolean zeroed
protected PageResource pr
protected final Address start
protected final Extent extent
protected Address headDiscontiguousRegion
Constructor Detail |
---|
protected Space(String name, boolean movable, boolean immortal, boolean zeroed, VMRequest vmRequest)
name
- The name of this space (used when printing error messages etc)movable
- Are objects in this space movable?immortal
- Are objects in this space immortal (uncollected)?zeroed
- if it is true
, allocated memory is zeroed.vmRequest
- An object describing the virtual memory requested.Method Detail |
---|
public static Address getDiscontigStart()
public static Address getDiscontigEnd()
public final String getName()
public final Address getStart()
public final Extent getExtent()
public final int getDescriptor()
public final int getIndex()
public final boolean isImmortal()
true
if this space is never collected
public boolean isMovable()
true
if objects in this space may move
public final int reservedPages()
public final int committedPages()
public final int availablePhysicalPages()
public static long cumulativeCommittedPages()
public static boolean isImmortal(ObjectReference object)
true
if the given object is in an immortal (uncollected) space.
object
- The object in question
true
if the given object is in an immortal (uncollected) space.public static boolean isMovable(ObjectReference object)
true
if the given object is in space that moves objects.
object
- The object in question
true
if the given object is in space that moves objects.public static boolean isMappedObject(ObjectReference object)
true
if the given object is in a space managed by MMTk.
object
- The object in question
true
if the given object is in a space managed by MMTk.public static boolean isMappedAddress(Address address)
true
if the given address is in a space managed by MMTk.
address
- The address in question
true
if the given address is in a space managed by MMTk.public static boolean isInSpace(int descriptor, ObjectReference object)
true
if the given object is the space associated with the
given descriptor.
descriptor
- The descriptor for a spaceobject
- The object in question
true
if the given object is in the space associated with
the descriptor.public static boolean isInSpace(int descriptor, Address address)
true
if the given address is the space associated with the
given descriptor.
descriptor
- The descriptor for a spaceaddress
- The address in question.
true
if the given address is in the space associated with
the descriptor.public static Space getSpaceForObject(ObjectReference object)
object
- The object in question
public static Space getSpaceForAddress(Address addr)
addr
- The address in question
public void setZeroingApproach(boolean useNT, boolean concurrent)
public void skipConcurrentZeroing()
public void triggerConcurrentZeroing()
public final Address acquire(int pages)
This may trigger a GC if necessary.
First the page budget is checked to see whether polling the GC is necessary. If so, the GC is polled. If a GC is required then the request fails and zero is returned.
If the check of the page budget does not lead to GC being triggered, then a request is made for specific pages in virtual memory. If the page manager cannot satisify this request, then the request fails, a GC is forced, and zero is returned. Otherwise the address of the first page is returned.
pages
- The number of pages requested
public Address growDiscontiguousSpace(int chunks)
chunks
- The number of chunks by which the space needs to be extended
public static int requiredChunks(int pages)
pages
- The number of pages desired
public void growSpace(Address start, Extent bytes, boolean newChunk)
start
- The start of the newly allocated spacebytes
- The size of the newly allocated spacenewChunk
- true
if the new space encroached upon or started a new chunk or chunks.public int releaseDiscontiguousChunks(Address chunk)
chunk
- The address of the start of the contiguous chunk or chunks
public Address getHeadDiscontiguousRegion()
public void releaseAllChunks()
public abstract void release(Address start)
start
- The address of the start of the region to be releasedprivate static int getPagesReserved()
public static void printUsageMB()
public static void printUsagePages()
public static void printVMMap()
public static void visitSpaces(Space.SpaceVisitor v)
v
- The visitor to perform on each Space instancepublic static void eagerlyMmapMMTkSpaces()
public static void eagerlyMmapMMTkContiguousSpaces()
public static void eagerlyMmapMMTkDiscontiguousSpaces()
private static void printUsage(int mode)
mode
- An enumeration type that specifies the format for the
prining (PAGES, MB, PAGES_MB, or MB_PAGES).private static void printPages(int pages, int mode)
pages
- The number of pagesmode
- An enumeration type that specifies the format for the
printing (PAGES, MB, PAGES_MB, or MB_PAGES).public abstract ObjectReference traceObject(TransitiveClosure trace, ObjectReference object)
trace
- The trace being conducted.object
- The object to trace
public boolean isReachable(ObjectReference object)
object
- The object reference.
true
if the object is reachable.public abstract boolean isLive(ObjectReference object)
object
- The object reference.
true
if the object is live.public static Address chunkAlign(Address addr, boolean down)
addr
- The address to be aligneddown
- If true
the address will be rounded down, otherwise
it will rounded up.
public static Extent chunkAlign(Extent bytes, boolean down)
bytes
- The extent to be aligneddown
- If true
the extent will be rounded down, otherwise
it will rounded up.
public static Extent getFracAvailable(float frac)
frac
- The fraction of available virtual memory desired
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |