public abstract class PageResource extends Object
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).
Modifier and Type | Field and Description |
---|---|
private static Lock |
classLock
lock protecting count of total cumulative pages committed
|
protected int |
committed |
protected boolean |
contiguous |
private static long |
cumulativeCommitted
cumulative count of pages ever committed
|
private Lock |
lock |
protected int |
reserved |
protected Space |
space |
protected Address |
start
only for contiguous spaces
|
protected boolean |
zeroConcurrent |
protected ConcurrentZeroingContext |
zeroingContext |
protected boolean |
zeroNT |
Modifier | Constructor and Description |
---|---|
(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) |
Modifier and Type | Method and Description |
---|---|
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.
|
private static final Lock classLock
private static long cumulativeCommitted
protected int reserved
protected int committed
protected final boolean contiguous
protected boolean zeroNT
protected boolean zeroConcurrent
protected ConcurrentZeroingContext zeroingContext
private PageResource(Space space, boolean contiguous)
space
- The space to which this resource is attachedcontiguous
- whether the space is contiguous or discontiguousPageResource(Space space)
space
- The space to which this resource is attachedPageResource(Space space, Address start)
space
- The space to which this resource is attachedstart
- start address of the spacepublic 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 requestedpublic final void clearRequest(int reservedPages)
reservedPages
- The number of pages returned due to the request.public void updateZeroingApproach(boolean nontemporal, boolean concurrent)
nontemporal
- whether to use non-temporal instructions for zeroingconcurrent
- whether to do the zeroing concurrentlypublic 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 pagespublic 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()