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: 5387c347acd3
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9a4dcb28bec5
Choose a head ref
  • 2 commits
  • 10 files changed
  • 1 contributor

Commits on Jun 18, 2015

  1. Remove name as a field in Temporary Variable.

    This saves about 80k on an empty rails app but it also saves a little work for execution
    since we only use name for debugging purposes.
    enebo committed Jun 18, 2015
    Copy the full SHA
    277205a View commit details
  2. Make a single ReceiveSelfInstr instance.

    We already have a single %self variable and so there really is no different state here.
    This saves 350k on an empty Rails app.
    enebo committed Jun 18, 2015
    Copy the full SHA
    9a4dcb2 View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1913,7 +1913,7 @@ protected void receiveBlockArg(final ArgsNode argsNode) {
*/
private void prepareImplicitState() {
// Receive self
addInstr(new ReceiveSelfInstr(buildSelf()));
addInstr(manager.getReceiveSelfInstr());

// used for yields; metaclass body (sclass) inherits yield var from surrounding, and accesses it as implicit
if (scope instanceof IRMethod || scope instanceof IRMetaClassBody) {
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/IRManager.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.RubyInstanceConfig;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.instructions.LineNumberInstr;
import org.jruby.ir.instructions.ReceiveSelfInstr;
import org.jruby.ir.listeners.IRScopeListener;
import org.jruby.ir.listeners.InstructionsListener;
import org.jruby.ir.operands.*;
@@ -194,6 +195,12 @@ public LineNumberInstr newLineNumber(int line) {

}

private ReceiveSelfInstr receiveSelfInstr = new ReceiveSelfInstr(Self.SELF);

public ReceiveSelfInstr getReceiveSelfInstr() {
return receiveSelfInstr;
}

private LineNumberInstr[] lineNumbers = new LineNumberInstr[3000];

protected LineNumberInstr[] growLineNumbersPool(int index) {
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRReaderDecoder;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;

@@ -24,8 +25,13 @@ public Instr clone(CloneInfo info) {
return null;
}

@Override
public void encode(IRWriterEncoder e) {
e.encode(getOperation());
}

public static ReceiveSelfInstr decode(IRReaderDecoder d) {
return new ReceiveSelfInstr(d.decodeVariable());
return d.getCurrentScope().getManager().getReceiveSelfInstr();
}

@Override
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
public class TemporaryBooleanVariable extends TemporaryLocalVariable {
public static final String PREFIX = "%b_";
public TemporaryBooleanVariable(int offset) {
super(PREFIX+offset, offset);
super(offset);
}

@Override
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ public class TemporaryClosureVariable extends TemporaryLocalVariable {
private final int closureId;

public TemporaryClosureVariable(int closureId, int offset) {
super("%cl_" + closureId + "_" + offset, offset);
super(offset); // Do not save name to prevent constructing string

this.closureId = closureId;
}
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
public class TemporaryFixnumVariable extends TemporaryLocalVariable {
public static final String PREFIX = "%i_";
public TemporaryFixnumVariable(int offset) {
super(PREFIX+offset, offset);
super(offset);
}

@Override
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
public class TemporaryFloatVariable extends TemporaryLocalVariable {
public static final String PREFIX = "%f_";
public TemporaryFloatVariable(int offset) {
super(PREFIX+offset, offset);
super(offset);
}

@Override
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ public class TemporaryLocalReplacementVariable extends TemporaryLocalVariable im
private final String oldName;

public TemporaryLocalReplacementVariable(String oldName, int offset) {
super(PREFIX + oldName + "_" + offset, offset);
super(offset);

this.oldName = oldName;
}
@@ -24,7 +24,7 @@ public Variable clone(SimpleCloneInfo ii) {

@Override
public String getPrefix() {
return "%t_" + oldName + "_";
return PREFIX + oldName + "_";
}

@Override
Original file line number Diff line number Diff line change
@@ -17,14 +17,14 @@ public class TemporaryLocalVariable extends TemporaryVariable {
public static final String PREFIX = "%v_";
public final int offset;

public TemporaryLocalVariable(String name, int offset) {
super(name);
public TemporaryLocalVariable(int offset) {
super();

this.offset = offset;
}

public TemporaryLocalVariable(int offset) {
this(PREFIX + offset, offset);
public String getName() {
return getPrefix() + offset;
}

public int getOffset() {
11 changes: 3 additions & 8 deletions core/src/main/java/org/jruby/ir/operands/TemporaryVariable.java
Original file line number Diff line number Diff line change
@@ -3,22 +3,17 @@
import org.jruby.ir.IRVisitor;

public abstract class TemporaryVariable extends Variable {
private final String name;

public TemporaryVariable(String name) {
public TemporaryVariable() {
super(OperandType.TEMPORARY_VARIABLE);

this.name = name;
}

/**
* Differentiates between different types of TemporaryVariables (useful for switch and persistence).
*/
public abstract TemporaryVariableType getType();

public String getName() {
return name;
}
public abstract String getName();


@Override
public int hashCode() {