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: 746f24f9858f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e70076db9842
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Aug 5, 2015

  1. Copy the full SHA
    2450edb View commit details
  2. Remove fully-qualified name.

    headius committed Aug 5, 2015
    Copy the full SHA
    22536cd View commit details
  3. Copy the full SHA
    e70076d View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRMethod.java
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ public LocalVariable getLocalVariable(String name, int scopeDepth) {
}

public void addNativeSignature(int arity, MethodType signature) {
if (signatures == null) signatures = new HashMap<>();
if (signatures == null) signatures = new HashMap<>(1);
signatures.put(arity, signature);
}

22 changes: 11 additions & 11 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ protected IRScope(IRScope s, IRScope lexicalParent) {
this.nextClosureIndex = s.nextClosureIndex;
this.temporaryVariableIndex = s.temporaryVariableIndex;
this.floatVariableIndex = s.floatVariableIndex;
this.nextVarIndex = new HashMap<>(); // SSS FIXME: clone!
this.nextVarIndex = new HashMap<>(1); // SSS FIXME: clone!
this.interpreterContext = null;

this.flagsComputed = s.flagsComputed;
@@ -166,7 +166,7 @@ public IRScope(IRManager manager, IRScope lexicalParent, String name,
this.nextClosureIndex = 0;
this.temporaryVariableIndex = -1;
this.floatVariableIndex = -1;
this.nextVarIndex = new HashMap<>();
this.nextVarIndex = new HashMap<>(1);
this.interpreterContext = null;
this.flagsComputed = false;
flags.remove(CAN_RECEIVE_BREAKS);
@@ -190,7 +190,7 @@ public IRScope(IRManager manager, IRScope lexicalParent, String name,
// 'module X; class B; using A; end; end'. First case B can see refinements and in second it cannot.
if (parentMaybeUsingRefinements()) flags.add(MAYBE_USING_REFINEMENTS);

this.localVars = new HashMap<>();
this.localVars = new HashMap<>(1);
this.scopeId = globalScopeCount.getAndIncrement();

setupLexicalContainment();
@@ -199,7 +199,7 @@ public IRScope(IRManager manager, IRScope lexicalParent, String name,

private void setupLexicalContainment() {
if (manager.isDryRun() || RubyInstanceConfig.IR_WRITING) {
lexicalChildren = new ArrayList<>();
lexicalChildren = new ArrayList<>(1);
if (lexicalParent != null) lexicalParent.addChildScope(this);
}
}
@@ -223,17 +223,17 @@ public boolean equals(Object other) {
}

protected void addChildScope(IRScope scope) {
if (lexicalChildren == null) lexicalChildren = new ArrayList<>();
if (lexicalChildren == null) lexicalChildren = new ArrayList<>(1);
lexicalChildren.add(scope);
}

public List<IRScope> getLexicalScopes() {
if (lexicalChildren == null) lexicalChildren = new ArrayList<>();
if (lexicalChildren == null) lexicalChildren = new ArrayList<>(1);
return lexicalChildren;
}

public void addClosure(IRClosure closure) {
if (nestedClosures == null) nestedClosures = new ArrayList<>();
if (nestedClosures == null) nestedClosures = new ArrayList<>(1);
nestedClosures.add(closure);
}

@@ -487,7 +487,7 @@ protected boolean isUnsafeScope() {

public List<CompilerPass> getExecutedPasses() {
// FIXME: Super annoying...because OptimizeTempVars is a pre-CFG pass we have no full build info yet
return fullInterpreterContext == null ? new ArrayList<CompilerPass>() : fullInterpreterContext.getExecutedPasses();
return fullInterpreterContext == null ? new ArrayList<CompilerPass>(1) : fullInterpreterContext.getExecutedPasses();
}

// SSS FIXME: We should configure different optimization levels
@@ -589,7 +589,7 @@ public synchronized BasicBlock[] prepareForInitialCompilation() {
// construct a new fullInterpreterContext. Primary obstacles is JITFlags and linearization of BBs.

public Map<BasicBlock, Label> buildJVMExceptionTable() {
Map<BasicBlock, Label> map = new HashMap<>();
Map<BasicBlock, Label> map = new HashMap<>(1);

for (BasicBlock bb: fullInterpreterContext.getLinearizedBBList()) {
BasicBlock rescueBB = getCFG().getRescuerBBFor(bb);
@@ -931,8 +931,8 @@ public int getUsedVariablesCount() {
}

public void setUpUseDefLocalVarMaps() {
definedLocalVars = new java.util.HashSet<>();
usedLocalVars = new java.util.HashSet<>();
definedLocalVars = new HashSet<>(1);
usedLocalVars = new HashSet<>(1);
for (BasicBlock bb : getCFG().getBasicBlocks()) {
for (Instr i : bb.getInstrs()) {
for (Variable v : i.getUsedVariables()) {
25 changes: 17 additions & 8 deletions core/src/main/java/org/jruby/ir/instructions/Instr.java
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.LocalVariable;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.OperandType;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
@@ -37,7 +38,15 @@ public abstract class Instr {

private int ipc; // Interpreter-only: instruction pointer
private int rpc; // Interpreter-only: rescue pointer
private final Operation operation;

// Packed ordinal of Operation enum
private final byte operation;

// Ensure we never exceed 8 bits worth of Operation values
static {
if (Operation.values().length > 255) throw new RuntimeException("Operation count exceeds packed field width");
}

// Is this instruction live or dead? During optimization passes, if this instruction
// 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.
@@ -46,7 +55,7 @@ public abstract class Instr {
public Instr(Operation operation) {
this.ipc = -1;
this.rpc = -1;
this.operation = operation;
this.operation = (byte)operation.ordinal();
}

private static String[] EMPTY_STRINGS = new String[0];
@@ -75,7 +84,7 @@ public String toString() {

Operand[] operands = getOperands();

buf.append(operation).append('(');
buf.append(getOperation()).append('(');
toArgList(buf, operands);

String[] extraArgs = toStringNonOperandArgs();
@@ -102,7 +111,7 @@ private StringBuilder toArgList(StringBuilder buf, Object[] args) {

@Interp
public Operation getOperation() {
return operation;
return Operation.values()[operation & 0xFF];
}

@Interp
@@ -121,17 +130,17 @@ public Operation getOperation() {
// This information is used in optimization phases to impact dead code elimination
// and other optimization passes
public boolean hasSideEffects() {
return operation.hasSideEffects();
return getOperation().hasSideEffects();
}

// Can this instruction raise exceptions -- this superclass method has to be conservative and cannot affect program correctness.
public boolean canRaiseException() {
return operation.canRaiseException();
return getOperation().canRaiseException();
}

// Can this instruction raise exceptions -- this superclass method has to be conservative and cannot affect program correctness.
public boolean transfersControl() {
return operation.transfersControl();
return getOperation().transfersControl();
}

/**
@@ -148,7 +157,7 @@ public boolean computeScopeFlags(IRScope scope) {
* during DCE for other reasons (like if it unconditionally has a side-effect)
*/
public boolean isDeletable() {
return !(hasSideEffects() || operation.isDebugOp() || canRaiseException() || transfersControl());
return !(hasSideEffects() || getOperation().isDebugOp() || canRaiseException() || transfersControl());
}

public boolean canBeDeletedFromScope(IRScope s) {
13 changes: 10 additions & 3 deletions core/src/main/java/org/jruby/ir/operands/Operand.java
Original file line number Diff line number Diff line change
@@ -14,14 +14,21 @@

public abstract class Operand {
public static final Operand[] EMPTY_ARRAY = new Operand[0];
private final OperandType type;

// Packed ordinal of OperandType enum
private final byte type;

// Ensure we never exceed 8 bits worth of OperandType values
static {
if (OperandType.values().length > 255) throw new RuntimeException("OperandType count exceeds packed field width");
}

public Operand(OperandType type) {
this.type = type;
this.type = (byte)type.ordinal();
}

public final OperandType getOperandType() {
return type;
return OperandType.values()[type & 0xFF];
}

/**