public final class MarkCompactCollector extends Object
Specifically, this class provides the methods that
Each collector thread maintains a private list of the pages that it compacts. If it runs out of work during the calculateForwardingPointers pass, it requests a new region from the global MarkCompactSpace. Regions compacted by a collector remain local to the collector.
MarkCompactSpace
,
MarkCompactLocal
Modifier and Type | Class and Description |
---|---|
private static class |
MarkCompactCollector.FromCursor
Subclass for the read-only cursor that leads the scan of regions.
|
private static class |
MarkCompactCollector.RegionCursor
Both the 'compact' and 'calculate' phases can be thought of as sweeping
a pair of cursors across a linked list of regions.
|
private static class |
MarkCompactCollector.ToCursor
Subclass for the read-only cursor that follows the 'from' cursor,
writing or calculating the position of copied objects
|
Modifier and Type | Field and Description |
---|---|
private MarkCompactCollector.FromCursor |
fromCursor |
private Address |
regions
This collector's work list
|
private MarkCompactSpace |
space |
private MarkCompactCollector.ToCursor |
toCursor |
(package private) static boolean |
VERBOSE |
(package private) static boolean |
VERY_VERBOSE |
Constructor and Description |
---|
MarkCompactCollector(MarkCompactSpace space)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
calculateForwardingPointers()
Perform a linear scan through the objects allocated by this bump pointer,
calculating where each live object will be post collection.
|
void |
compact()
Perform the compacting phase of the collection.
|
static final boolean VERBOSE
static final boolean VERY_VERBOSE
private final MarkCompactSpace space
private final MarkCompactCollector.FromCursor fromCursor
private final MarkCompactCollector.ToCursor toCursor
public MarkCompactCollector(MarkCompactSpace space)
space
- The space to bump point into.public void calculateForwardingPointers()
We maintain two cursors, fromCursor
and toCursor
, and simulate
copying live objects from the former to the latter. Initially, the cursors
point to the first region in this collector's local list, and increment in
lockstep until the first dead object is encountered. After that, the to cursor
trails the from cursor.
The outer loop advances the 'from' pointer
public void compact()