Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Scheduler for controlling the Execution of IR Passes #917

Merged
merged 4 commits into from

2 participants

@komax

After a discussion with @enebo and @subbuss, I propose a new simple interface for controlling the execution of IR passes. Explanation:

  • it is just an Iterable<CompilerPass>, as every configuration of IR passes is a directed acyclic graph (starting on IR and ending up in (optimized) IR)
  • If a IR pass requires to run after another pass (dependency), this must be modeled as an edge
  • There cannot be cycles, since this means to have unresolvable dependencies on passes
  • Hence, there must be a topological sort for each allowed execution configuration of IR passes
  • This is modeled as Iterable interface in CompilerPassScheduler

In future, there are maybe more features required to linearize and resolve the dependencies on IR passes. However, this simple interface should then be extended by more sophisticated features and then iterate in the end on the Scheduler.

@enebo enebo merged commit e135970 into jruby:master

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
18 core/src/main/java/org/jruby/ir/IRManager.java
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.jruby.RubyInstanceConfig;
@@ -10,6 +11,7 @@
import org.jruby.ir.passes.BasicCompilerPassListener;
import org.jruby.ir.passes.CompilerPass;
import org.jruby.ir.passes.CompilerPassListener;
+import org.jruby.ir.passes.CompilerPassScheduler;
/**
*/
@@ -62,6 +64,22 @@ public IRModuleBody getObject() {
return object;
}
+ public CompilerPassScheduler schedulePasses() {
+ CompilerPassScheduler scheduler = new CompilerPassScheduler() {
+ private Iterator<CompilerPass> iterator;
+ {
+ this.iterator = compilerPasses.iterator();
+ }
+
+ @Override
+ public Iterator<CompilerPass> iterator() {
+ return this.iterator;
+ }
+
+ };
+ return scheduler;
+ }
+
public List<CompilerPass> getCompilerPasses(IRScope scope) {
return compilerPasses;
}
View
5 core/src/main/java/org/jruby/ir/IRScope.java
@@ -36,6 +36,7 @@
import org.jruby.ir.operands.Variable;
import org.jruby.ir.operands.WrappedIRClosure;
import org.jruby.ir.passes.CompilerPass;
+import org.jruby.ir.passes.CompilerPassScheduler;
import org.jruby.ir.representations.BasicBlock;
import org.jruby.ir.representations.CFG;
import org.jruby.ir.representations.CFGLinearizer;
@@ -653,7 +654,6 @@ private void runCompilerPasses() {
// SSS FIXME: Why is this again? Document this weirdness!
// Forcibly clear out the shared eval-scope variable allocator each time this method executes
initEvalScopeVariableAllocator(true);
-
// SSS FIXME: We should configure different optimization levels
// and run different kinds of analysis depending on time budget. Accordingly, we need to set
// IR levels/states (basic, optimized, etc.) and the
@@ -661,7 +661,8 @@ private void runCompilerPasses() {
// while another thread is using it. This may need to happen on a clone()
// and we may need to update the method to return the new method. Also,
// if this scope is held in multiple locations how do we update all references?
- for (CompilerPass pass: getManager().getCompilerPasses(this)) {
+ CompilerPassScheduler scheduler = getManager().schedulePasses();
+ for (CompilerPass pass: scheduler) {
pass.run(this);
}
}
View
4 core/src/main/java/org/jruby/ir/passes/CompilerPassScheduler.java
@@ -0,0 +1,4 @@
+package org.jruby.ir.passes;
+
+public interface CompilerPassScheduler extends Iterable<CompilerPass> {
+}
Something went wrong with that request. Please try again.