Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8efce53e4047
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8a84610c5184
Choose a head ref
  • 2 commits
  • 10 files changed
  • 1 contributor

Commits on Jan 5, 2015

  1. Copy the full SHA
    7623840 View commit details
  2. Copy the full SHA
    8a84610 View commit details
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/IRMethod.java
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
import org.jruby.ir.operands.Symbol;
import org.jruby.ir.operands.Hash;
import org.jruby.ir.operands.Splat;
import org.jruby.ir.representations.BasicBlock;
import org.jruby.util.KeyValuePair;
import org.jruby.parser.StaticScope;

@@ -74,6 +75,12 @@ public synchronized InterpreterContext prepareForInterpretation() {
return super.prepareForInterpretation();
}

public synchronized List<BasicBlock> prepareForCompilation() {
if (defn != null) prepareForInterpretation();

return super.prepareForCompilation();
}

@Override
public IRScopeType getScopeType() {
return isInstanceMethod ? IRScopeType.INSTANCE_METHOD : IRScopeType.CLASS_METHOD;
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ public Instr clone(CloneInfo ii) {

@Override
public String toString() {
return (hasUnusedResult() ? "[DEAD-RESULT]" : "") + result + " = " + super.toString();
return "" + result + " = " + super.toString();
}

@Override
11 changes: 1 addition & 10 deletions core/src/main/java/org/jruby/ir/instructions/Instr.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@ public abstract class Instr {
// causes no side-effects and the result of the instruction is not needed by anyone else,
// we can remove this instruction altogether without affecting program correctness.
private boolean isDead;
private boolean hasUnusedResult;

public Instr(Operation operation) {
this.ipc = -1;
@@ -50,7 +49,7 @@ public Instr(Operation operation) {

@Override
public String toString() {
return "" + (isDead() ? "[DEAD]" : "") + (hasUnusedResult ? "[DEAD-RESULT]" : "") + ((this instanceof ResultInstr) ? ((ResultInstr)this).getResult() + " = " : "") + operation;
return "" + (isDead() ? "[DEAD]" : "") + ((this instanceof ResultInstr) ? ((ResultInstr)this).getResult() + " = " : "") + operation;
}

@Interp
@@ -121,14 +120,6 @@ public boolean isDead() {
return isDead;
}

public void markUnusedResult() {
hasUnusedResult = true;
}

public boolean hasUnusedResult() {
return hasUnusedResult;
}

/* Array of all operands for this instruction */
@Interp
public abstract Operand[] getOperands();
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public Variable getResult() {

@Override
public String toString() {
return (isDead() ? "[DEAD]" : "") + (hasUnusedResult() ? "[DEAD-RESULT]" : "") + getResult() + " = " + getOperation();
return (isDead() ? "[DEAD]" : "") + getResult() + " = " + getOperation();
}

@Override
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public Operand[] getOperands() {

@Override
public String toString() {
return (isDead() ? "[DEAD]" : "") + (hasUnusedResult() ? "[DEAD-RESULT]" : "") + getResult() + " = " + getOperation() + "(" + required + ", " + argName + ")";
return (isDead() ? "[DEAD]" : "") + getResult() + " = " + getOperation() + "(" + required + ", " + argName + ")";
}

@Override
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public Operand[] getOperands() {

@Override
public String toString() {
return (isDead() ? "[DEAD]" : "") + (hasUnusedResult() ? "[DEAD-RESULT]" : "") + getResult() + " = " + getOperation() + "(" + required + ")";
return (isDead() ? "[DEAD]" : "") + getResult() + " = " + getOperation() + "(" + required + ")";
}

@Override
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public Operand[] getOperands() {

@Override
public String toString() {
return (isDead() ? "[DEAD]" : "") + (hasUnusedResult() ? "[DEAD-RESULT]" : "") + getResult() + " = " + getOperation() + "(" + requiredArgs + "," + preArgs + "," + argIndex + ")";
return (isDead() ? "[DEAD]" : "") + getResult() + " = " + getOperation() + "(" + requiredArgs + "," + preArgs + "," + argIndex + ")";
}

public int getPreArgs() {
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ public Operand[] getOperands() {

@Override
public String toString() {
return (isDead() ? "[DEAD]" : "") + (hasUnusedResult() ? "[DEAD-RESULT]" : "") + getResult() + " = " + getOperation() + "(" + argIndex + ", " + preReqdArgsCount + ", " + postReqdArgsCount + ")";
return (isDead() ? "[DEAD]" : "") + getResult() + " = " + getOperation() + "(" + argIndex + ", " + preReqdArgsCount + ", " + postReqdArgsCount + ")";
}

@Override
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ public ReceiveRestArgInstr(Variable result, int required, int argIndex) {

@Override
public String toString() {
return (isDead() ? "[DEAD]" : "") + (hasUnusedResult() ? "[DEAD-RESULT]" : "") + getResult() + " = " + getOperation() + "(" + required + ", " + argIndex + ")";
return (isDead() ? "[DEAD]" : "") + getResult() + " = " + getOperation() + "(" + required + ", " + argIndex + ")";
}

@Override
Original file line number Diff line number Diff line change
@@ -101,8 +101,11 @@ private static void optimizeTmpVars(IRScope s) {
instrs.remove();
} else if (i instanceof CallInstr) {
instrs.set(((CallInstr)i).discardResult());
} else {
i.markUnusedResult();
//} else {
// FIXME: This was not being used and is not for calls specifically so we were unsure how much it would help
// but it is left here. For some instrs which assign the result to a tempvar but we notice it is not used
// we can eliminate setting the result. In pratice this seems to mostly happen in module bodies.
// i.markUnusedResult();
}
}
// Deal with this code pattern: