Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[IR] Renamed several classes to more accurate reflect functionality.

  • Loading branch information...
commit 327418d76b115379018f55dc696453dc7d7c3bb1 1 parent 6db14a4
@subbuss subbuss authored
View
2  src/org/jruby/ir/IRBuilder.java
@@ -350,7 +350,7 @@ public static void main(String[] args) {
long t7 = new Date().getTime();
scope.runCompilerPass(new DeadCodeElimination());
long t8 = new Date().getTime();
- // scope.runCompilerPass(new AddBindingInstructions());
+ // scope.runCompilerPass(new AddLocalVarLoadStoreInstructions());
// long t9 = new Date().getTime();
if (isDebug) {
scope.runCompilerPass(new IRPrinter());
View
4 src/org/jruby/ir/IRScope.java
@@ -14,7 +14,7 @@
import org.jruby.ir.passes.IRPrinter;
import org.jruby.ir.passes.InlineTest;
import org.jruby.ir.passes.LinearizeCFG;
-import org.jruby.ir.passes.AddBindingInstructions;
+import org.jruby.ir.passes.AddLocalVarLoadStoreInstructions;
import org.jruby.ir.passes.LiveVariableAnalysis;
import org.jruby.ir.passes.opts.DeadCodeElimination;
import org.jruby.ir.passes.opts.LocalOptimizationPass;
@@ -579,7 +579,7 @@ private void runCompilerPasses() {
printPass("After inline");
}
- if (RubyInstanceConfig.IR_OPT_LVAR_ACCESS) runCompilerPass(new AddBindingInstructions());
+ if (RubyInstanceConfig.IR_OPT_LVAR_ACCESS) runCompilerPass(new AddLocalVarLoadStoreInstructions());
// Do not run dead-code-elimination on eval-scripts because they might
// update their enclosing environments.
View
8 src/org/jruby/ir/dataflow/DataFlowConstants.java
@@ -3,16 +3,16 @@
import java.util.List;
import org.jruby.ir.dataflow.analyses.LiveVariablesProblem;
-import org.jruby.ir.dataflow.analyses.BindingLoadPlacementProblem;
-import org.jruby.ir.dataflow.analyses.BindingStorePlacementProblem;
+import org.jruby.ir.dataflow.analyses.LoadLocalVarPlacementProblem;
+import org.jruby.ir.dataflow.analyses.StoreLocalVarPlacementProblem;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.transformations.inlining.InlinerInfo;
public class DataFlowConstants {
public static final String LVP_NAME = LiveVariablesProblem.NAME;
- public static final String BLP_NAME = (new BindingLoadPlacementProblem()).getName();
- public static final String BSP_NAME = (new BindingStorePlacementProblem()).getName();
+ public static final String LLVP_NAME = (new LoadLocalVarPlacementProblem()).getName();
+ public static final String SLVP_NAME = (new StoreLocalVarPlacementProblem()).getName();
/* Lattice TOP, BOTTOM, ANY values -- these will be used during dataflow analyses */
View
20 ...r/dataflow/analyses/BindingLoadPlacementNode.java → .../dataflow/analyses/LoadLocalVarPlacementNode.java
@@ -12,7 +12,7 @@
import org.jruby.ir.dataflow.FlowGraphNode;
import org.jruby.ir.instructions.CallBase;
import org.jruby.ir.instructions.Instr;
-import org.jruby.ir.instructions.LoadFromBindingInstr;
+import org.jruby.ir.instructions.LoadLocalVarInstr;
import org.jruby.ir.instructions.ResultInstr;
import org.jruby.ir.operands.ClosureLocalVariable;
import org.jruby.ir.operands.LocalVariable;
@@ -22,8 +22,8 @@
import org.jruby.ir.operands.WrappedIRClosure;
import org.jruby.ir.representations.BasicBlock;
-public class BindingLoadPlacementNode extends FlowGraphNode {
- public BindingLoadPlacementNode(DataFlowProblem prob, BasicBlock n) {
+public class LoadLocalVarPlacementNode extends FlowGraphNode {
+ public LoadLocalVarPlacementNode(DataFlowProblem prob, BasicBlock n) {
super(prob, n);
}
@@ -40,12 +40,12 @@ public void buildDataFlowVars(Instr i) {
public void initSolnForNode() {
if (basicBlock == problem.getScope().cfg().getExitBB()) {
- inRequiredLoads = ((BindingLoadPlacementProblem) problem).getLoadsOnScopeExit();
+ inRequiredLoads = ((LoadLocalVarPlacementProblem) problem).getLoadsOnScopeExit();
}
}
public void compute_MEET(BasicBlock source, FlowGraphNode pred) {
- BindingLoadPlacementNode n = (BindingLoadPlacementNode) pred;
+ LoadLocalVarPlacementNode n = (LoadLocalVarPlacementNode) pred;
inRequiredLoads.addAll(n.outRequiredLoads);
}
@@ -127,7 +127,7 @@ private TemporaryVariable getLocalVarReplacement(LocalVariable v, IRScope scope,
}
public void addLoads(Map<Operand, Operand> varRenameMap) {
- BindingLoadPlacementProblem blp = (BindingLoadPlacementProblem) problem;
+ LoadLocalVarPlacementProblem blp = (LoadLocalVarPlacementProblem) problem;
IRScope s = blp.getScope();
List<Instr> instrs = basicBlock.getInstrs();
ListIterator<Instr> it = instrs.listIterator(instrs.size());
@@ -152,7 +152,7 @@ public void addLoads(Map<Operand, Operand> varRenameMap) {
it.next();
for (LocalVariable v : reqdLoads) {
if (cl.definesLocalVariable(v)) {
- it.add(new LoadFromBindingInstr(s, getLocalVarReplacement(v, s, varRenameMap), v));
+ it.add(new LoadLocalVarInstr(s, getLocalVarReplacement(v, s, varRenameMap), v));
it.previous();
newReqdLoads.remove(v);
}
@@ -165,7 +165,7 @@ public void addLoads(Map<Operand, Operand> varRenameMap) {
if (call.targetRequiresCallersBinding()) {
it.next();
for (LocalVariable v : reqdLoads) {
- it.add(new LoadFromBindingInstr(s, getLocalVarReplacement(v, s, varRenameMap), v));
+ it.add(new LoadLocalVarInstr(s, getLocalVarReplacement(v, s, varRenameMap), v));
it.previous();
}
it.previous();
@@ -197,10 +197,10 @@ public void addLoads(Map<Operand, Operand> varRenameMap) {
IRClosure definingScope = ((ClosureLocalVariable)v).definingScope;
if ((s != definingScope) && s.isNestedInClosure(definingScope)) {
- it.add(new LoadFromBindingInstr(s, getLocalVarReplacement(v, s, varRenameMap), v));
+ it.add(new LoadLocalVarInstr(s, getLocalVarReplacement(v, s, varRenameMap), v));
}
} else {
- it.add(new LoadFromBindingInstr(s, getLocalVarReplacement(v, s, varRenameMap), v));
+ it.add(new LoadLocalVarInstr(s, getLocalVarReplacement(v, s, varRenameMap), v));
}
}
}
View
8 ...ataflow/analyses/BindingLoadPlacementProblem.java → ...taflow/analyses/LoadLocalVarPlacementProblem.java
@@ -9,8 +9,8 @@
import java.util.Map;
import java.util.Set;
-public class BindingLoadPlacementProblem extends DataFlowProblem {
- public BindingLoadPlacementProblem() {
+public class LoadLocalVarPlacementProblem extends DataFlowProblem {
+ public LoadLocalVarPlacementProblem() {
super(DataFlowProblem.DF_Direction.BACKWARD);
initLoadsOnExit = new java.util.HashSet<LocalVariable>();
bindingHasEscaped = false;
@@ -21,7 +21,7 @@ public String getName() {
}
public FlowGraphNode buildFlowGraphNode(BasicBlock bb) {
- return new BindingLoadPlacementNode(this, bb);
+ return new LoadLocalVarPlacementNode(this, bb);
}
@Override
@@ -47,7 +47,7 @@ public void setBindingHasEscaped(boolean flag) {
public void addLoads(Map<Operand, Operand> varRenameMap) {
for (FlowGraphNode n: flowGraphNodes) {
- BindingLoadPlacementNode blpn = (BindingLoadPlacementNode)n;
+ LoadLocalVarPlacementNode blpn = (LoadLocalVarPlacementNode)n;
blpn.addLoads(varRenameMap);
}
}
View
24 .../dataflow/analyses/BindingStorePlacementNode.java → ...dataflow/analyses/StoreLocalVarPlacementNode.java
@@ -16,7 +16,7 @@
import org.jruby.ir.instructions.ClosureReturnInstr;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.instructions.ResultInstr;
-import org.jruby.ir.instructions.StoreToBindingInstr;
+import org.jruby.ir.instructions.StoreLocalVarInstr;
import org.jruby.ir.operands.ClosureLocalVariable;
import org.jruby.ir.operands.LocalVariable;
import org.jruby.ir.operands.Operand;
@@ -25,8 +25,8 @@
import org.jruby.ir.operands.WrappedIRClosure;
import org.jruby.ir.representations.BasicBlock;
-public class BindingStorePlacementNode extends FlowGraphNode {
- public BindingStorePlacementNode(DataFlowProblem prob, BasicBlock n) {
+public class StoreLocalVarPlacementNode extends FlowGraphNode {
+ public StoreLocalVarPlacementNode(DataFlowProblem prob, BasicBlock n) {
super(prob, n);
}
@@ -54,7 +54,7 @@ public void initSolnForNode() {
}
public void compute_MEET(BasicBlock source, FlowGraphNode pred) {
- BindingStorePlacementNode n = (BindingStorePlacementNode) pred;
+ StoreLocalVarPlacementNode n = (StoreLocalVarPlacementNode) pred;
inDirtyVars.addAll(n.outDirtyVars);
// For binding allocation, we are using the and operator -- so only if the binding has been allocated
@@ -136,15 +136,15 @@ private TemporaryVariable getLocalVarReplacement(LocalVariable v, IRScope scope,
return value;
}
- private void addClosureExitBindingStores(IRScope scope, ListIterator<Instr> instrs, Set<LocalVariable> dirtyVars, Map<Operand, Operand> varRenameMap) {
+ private void addClosureExitStoreLocalVars(IRScope scope, ListIterator<Instr> instrs, Set<LocalVariable> dirtyVars, Map<Operand, Operand> varRenameMap) {
for (LocalVariable v : dirtyVars) {
if (v instanceof ClosureLocalVariable) {
IRClosure definingScope = ((ClosureLocalVariable)v).definingScope;
if ((scope != definingScope) && scope.isNestedInClosure(definingScope)) {
- instrs.add(new StoreToBindingInstr(getLocalVarReplacement(v, scope, varRenameMap), scope, v));
+ instrs.add(new StoreLocalVarInstr(getLocalVarReplacement(v, scope, varRenameMap), scope, v));
}
} else {
- instrs.add(new StoreToBindingInstr(getLocalVarReplacement(v, scope, varRenameMap), scope, v));
+ instrs.add(new StoreLocalVarInstr(getLocalVarReplacement(v, scope, varRenameMap), scope, v));
}
}
}
@@ -152,7 +152,7 @@ private void addClosureExitBindingStores(IRScope scope, ListIterator<Instr> inst
public void addStoreAndBindingAllocInstructions(Map<Operand, Operand> varRenameMap, Set<LocalVariable> callsiteDirtyVars) {
boolean addAllocateBindingInstructions = false; // SSS: This is going to be useful during JIT -- we are far away from there at this time
- BindingStorePlacementProblem bsp = (BindingStorePlacementProblem) problem;
+ StoreLocalVarPlacementProblem bsp = (StoreLocalVarPlacementProblem) problem;
IRScope scope = bsp.getScope();
ListIterator<Instr> instrs = basicBlock.getInstrs().listIterator();
Set<LocalVariable> dirtyVars = new HashSet<LocalVariable>(inDirtyVars);
@@ -207,7 +207,7 @@ public void addStoreAndBindingAllocInstructions(Map<Operand, Operand> varRenameM
Set<LocalVariable> newDirtyVars = new HashSet<LocalVariable>(dirtyVars);
for (LocalVariable v : dirtyVars) {
if (spillAllVars || cl.usesLocalVariable(v)) {
- instrs.add(new StoreToBindingInstr(getLocalVarReplacement(v, scope, varRenameMap), scope, v));
+ instrs.add(new StoreLocalVarInstr(getLocalVarReplacement(v, scope, varRenameMap), scope, v));
newDirtyVars.remove(v);
} else if (cl.definesLocalVariable(v)) {
// These variables will be spilt inside the closure -- so they will no longer be dirty after the call site!
@@ -225,7 +225,7 @@ public void addStoreAndBindingAllocInstructions(Map<Operand, Operand> varRenameM
}
}
for (LocalVariable v : dirtyVars) {
- instrs.add(new StoreToBindingInstr(getLocalVarReplacement(v, scope, varRenameMap), scope, v));
+ instrs.add(new StoreLocalVarInstr(getLocalVarReplacement(v, scope, varRenameMap), scope, v));
}
instrs.next();
dirtyVars.clear();
@@ -266,7 +266,7 @@ public void addStoreAndBindingAllocInstructions(Map<Operand, Operand> varRenameM
}
instrs.previous();
- addClosureExitBindingStores(scope, instrs, dirtyVars, varRenameMap);
+ addClosureExitStoreLocalVars(scope, instrs, dirtyVars, varRenameMap);
instrs.next();
// Nothing is dirty anymore -- everything that needs spilling has been spilt
@@ -288,7 +288,7 @@ public void addStoreAndBindingAllocInstructions(Map<Operand, Operand> varRenameM
}
// If this is the exit BB, add binding stores for all vars that are still dirty
- if (amExitBB) addClosureExitBindingStores(scope, instrs, dirtyVars, varRenameMap);
+ if (amExitBB) addClosureExitStoreLocalVars(scope, instrs, dirtyVars, varRenameMap);
}
Set<LocalVariable> inDirtyVars; // On entry to flow graph node: Variables that need to be stored to the heap binding
View
12 ...taflow/analyses/BindingStorePlacementProblem.java → ...aflow/analyses/StoreLocalVarPlacementProblem.java
@@ -5,7 +5,7 @@
import org.jruby.ir.dataflow.DataFlowProblem;
import org.jruby.ir.dataflow.FlowGraphNode;
import org.jruby.ir.instructions.ReceiveExceptionInstr;
-import org.jruby.ir.instructions.StoreToBindingInstr;
+import org.jruby.ir.instructions.StoreLocalVarInstr;
import org.jruby.ir.instructions.ThrowExceptionInstr;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.LocalVariable;
@@ -26,9 +26,9 @@
// strictly speaking, this is a AND of two independent dataflow analyses -- we are doing these together for
// efficiency reasons, and also because the binding allocation problem is also a forwards flow problem and is a
// relatively straightforward analysis.
-public class BindingStorePlacementProblem extends DataFlowProblem {
+public class StoreLocalVarPlacementProblem extends DataFlowProblem {
- public BindingStorePlacementProblem() {
+ public StoreLocalVarPlacementProblem() {
super(DataFlowProblem.DF_Direction.FORWARD);
}
@@ -37,7 +37,7 @@ public String getName() {
}
public FlowGraphNode buildFlowGraphNode(BasicBlock bb) {
- return new BindingStorePlacementNode(this, bb);
+ return new StoreLocalVarPlacementNode(this, bb);
}
@Override
@@ -65,7 +65,7 @@ public void addStoreAndBindingAllocInstructions(Map<Operand, Operand> varRenameM
}
for (FlowGraphNode n : flowGraphNodes) {
- BindingStorePlacementNode bspn = (BindingStorePlacementNode) n;
+ StoreLocalVarPlacementNode bspn = (StoreLocalVarPlacementNode) n;
if (mightRequireGlobalEnsureBlock && !cfg.bbIsProtected(bspn.getBB())) {
bspn.addStoreAndBindingAllocInstructions(varRenameMap, dirtyVars);
} else {
@@ -83,7 +83,7 @@ public void addStoreAndBindingAllocInstructions(Map<Operand, Operand> varRenameM
value = cfgScope.getNewTemporaryVariable("%t_" + v.getName());
varRenameMap.put(v, value);
}
- geb.addInstr(new StoreToBindingInstr(value, (IRClosure) cfgScope, v));
+ geb.addInstr(new StoreLocalVarInstr(value, (IRClosure) cfgScope, v));
}
geb.addInstr(new ThrowExceptionInstr(exc));
cfg.addGlobalEnsureBlock(geb);
View
8 ...g/jruby/ir/instructions/LoadFromBindingInstr.java → src/org/jruby/ir/instructions/LoadLocalVarInstr.java
@@ -13,7 +13,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
-public class LoadFromBindingInstr extends Instr implements ResultInstr {
+public class LoadLocalVarInstr extends Instr implements ResultInstr {
private IRScope scope;
private TemporaryVariable result;
@@ -22,10 +22,10 @@
* its (a) name (b) offset (c) scope-depth. */
private LocalVariable lvar;
- public LoadFromBindingInstr(IRScope scope, TemporaryVariable result, LocalVariable lvar) {
+ public LoadLocalVarInstr(IRScope scope, TemporaryVariable result, LocalVariable lvar) {
super(Operation.BINDING_LOAD);
- assert result != null: "LoadFromBindingInstr result is null";
+ assert result != null: "LoadLocalVarInstr result is null";
this.lvar = lvar;
this.result = result;
@@ -51,7 +51,7 @@ public String toString() {
@Override
public Instr cloneForInlining(InlinerInfo ii) {
// SSS FIXME: Do we need to rename lvar really? It is just a name-proxy!
- return new LoadFromBindingInstr(scope, (TemporaryVariable)ii.getRenamedVariable(result), (LocalVariable)ii.getRenamedVariable(lvar));
+ return new LoadLocalVarInstr(scope, (TemporaryVariable)ii.getRenamedVariable(result), (LocalVariable)ii.getRenamedVariable(lvar));
}
@Interp
View
6 ...rg/jruby/ir/instructions/StoreToBindingInstr.java → ...org/jruby/ir/instructions/StoreLocalVarInstr.java
@@ -12,7 +12,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
-public class StoreToBindingInstr extends Instr {
+public class StoreLocalVarInstr extends Instr {
private IRScope scope;
private Operand value;
@@ -21,7 +21,7 @@
* its (a) name (b) offset (c) scope-depth. */
private LocalVariable lvar;
- public StoreToBindingInstr(Operand value, IRScope scope, LocalVariable lvar) {
+ public StoreLocalVarInstr(Operand value, IRScope scope, LocalVariable lvar) {
super(Operation.BINDING_STORE);
this.lvar = lvar;
@@ -46,7 +46,7 @@ public String toString() {
@Override
public Instr cloneForInlining(InlinerInfo ii) {
// SSS FIXME: Do we need to rename lvar really? It is just a name-proxy!
- return new StoreToBindingInstr(value.cloneForInlining(ii), scope, (LocalVariable)lvar.cloneForInlining(ii));
+ return new StoreLocalVarInstr(value.cloneForInlining(ii), scope, (LocalVariable)lvar.cloneForInlining(ii));
}
@Override
View
14 src/org/jruby/ir/passes/AddBindingInstructions.java → ...y/ir/passes/AddLocalVarLoadStoreInstructions.java
@@ -6,17 +6,17 @@
import org.jruby.ir.IRClosure;
import org.jruby.ir.IRMethod;
import org.jruby.ir.IRScope;
-import org.jruby.ir.dataflow.analyses.BindingLoadPlacementProblem;
-import org.jruby.ir.dataflow.analyses.BindingStorePlacementProblem;
+import org.jruby.ir.dataflow.analyses.LoadLocalVarPlacementProblem;
+import org.jruby.ir.dataflow.analyses.StoreLocalVarPlacementProblem;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.representations.BasicBlock;
-public class AddBindingInstructions extends CompilerPass {
- public static String[] NAMES = new String[] { "add_binding", "add_binding_instructions" };
+public class AddLocalVarLoadStoreInstructions extends CompilerPass {
+ public static String[] NAMES = new String[] { "add_lvar_load_store", "add_local_var_load_store_instructions" };
public String getLabel() {
- return "Add Binding Instructions";
+ return "Add Local Variable Load/Store Instructions";
}
public boolean isPreOrder() {
@@ -26,11 +26,11 @@ public boolean isPreOrder() {
public Object execute(IRScope s, Object... data) {
// if (s.requiresBinding()) {
- BindingStorePlacementProblem fsp = new BindingStorePlacementProblem();
+ StoreLocalVarPlacementProblem fsp = new StoreLocalVarPlacementProblem();
fsp.setup(s);
fsp.compute_MOP_Solution();
- BindingLoadPlacementProblem frp = new BindingLoadPlacementProblem();
+ LoadLocalVarPlacementProblem frp = new LoadLocalVarPlacementProblem();
frp.setup(s);
frp.compute_MOP_Solution();
Please sign in to comment.
Something went wrong with that request. Please try again.