public abstract class Phase extends Object
The context an individual phase executes in may be global, mutator, or collector.
Phases are executed within a stack and all synchronization between parallel GC threads is managed from within this class.
Modifier and Type | Field and Description |
---|---|
private static boolean |
allowConcurrentPhase
Do we want to allow new concurrent workers to become active
|
private static int[] |
complexPhaseCursor
Stores the current sub phase for a complex phase.
|
private static short |
concurrentPhaseId
The concurrent phase being executed
|
private static boolean |
evenMutatorResetRendezvous
Do we need to add a sync point to reset the mutator count.
|
private static int |
evenScheduledPhase
The current even (0 mod 2) scheduled phase.
|
protected short |
id
The unique phase identifier.
|
private static int |
MAX_PHASE_STACK_DEPTH
The maximum stack depth for the phase stack.
|
private static int |
MAX_PHASES
The maximum number of phases
|
protected String |
name
The name of the phase.
|
private static short |
nextPhaseId
The id to be allocated for the next phase
|
private static boolean |
oddMutatorResetRendezvous
Do we need to add a sync point to reset the mutator count.
|
private static int |
oddScheduledPhase
The current odd (1 mod 2) scheduled phase.
|
private static Phase[] |
phases
The array of phase instances.
|
private static int[] |
phaseStack
The phase stack.
|
private static int |
phaseStackPointer
The current stack pointer
|
protected static short |
SCHEDULE_COLLECTOR
Run the phase on collectors.
|
protected static short |
SCHEDULE_COMPLEX
This is a complex phase.
|
protected static short |
SCHEDULE_CONCURRENT
Run this phase concurrently with the mutators
|
protected static short |
SCHEDULE_GLOBAL
Run the phase globally.
|
protected static short |
SCHEDULE_MUTATOR
Run the phase on mutators.
|
protected static short |
SCHEDULE_PLACEHOLDER
Don't run this phase.
|
private static short |
startComplexTimer
The complex phase whose timer should be started after the next
rendezvous.
|
private static short |
stopComplexTimer
The complex phase whose timer should be stopped after the next
rendezvous.
|
protected Timer |
timer
The Timer that is started and stopped around the execution of this
phase.
|
Modifier | Constructor and Description |
---|---|
protected |
Phase(String name)
Create a new Phase.
|
protected |
Phase(String name,
Timer timer)
Create a new phase.
|
Modifier and Type | Method and Description |
---|---|
static void |
beginNewPhaseStack(int scheduledPhase)
Place a phase on the phase stack and begin processing.
|
static void |
clearConcurrentPhase()
Clear the current phase Id.
|
static boolean |
concurrentPhaseActive() |
static void |
continuePhaseStack()
Continue the execution of a phase stack.
|
static short |
createComplex(String name,
int... scheduledPhases)
Constructs a complex phase.
|
static short |
createComplex(String name,
Timer timer,
int... scheduledPhases)
Constructs a complex phase, re-using a specified timer.
|
static short |
createConcurrent(String name,
int atomicScheduledPhase)
Constructs a phase.
|
static short |
createConcurrent(String name,
Timer timer,
int atomicScheduledPhase)
Construct a phase, re-using a specified timer.
|
static short |
createSimple(String name)
Constructs a phase.
|
static short |
createSimple(String name,
Timer timer)
Constructs a phase, re-using a specified timer.
|
static short |
getConcurrentPhaseId() |
private static int |
getCurrentPhase(boolean isEvenPhase) |
short |
getId() |
static String |
getName(short phaseId) |
private static int |
getNextPhase()
Pull the next scheduled phase off the stack.
|
static Phase |
getPhase(short id)
Retrieve a phase by the unique phase identifier.
|
protected static short |
getPhaseId(int scheduledPhase) |
protected static short |
getSchedule(int scheduledPhase) |
protected static String |
getScheduleName(short ordering) |
private static int |
incrementComplexPhaseCursor()
Increment the cursor associated with the current phase
stack entry.
|
static boolean |
isPhaseStackEmpty()
Return true if phase stack is empty, false otherwise.
|
protected abstract void |
logPhase()
Display a description of this phase, for debugging purposes.
|
private static boolean |
needsMutatorResetRendezvous(boolean isEvenPhase) |
static boolean |
notifyConcurrentPhaseComplete()
Notify that the concurrent phase has completed successfully.
|
static void |
notifyConcurrentPhaseIncomplete()
Notify that the concurrent phase has not finished, and must be
re-attempted.
|
private static void |
pauseComplexTimers()
Pause all of the timers for the complex phases sitting in the stack.
|
private static int |
peekScheduledPhase()
Peek the scheduled phase at the top of the work stack.
|
private static int |
popScheduledPhase()
Pop off the scheduled phase at the top of the work stack.
|
private static void |
processPhaseStack(boolean resume)
Processes the phase stack.
|
static void |
pushScheduledPhase(int scheduledPhase)
Push a scheduled phase onto the top of the work stack.
|
static void |
resetPhaseStack()
Clears the scheduled phase stack.
|
private static void |
resumeComplexTimers()
Resume all of the timers for the complex phases sitting in the stack.
|
static int |
scheduleCollector(short phaseId)
Take the passed phase and return an encoded phase to
run that phase in a collector context;
|
static int |
scheduleComplex(short phaseId)
Take the passed phase and return an encoded phase to
run that phase as a complex phase.
|
static int |
scheduleConcurrent(short phaseId)
Take the passed phase and return an encoded phase to
run that phase as a concurrent phase.
|
static int |
scheduleGlobal(short phaseId)
Take the passed phase and return an encoded phase to
run that phase in a global context;
|
static int |
scheduleMutator(short phaseId)
Take the passed phase and return an encoded phase to
run that phase in a mutator context;
|
static int |
schedulePlaceholder(short phaseId)
Take the passed phase and return an encoded phase to
run that phase in a mutator context;
|
private static void |
setNextPhase(boolean isEvenPhase,
int scheduledPhase,
boolean needsResetRendezvous)
Sets the next phase.
|
private static final int MAX_PHASES
private static short nextPhaseId
protected static final short SCHEDULE_GLOBAL
protected static final short SCHEDULE_COLLECTOR
protected static final short SCHEDULE_MUTATOR
protected static final short SCHEDULE_CONCURRENT
protected static final short SCHEDULE_PLACEHOLDER
protected static final short SCHEDULE_COMPLEX
protected final short id
protected final Timer timer
private static final int MAX_PHASE_STACK_DEPTH
private static int[] complexPhaseCursor
private static int[] phaseStack
private static int phaseStackPointer
private static int evenScheduledPhase
private static int oddScheduledPhase
private static boolean evenMutatorResetRendezvous
private static boolean oddMutatorResetRendezvous
private static short startComplexTimer
private static short stopComplexTimer
private static short concurrentPhaseId
private static boolean allowConcurrentPhase
protected Phase(String name)
name
- The name for the phase.public static Phase getPhase(short id)
id
- The phase identifier.protected static short getPhaseId(int scheduledPhase)
scheduledPhase
- an encoded phasepublic static String getName(short phaseId)
phaseId
- The unique phase identifier.protected static short getSchedule(int scheduledPhase)
scheduledPhase
- an encoded phaseprotected static String getScheduleName(short ordering)
ordering
- the ordering component of a phasepublic static short createSimple(String name)
name
- Display name of the phasepublic static short createSimple(String name, Timer timer)
name
- Display name of the phasetimer
- the time to re-usepublic static short createComplex(String name, int... scheduledPhases)
name
- Display name of the phasescheduledPhases
- The phases in this complex phase.public static short createComplex(String name, Timer timer, int... scheduledPhases)
name
- Display name of the phasetimer
- Timer for this phase to contribute toscheduledPhases
- The phases in this complex phase.public static final short createConcurrent(String name, int atomicScheduledPhase)
name
- Display name of the phaseatomicScheduledPhase
- The corresponding atomic phase to run in a stop the world collectionpublic static final short createConcurrent(String name, Timer timer, int atomicScheduledPhase)
name
- Display name of the phasetimer
- Timer for this phase to contribute toatomicScheduledPhase
- The corresponding atomic phase to run in a stop the world collectionpublic static int scheduleComplex(short phaseId)
phaseId
- The phase to run as complexpublic static int scheduleConcurrent(short phaseId)
phaseId
- The phase to run as concurrentpublic static int scheduleGlobal(short phaseId)
phaseId
- The phase to run globallypublic static int scheduleCollector(short phaseId)
phaseId
- The phase to run on collectorspublic static int scheduleMutator(short phaseId)
phaseId
- The phase to run on mutatorspublic static int schedulePlaceholder(short phaseId)
phaseId
- The phase to run on mutatorspublic final short getId()
protected abstract void logPhase()
public static void beginNewPhaseStack(int scheduledPhase)
scheduledPhase
- The phase to executepublic static void continuePhaseStack()
private static void processPhaseStack(boolean resume)
resume
- whether to resume garbage collection. If set to true
,
GC status will be set to Plan.GC_PROPER
when the first phase
is processed.private static int getCurrentPhase(boolean isEvenPhase)
isEvenPhase
- whether an even or odd phase will be returnedprivate static boolean needsMutatorResetRendezvous(boolean isEvenPhase)
isEvenPhase
- whether the phase is even or oddprivate static void setNextPhase(boolean isEvenPhase, int scheduledPhase, boolean needsResetRendezvous)
isEvenPhase
- whether the phase is evenscheduledPhase
- the scheduled phaseneedsResetRendezvous
- whether it's necessary to rendezvous. This is
only necessary for consecutive mutator phases.private static int getNextPhase()
private static void pauseComplexTimers()
private static void resumeComplexTimers()
public static boolean isPhaseStackEmpty()
public static void resetPhaseStack()
public static void pushScheduledPhase(int scheduledPhase)
scheduledPhase
- The scheduled phase.private static int incrementComplexPhaseCursor()
private static int popScheduledPhase()
private static int peekScheduledPhase()
public static short getConcurrentPhaseId()
public static void clearConcurrentPhase()
public static boolean concurrentPhaseActive()
true
if there is an active concurrent phase.public static boolean notifyConcurrentPhaseComplete()
true
if more concurrent work needs to be done right now,
false
otherwisepublic static void notifyConcurrentPhaseIncomplete()