Skip to content

Commit

Permalink
Showing 144 changed files with 840 additions and 840 deletions.
7 changes: 3 additions & 4 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -13,8 +13,7 @@
import org.jruby.ir.operands.*;
import org.jruby.ir.operands.Boolean;
import org.jruby.ir.operands.Float;
import org.jruby.ir.transformations.inlining.CloneMode;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
import org.jruby.runtime.CallType;
@@ -221,7 +220,7 @@ public void emitBody(IRBuilder b, IRScope s) {
}

public void cloneIntoHostScope(IRBuilder b, IRScope s) {
InlinerInfo ii = new InlinerInfo(null, s, CloneMode.ENSURE_BLOCK_CLONE);
SimpleCloneInfo ii = new SimpleCloneInfo(s, true);

// Clone required labels.
// During normal cloning below, labels not found in the rename map
@@ -237,7 +236,7 @@ public void cloneIntoHostScope(IRBuilder b, IRScope s) {
b.addInstr(s, new LabelInstr(ii.getRenamedLabel(start)));
b.addInstr(s, new ExceptionRegionStartMarkerInstr(bodyRescuer));
for (Instr i: instrs) {
Instr clonedInstr = i.cloneForInlining(ii);
Instr clonedInstr = i.clone(ii);
if (clonedInstr instanceof CallBase) {
CallBase call = (CallBase)clonedInstr;
Operand block = call.getClosureArg(null);
34 changes: 21 additions & 13 deletions core/src/main/java/org/jruby/ir/IRClosure.java
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
import org.jruby.ir.operands.*;
import org.jruby.ir.representations.BasicBlock;
import org.jruby.ir.representations.CFG;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
import org.jruby.runtime.BlockBody;
@@ -61,10 +62,11 @@ protected IRClosure(IRManager manager, IRScope lexicalParent, String fileName, i
}

/** Used by cloning code */
protected IRClosure(IRClosure c, IRScope lexicalParent, String prefix) {
/* Inlining generates a new name and id and basic cloning will reuse the originals name */
protected IRClosure(IRClosure c, IRScope lexicalParent, int closureId, String fullName) {
super(c, lexicalParent);
this.closureId = lexicalParent.getNextClosureId();
setName(prefix + closureId);
this.closureId = closureId;
super.setName(fullName);
this.startLabel = getNewLabel(getName() + "_START");
this.endLabel = getNewLabel(getName() + "_END");
if (getManager().isDryRun()) {
@@ -281,12 +283,11 @@ public int getNestingDepth() {
return nestingDepth;
}

protected IRClosure cloneForInlining(InlinerInfo ii, IRClosure clone) {
protected IRClosure cloneForInlining(CloneInfo ii, IRClosure clone) {
clone.nestingDepth = this.nestingDepth;
clone.parameterList = this.parameterList;

// Create a new inliner info object
InlinerInfo clonedII = ii.cloneForCloningClosure(clone);
SimpleCloneInfo clonedII = ii.cloneForCloningClosure(clone);

if (getCFG() != null) {
// Clone the cfg
@@ -296,7 +297,7 @@ protected IRClosure cloneForInlining(InlinerInfo ii, IRClosure clone) {
} else {
// Clone the instruction list
for (Instr i: getInstrs()) {
Instr clonedInstr = i.cloneForInlining(clonedII);
Instr clonedInstr = i.clone(clonedII);
if (clonedInstr instanceof CallBase) {
CallBase call = (CallBase)clonedInstr;
Operand block = call.getClosureArg(null);
@@ -309,9 +310,17 @@ protected IRClosure cloneForInlining(InlinerInfo ii, IRClosure clone) {
return clone;
}

public IRClosure cloneForInlining(InlinerInfo ii) {
// FIXME: This is buggy! Is this not dependent on clone-mode??
IRClosure clonedClosure = new IRClosure(this, ii.getNewLexicalParentForClosure(), "_CLOSURE_CLONE_");
public IRClosure cloneForInlining(CloneInfo ii) {
IRClosure clonedClosure;
IRScope lexicalParent = ii.getScope();

if (ii instanceof SimpleCloneInfo) {
clonedClosure = new IRClosure(this, lexicalParent, closureId, getName());
} else {
int id = lexicalParent.getNextClosureId();
String fullName = lexicalParent.getName() + "_CLOSURE_CLONE_" + id;
clonedClosure = new IRClosure(this, lexicalParent, id, fullName);
}

return cloneForInlining(ii, clonedClosure);
}
@@ -361,8 +370,7 @@ protected boolean addGEBForUncaughtBreaks() {
@Override
public void setName(String name) {
// We can distinguish closures only with parent scope name
String fullName = getLexicalParent().getName() + name;
super.setName(fullName);
super.setName(getLexicalParent().getName() + name);
}

public Arity getArity() {
22 changes: 16 additions & 6 deletions core/src/main/java/org/jruby/ir/IRFor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir;

import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.parser.StaticScopeFactory;
import org.jruby.runtime.Arity;
@@ -18,8 +19,8 @@ public IRFor(IRManager manager, IRScope lexicalParent, int lineNumber, StaticSco
}

/** Used by cloning code */
private IRFor(IRClosure c, IRScope lexicalParent) {
super(c, lexicalParent, "_FOR_LOOP_CLONE_");
private IRFor(IRClosure c, IRScope lexicalParent, int id, String fullName) {
super(c, lexicalParent, id, fullName);
}

@Override
@@ -28,9 +29,18 @@ public IRScopeType getScopeType() {
}

@Override
public IRClosure cloneForInlining(InlinerInfo ii) {
// FIXME: This is buggy! Is this not dependent on clone-mode??
IRClosure clonedClosure = new IRFor(this, ii.getNewLexicalParentForClosure());
public IRClosure cloneForInlining(CloneInfo ii) {
IRClosure clonedClosure;
IRScope lexicalParent = ii.getScope();

if (ii instanceof SimpleCloneInfo) {
clonedClosure = new IRFor(this, lexicalParent, closureId, getName());
} else {
int id = lexicalParent.getNextClosureId();
String fullName = lexicalParent.getName() + "_FOR_LOOP_CLONE_" + id;
clonedClosure = new IRFor(this, lexicalParent, id, fullName);
}

return cloneForInlining(ii, clonedClosure);
}
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -49,7 +49,7 @@ public void simplifyOperands(Map<Operand, Operand> valueMap, boolean force) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new AliasInstr(getNewName().cloneForInlining(ii), getOldName().cloneForInlining(ii));
}

Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -35,7 +35,7 @@ public void updateResult(Variable v) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new ArgScopeDepthInstr(ii.getRenamedVariable(result));
}

Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
import org.jruby.ir.instructions.specialized.OneArgOperandAttrAssignInstr;
import org.jruby.ir.operands.MethAddr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.*;
import org.jruby.runtime.builtin.IRubyObject;
@@ -22,7 +22,7 @@ public AttrAssignInstr(AttrAssignInstr instr) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new AttrAssignInstr(receiver.cloneForInlining(ii),
(MethAddr)getMethodAddr().cloneForInlining(ii), cloneCallArgs(ii));
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/BEQInstr.java
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Boolean;
import org.jruby.ir.operands.*;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -25,7 +25,7 @@ protected BEQInstr(Operand v1, Operand v2, Label jmpTarget) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new BEQInstr(getArg1().cloneForInlining(ii), getArg2().cloneForInlining(ii), ii.getRenamedLabel(getJumpTarget()));
}

4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/BFalseInstr.java
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -21,7 +21,7 @@ public BFalseInstr(Operand v, Label jmpTarget) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new BFalseInstr(getOperation(), getArg1().cloneForInlining(ii), ii.getRenamedLabel(getJumpTarget()));
}

4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/BNEInstr.java
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -25,7 +25,7 @@ public BNEInstr(Operand v1, Operand v2, Label jmpTarget) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new BNEInstr(getArg1().cloneForInlining(ii),
getArg2().cloneForInlining(ii), ii.getRenamedLabel(getJumpTarget()));
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/BNilInstr.java
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -16,7 +16,7 @@ public BNilInstr(Operand v, Label jmpTarget) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new BNilInstr(getArg1().cloneForInlining(ii), ii.getRenamedLabel(getJumpTarget()));
}

4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/BTrueInstr.java
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -20,7 +20,7 @@ public BTrueInstr(Operand v, Label jmpTarget) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new BTrueInstr(getOperation(), getArg1().cloneForInlining(ii), ii.getRenamedLabel(getJumpTarget()));
}

4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/BUndefInstr.java
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -17,7 +17,7 @@ public BUndefInstr(Operand v, Label jmpTarget) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new BUndefInstr(getArg1().cloneForInlining(ii), ii.getRenamedLabel(getJumpTarget()));
}

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -68,7 +68,7 @@ public void simplifyOperands(Map<Operand, Operand> valueMap, boolean force) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
List<Operand> newPieces = new ArrayList<Operand>();
for (Operand p : pieces) {
newPieces.add(p.cloneForInlining(ii));
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -51,7 +51,7 @@ public void updateResult(Variable v) {
}

@Override
public Instr cloneForInlining(InlinerInfo ii) {
public Instr clone(CloneInfo ii) {
return new BlockGivenInstr(ii.getRenamedVariable(result), blockArg.cloneForInlining(ii));
}

Loading

0 comments on commit 94eb4ae

Please sign in to comment.