|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpolyglot.frontend.Scheduler
public abstract class Scheduler
The Scheduler
manages Goal
s and runs
Pass
es.
The basic idea is to have the scheduler try to satisfy goals.
To reach a goal, a pass is run. The pass could modify an AST or it
could, for example, initialize the members of a class loaded from a
class file. Passes may be rerun if a goal is not reached. Goals are
processed via a worklist. A goal may have prerequisite
dependencies and corequisite dependencies. All prerequisites
must be reached before the goal is attempted. A corequisite may be
reached while satisfying the goal itself, or vice versa.
Recursive passes are not allowed. If a goal cannot be reached a
SchedulerException (or more usually the subclass
MissingDependencyException) is thrown. The scheduler catches the
exception and adds the goal back onto the worklist and adds the
missing dependency, if any, to the dependency graph. Optionally, a
pass may catch the exception, but it must mark the goal as unreachable
on this run so that it will be added back to the worklist; the pass
must also add any missing dependencies.
Nested Class Summary | |
---|---|
protected static class |
Scheduler.TheEndGoal
|
Field Summary | |
---|---|
protected java.util.Collection |
commandLineJobs
|
protected static java.lang.Object |
COMPLETED_JOB
|
protected Pass |
currentPass
The currently running pass, or null if no pass is running. |
protected static int |
dumpCounter
|
protected ExtensionInfo |
extInfo
|
protected java.util.Map |
goals
Map from goals to goals used to intern goals. |
protected Goal |
infiniteLoopGoal
|
protected java.util.Set |
inWorklist
Collection of uncompleted goals. |
protected java.util.Map |
jobs
A map from Source s to Job s or to
the COMPLETED_JOB object if the Job previously
existed
but has now finished. |
protected static int |
MAX_RUN_COUNT
|
protected java.util.Map |
runCount
Map from goals to number of times a pass was run for the goal. |
protected java.util.LinkedList |
worklist
|
Constructor Summary | |
---|---|
Scheduler(ExtensionInfo extInfo)
|
Method Summary | |
---|---|
void |
addCorequisiteDependency(Goal goal,
Goal subgoal)
Add a new corequisite subgoal of the goal . |
void |
addCorequisiteDependencyAndEnqueue(Goal goal,
Goal subgoal)
|
void |
addDependencyAndEnqueue(Goal goal,
Goal subgoal,
boolean prerequisite)
|
void |
addGoal(Goal goal)
Add goal to the worklist. |
Job |
addJob(Source source)
Add a new Job for the Source source . |
Job |
addJob(Source source,
Node ast)
Add a new Job for the Source source ,
with AST ast . |
void |
addPrerequisiteDependency(Goal goal,
Goal subgoal)
Add a new subgoal of goal . |
void |
addPrerequisiteDependencyChain(java.util.List deps)
Add prerequisite dependencies between adjacent items in a list of goals. |
boolean |
attemptGoal(Goal goal)
Run a passes until the goal is attempted. |
protected boolean |
attemptGoal(Goal goal,
java.util.Set above)
|
abstract Goal |
CodeGenerated(Job job)
|
java.util.Collection |
commandLineJobs()
|
protected void |
completeJob(Job job)
|
abstract Goal |
ConstantsChecked(Job job)
|
abstract Goal |
ConstructorCallsChecked(Job job)
|
protected Job |
createSourceJob(Source source,
Node ast)
Create a new Job for the given source and AST. |
Goal |
currentGoal()
|
Job |
currentJob()
|
Pass |
currentPass()
|
abstract Goal |
Disambiguated(Job job)
|
protected void |
dumpDependenceGraph()
Dump the dependence graph to a DOT file. |
protected void |
dumpDependenceGraph(Goal g)
Dump the dependence graph to a DOT file. |
protected void |
dumpInFlightDependenceGraph()
Dump the dependence graph to a DOT file. |
abstract Goal |
ExceptionsChecked(Job job)
|
abstract Goal |
ExitPathsChecked(Job job)
|
abstract Goal |
FieldConstantsChecked(FieldInstance fi)
|
abstract Goal |
ForwardReferencesChecked(Job job)
|
abstract Goal |
ImportTableInitialized(Job job)
|
boolean |
inInfiniteLoop()
|
abstract Goal |
InitializationsChecked(Job job)
|
Goal |
internGoal(Goal goal)
Intern the goal so that there is only one copy of the goal. |
java.util.Collection |
jobs()
Return all compilation units currently being compiled. |
Job |
loadSource(FileSource source,
boolean compile)
Load a source file and create a job for it. |
abstract Goal |
MembersAdded(ParsedClassType ct)
|
abstract Goal |
Parsed(Job job)
|
boolean |
prerequisiteDependsOn(Goal goal,
Goal subgoal)
|
abstract Goal |
ReachabilityChecked(Job job)
|
boolean |
reached(Goal g)
|
protected boolean |
runGoal(Goal goal)
|
protected boolean |
runPass(Pass pass)
Run the pass pass . |
boolean |
runToCompletion()
Attempt to complete all goals in the worklist (and any subgoals they have). |
abstract Goal |
Serialized(Job job)
|
void |
setCommandLineJobs(java.util.Collection c)
|
abstract Goal |
SignaturesDisambiguated(Job job)
|
abstract Goal |
SignaturesResolved(ParsedClassType ct)
|
boolean |
sourceHasJob(Source s)
|
protected static java.lang.String |
statusString(boolean okay)
|
abstract Goal |
SupertypesDisambiguated(Job job)
|
abstract Goal |
SupertypesResolved(ParsedClassType ct)
|
java.lang.String |
toString()
|
abstract Goal |
TypeChecked(Job job)
|
abstract Goal |
TypeExists(java.lang.String name)
|
abstract Goal |
TypesInitialized(Job job)
|
abstract Goal |
TypesInitializedForCommandLine()
|
protected java.util.List |
worklist()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ExtensionInfo extInfo
protected java.util.Set inWorklist
protected java.util.LinkedList worklist
protected java.util.Map jobs
Source
s to Job
s or to
the COMPLETED_JOB
object if the Job previously
existed
but has now finished. The map contains entries for all
Source
s that have had Job
s added for them.
protected java.util.Collection commandLineJobs
protected java.util.Map goals
protected java.util.Map runCount
protected static final java.lang.Object COMPLETED_JOB
protected Pass currentPass
protected static int dumpCounter
protected static final int MAX_RUN_COUNT
protected Goal infiniteLoopGoal
Constructor Detail |
---|
public Scheduler(ExtensionInfo extInfo)
Method Detail |
---|
public java.util.Collection commandLineJobs()
public void setCommandLineJobs(java.util.Collection c)
public boolean prerequisiteDependsOn(Goal goal, Goal subgoal)
public void addCorequisiteDependency(Goal goal, Goal subgoal)
subgoal
of the goal
.
subgoal
is a goal on which goal
mutually
depends. The caller must be careful to ensure that all corequisite goals
can be eventually reached.
public void addCorequisiteDependencyAndEnqueue(Goal goal, Goal subgoal)
public void addDependencyAndEnqueue(Goal goal, Goal subgoal, boolean prerequisite)
public void addPrerequisiteDependency(Goal goal, Goal subgoal) throws CyclicDependencyException
subgoal
of goal
.
subgoal
must be completed before goal
is
attempted.
CyclicDependencyException
- if a prerequisite of subgoal
is
goal
public void addPrerequisiteDependencyChain(java.util.List deps) throws CyclicDependencyException
CyclicDependencyException
public Goal internGoal(Goal goal)
goal
so that there is only one copy of the goal.
All goals passed into and returned by scheduler should be interned.
goal
-
goal
public void addGoal(Goal goal)
goal
to the worklist.
public boolean reached(Goal g)
protected void completeJob(Job job)
protected java.util.List worklist()
public boolean runToCompletion()
true
if all passes were
successfully run and all goals in the worklist were reached. The worklist
should be empty at return.
public Job loadSource(FileSource source, boolean compile)
source
- The source file to load.compile
- True if the compile goal should be added for the new job.
public boolean sourceHasJob(Source s)
public Job currentJob()
public Pass currentPass()
public Goal currentGoal()
public boolean attemptGoal(Goal goal)
goal
is attempted. Callers should
check goal.completed() and should be able to handle the goal not being
reached.
protected boolean attemptGoal(Goal goal, java.util.Set above)
protected boolean runGoal(Goal goal)
protected boolean runPass(Pass pass)
pass
. All subgoals of the pass's goal
required to start the pass should be satisfied. Running the pass
may not satisfy the goal, forcing it to be retried later with new
subgoals.
protected static java.lang.String statusString(boolean okay)
public abstract Goal TypeExists(java.lang.String name)
public abstract Goal MembersAdded(ParsedClassType ct)
public abstract Goal SupertypesResolved(ParsedClassType ct)
public abstract Goal SignaturesResolved(ParsedClassType ct)
public abstract Goal FieldConstantsChecked(FieldInstance fi)
public abstract Goal Parsed(Job job)
public abstract Goal TypesInitialized(Job job)
public abstract Goal TypesInitializedForCommandLine()
public abstract Goal ImportTableInitialized(Job job)
public abstract Goal SignaturesDisambiguated(Job job)
public abstract Goal SupertypesDisambiguated(Job job)
public abstract Goal Disambiguated(Job job)
public abstract Goal TypeChecked(Job job)
public abstract Goal ConstantsChecked(Job job)
public abstract Goal ReachabilityChecked(Job job)
public abstract Goal ExceptionsChecked(Job job)
public abstract Goal ExitPathsChecked(Job job)
public abstract Goal InitializationsChecked(Job job)
public abstract Goal ConstructorCallsChecked(Job job)
public abstract Goal ForwardReferencesChecked(Job job)
public abstract Goal Serialized(Job job)
public abstract Goal CodeGenerated(Job job)
public java.util.Collection jobs()
public Job addJob(Source source)
Job
for the Source source
.
A new job will be created if
needed. If the Source source
has already been processed,
and its job discarded to release resources, then null
will be returned.
public Job addJob(Source source, Node ast)
Job
for the Source source
,
with AST ast
.
A new job will be created if
needed. If the Source source
has already been processed,
and its job discarded to release resources, then null
will be returned.
protected Job createSourceJob(Source source, Node ast)
Job
for the given source and AST.
In general, this method should only be called by addJob
.
public java.lang.String toString()
toString
in class java.lang.Object
public boolean inInfiniteLoop()
protected void dumpDependenceGraph()
protected void dumpInFlightDependenceGraph()
protected void dumpDependenceGraph(Goal g)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |