|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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 |
gcLock
|
private Lock |
mutatorLock
|
private int |
pageBudget
|
protected int |
required
|
protected int |
reserved
Instance variables |
protected Space |
space
|
protected Address |
start
|
protected static boolean |
ZERO_ON_RELEASE
Class variables |
| Constructor Summary | |
|---|---|
(package private) |
PageResource(int pageBudget,
Space space)
Constructor for discontiguous spaces |
(package private) |
PageResource(int pageBudget,
Space space,
Address start)
Constructor for contiguous spaces |
private |
PageResource(int pageBudget,
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 pages)
|
void |
clearRequest(int pages)
Remove a request to the space. |
protected void |
commitPages(int requestedPages,
int totalPages)
Commit pages to the page budget. |
int |
committedPages()
Return the number of committed pages |
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 pages)
Allocate pages in virtual memory, returning zero on failure. |
protected void |
lock()
Acquire the appropriate lock depending on whether the context is GC or mutator. |
int |
requiredPages()
Return the number of required pages |
int |
reservedPages()
Return the number of reserved pages |
boolean |
reservePages(int pages)
Reserve pages. |
void |
unconditionallyReleasePages(int pages)
Release pages unconditionally. |
void |
unconditionallyReservePages(int pages)
Reserve pages unconditionally. |
protected void |
unlock()
Release the appropriate lock depending on whether the context is GC or mutator. |
| 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 int required
private final int pageBudget
protected final boolean contiguous
protected final Space space
protected Address start
private final Lock gcLock
private final Lock mutatorLock
| Constructor Detail |
|---|
private PageResource(int pageBudget,
Space space,
boolean contiguous)
pageBudget - The budget of pages available to this memory
manager before it must poll the collector.space - The space to which this resource is attached
PageResource(int pageBudget,
Space space)
pageBudget - The budget of pages available to this memory
manager before it must poll the collector.space - The space to which this resource is attached
PageResource(int pageBudget,
Space space,
Address start)
pageBudget - The budget of pages available to this memory
manager before it must poll the collector.space - The space to which this resource is attached| Method Detail |
|---|
public abstract int getAvailablePhysicalPages()
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 boolean 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 pages)
pages - The number of pages in the request.public final void unconditionallyReservePages(int pages)
An example of where this is useful is in cases where it is desirable to put some space aside as head-room. By unconditionally reserving the pages, the pages are counted against the collectors budget. When the space is actually needed, the pages can be unconditionally released, freeing the pages for other purposes.
pages - The number of pages to be unconditionally
reserved.public final void unconditionallyReleasePages(int pages)
This call allows pages to be unconditionally removed from the collectors page budget.
pages - The number of pages to be unconditionally
released.unconditionallyReservePages(int)abstract Address allocPages(int pages)
public abstract int adjustForMetaData(int pages)
pages - The size of the pending allocation in pages
public final Address getNewPages(int pages)
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.
pages - The number of pages requested
pages pages, or
zero on failure.
protected void commitPages(int requestedPages,
int totalPages)
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.
requestedPages - The number of pages from this requesttotalPages - The number of pagespublic final int reservedPages()
public final int committedPages()
public final int requiredPages()
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 | |||||||||