|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mmtk.utility.heap.PageResource
public abstract class PageResource
This class manages the allocation of pages for a space. When a page is requested by the space both a page budget and the use of virtual address space are checked. If the request for space can't be satisfied (for either reason) a GC may be triggered.
This class is abstract, and is subclassed with monotone and freelist variants, which reflect monotonic and ad hoc space usage respectively. Monotonic use is easier to manage, but is obviously more restrictive (useful for copying collectors which allocate monotonically before freeing the entire space and starting over).
Field Summary | |
---|---|
private static Lock |
classLock
|
protected int |
committed
|
protected boolean |
contiguous
|
private static long |
cumulativeCommitted
|
private Lock |
lock
|
protected int |
reserved
|
protected Space |
space
|
protected Address |
start
only for contiguous spaces |
protected static boolean |
ZERO_ON_RELEASE
|
protected boolean |
zeroConcurrent
|
protected ConcurrentZeroingContext |
zeroingContext
|
protected boolean |
zeroNT
|
Constructor Summary | |
---|---|
(package private) |
PageResource(Space space)
Constructor for discontiguous spaces |
(package private) |
PageResource(Space space,
Address start)
Constructor for contiguous spaces |
private |
PageResource(Space space,
boolean contiguous)
Constructor |
Method Summary | |
---|---|
private static void |
addToCommitted(int pages)
Add to the total cumulative committed page count. |
abstract int |
adjustForMetaData(int pages)
Adjust a page request to include metadata requirements for a request of the given size. |
(package private) abstract Address |
allocPages(int reservedPages,
int requiredPages,
boolean zeroed)
|
void |
clearRequest(int reservedPages)
Remove a request to the space. |
protected void |
commitPages(int reservedPages,
int actualPages)
Commit pages to the page budget. |
int |
committedPages()
Return the number of committed pages |
void |
concurrentZeroing()
The entry point for the concurrent zeroing context. |
static long |
cumulativeCommittedPages()
Return the cumulative number of committed pages |
abstract int |
getAvailablePhysicalPages()
Return the number of available physical pages for this resource. |
Address |
getNewPages(int pagesReserved,
int pages,
boolean zeroed)
Allocate pages in virtual memory, returning zero on failure. |
protected void |
lock()
Acquire the lock. |
int |
reservedPages()
Return the number of reserved pages |
int |
reservePages(int pages)
Reserve pages. |
void |
skipConcurrentZeroing()
Skip concurrent zeroing (fall back to bulk zeroing). |
void |
triggerConcurrentZeroing()
Trigger concurrent zeroing. |
protected void |
unlock()
Release the lock. |
void |
updateZeroingApproach(boolean nontemporal,
boolean concurrent)
Update the zeroing approach for this page resource. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final boolean ZERO_ON_RELEASE
private static final Lock classLock
private static long cumulativeCommitted
protected int reserved
protected int committed
protected final boolean contiguous
protected final Space space
protected Address start
private final Lock lock
protected boolean zeroNT
protected boolean zeroConcurrent
protected ConcurrentZeroingContext zeroingContext
Constructor Detail |
---|
private PageResource(Space space, boolean contiguous)
space
- The space to which this resource is attachedPageResource(Space space)
space
- The space to which this resource is attachedPageResource(Space space, Address start)
space
- The space to which this resource is attachedMethod Detail |
---|
public abstract int getAvailablePhysicalPages()
Note: This just considers physical pages (ie virtual memory pages allocated for use by this resource). This calculation is orthogonal to and does not consider any restrictions on the number of pages this resource may actually use at any time (ie the number of committed and reserved pages).
Note: The calculation is made on the assumption that all space that could be assigned to this resource would be assigned to this resource (ie the unused discontiguous space could just as likely be assigned to another competing resource).
public final int reservePages(int pages)
The role of reserving pages is that it allows the request to be noted as pending (the difference between committed and reserved indicates pending requests). If the request would exceed the page budget then the caller must poll in case a GC is necessary.
pages
- The number of pages requested
public final void clearRequest(int reservedPages)
reservedPages
- The number of pages returned due to the request.public void updateZeroingApproach(boolean nontemporal, boolean concurrent)
public void skipConcurrentZeroing()
public void triggerConcurrentZeroing()
public void concurrentZeroing()
abstract Address allocPages(int reservedPages, int requiredPages, boolean zeroed)
public abstract int adjustForMetaData(int pages)
pages
- The size of the pending allocation in pages
public final Address getNewPages(int pagesReserved, int pages, boolean zeroed)
If the request cannot be satisfied, zero is returned and it
falls to the caller to trigger the GC.
Call allocPages
(subclass) to find the pages in
virtual memory. If successful then commit the pending page
request and return the address of the first page.
pagesReserved
- The number of pages reserved by the initial requestpages
- The number of pages requestedzeroed
- If true allocated pages are zeroed.
pages
pages, or
zero on failure.protected void commitPages(int reservedPages, int actualPages)
committed
and
reserved
while the request was pending.
This *MUST* be called by each PageResource during the
allocPages, and the caller must hold the lock.
reservedPages
- The number of pages initially reserved due to this requestactualPages
- The number of pages actually allocated.public final int reservedPages()
public final int committedPages()
public static long cumulativeCommittedPages()
private static void addToCommitted(int pages)
pages
- The number of pages to be added.protected final void lock()
protected final void unlock()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |