public abstract class Space extends Object
In addition to tracking virtual memory use and the mapping to policy, spaces also manage memory consumption (used virtual memory).
Modifier and Type | Class and Description |
---|---|
static interface |
Space.SpaceVisitor
Interface to use to implement the Visitor Pattern for Spaces.
|
Modifier and Type | Field and Description |
---|---|
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 |
Modifier | Constructor and Description |
---|---|
protected |
Space(String name,
boolean movable,
boolean immortal,
boolean zeroed,
VMRequest vmRequest)
This is the base constructor for all spaces.
|
Modifier and Type | Method and Description |
---|---|
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() |
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() |
static long |
cumulativeCommittedPages() |
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() |
static Address |
getDiscontigEnd() |
static Address |
getDiscontigStart() |
Extent |
getExtent() |
static Extent |
getFracAvailable(float frac)
Convert a fraction into a number of bytes according to the
fraction of available bytes.
|
Address |
getHeadDiscontiguousRegion() |
int |
getIndex() |
String |
getName() |
private static int |
getPagesReserved()
Get the total number of pages reserved by all of the spaces
|
static int |
getSpaceCount() |
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
|
static Space[] |
getSpaces() |
Address |
getStart() |
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() |
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() |
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() |
void |
setZeroingApproach(boolean useNT,
boolean concurrent)
Updates 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.
|
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
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 Address heapCursor
private final int nameLength
protected final int descriptor
private final int index
protected final boolean immortal
protected final boolean movable
protected final boolean contiguous
protected final boolean zeroed
protected PageResource pr
protected Address headDiscontiguousRegion
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.public static Address getDiscontigStart()
public static Address getDiscontigEnd()
public final int getDescriptor()
public final int getIndex()
public final boolean isImmortal()
true
if this space is never collectedpublic boolean isMovable()
true
if objects in this space may movepublic 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 questiontrue
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 questiontrue
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 questiontrue
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 questiontrue
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 questiontrue
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 questionpublic static Space getSpaceForAddress(Address addr)
addr
- The address in questionpublic void setZeroingApproach(boolean useNT, boolean concurrent)
useNT
- whether to use non-temporal instructions for zeroingconcurrent
- whether zeroing will be done concurrentlypublic 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 requestedpublic Address growDiscontiguousSpace(int chunks)
chunks
- The number of chunks by which the space needs to be extendedpublic static int requiredChunks(int pages)
pages
- The number of pages desiredpublic 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 chunkspublic 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 tracepublic 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 desiredpublic static int getSpaceCount()
public static Space[] getSpaces()
getSpaceCount()
to determine the maximum index that
is still filled.