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

Commits on Mar 10, 2015

  1. Copy the full SHA
    9a42332 View commit details
  2. ir.compiler.debug will not log irbuild interp lists. Remove nested cl…

    …osures for logging to de-noise output.
    enebo committed Mar 10, 2015
    Copy the full SHA
    dc71ebe View commit details
16 changes: 6 additions & 10 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import org.jruby.ir.operands.Float;
import org.jruby.ir.operands.Boolean;
import org.jruby.ir.passes.*;
import org.jruby.ir.persistence.IRReaderDecoder;
import org.jruby.ir.representations.BasicBlock;
import org.jruby.ir.representations.CFG;
import org.jruby.ir.transformations.inlining.CFGInliner;
@@ -22,6 +21,8 @@

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;

import static org.jruby.ir.IRFlags.*;

@@ -55,6 +56,8 @@
* and so on ...
*/
public abstract class IRScope implements ParseResult {
public static final Logger LOG = LoggerFactory.getLogger("IRScope");

private static final Collection<IRClosure> NO_CLOSURES = Collections.unmodifiableCollection(new ArrayList<IRClosure>(0));

private static AtomicInteger globalScopeCount = new AtomicInteger();
@@ -107,9 +110,6 @@ public abstract class IRScope implements ParseResult {
/** Keeps track of types of prefix indexes for variables and labels */
private Map<String, Integer> nextVarIndex;

// FIXME: Persistence is completely disconnected for now
//private int instructionsOffsetInfoPersistenceBuffer = -1;
//private IRReaderDecoder persistenceStore = null;
private TemporaryLocalVariable currentModuleVariable;
private TemporaryLocalVariable currentScopeVariable;

@@ -506,6 +506,8 @@ private void runCompilerPasses(List<CompilerPass> passes) {
public InterpreterContext allocateInterpreterContext(List<Instr> instructions) {
interpreterContext = new InterpreterContext(this, instructions);

if (RubyInstanceConfig.IR_COMPILER_DEBUG) LOG.info("" + interpreterContext);

return interpreterContext;
}

@@ -1093,10 +1095,4 @@ public boolean isTopLocalVariableScope() {
public boolean isScriptScope() {
return false;
}

public void savePersistenceInfo(int offset, IRReaderDecoder file) {
// FIXME: Persistence is disconnected for now.
// instructionsOffsetInfoPersistenceBuffer = offset;
// persistenceStore = file;
}
}
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ public Operand getArg1() {
@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArg1());
e.encode(getJumpTarget());
e.encode(getArg1());
}
}
Original file line number Diff line number Diff line change
@@ -169,17 +169,12 @@ public String toString() {
StringBuilder buf = new StringBuilder();

buf.append(getFileName()).append(':').append(scope.getLineNumber());
if (getName() != null) buf.append(' ').append(getName());
if (getName() != null) buf.append(' ').append(getName()).append("\n");

if (instructions == null) {
buf.append("No Instructions. Full Build before linearizeInstr?");
buf.append(" No Instructions. Full Build before linearizeInstr?");
} else {
int i = 0;
for (Instr instr : instructions) {
if (i > 0) buf.append("\n");
buf.append(" ").append(i).append('\t').append(instr);
i++;
}
buf.append(toStringInstrs()).append("\n");
}

return buf.toString();
@@ -194,13 +189,14 @@ public String toStringInstrs() {
b.append(" ").append(i).append('\t').append(instructions[i]);
}

/* ENEBO: I this this is too much output espectially for ic and not fic
Collection<IRClosure> nestedClosures = scope.getClosures();
if (nestedClosures != null && !nestedClosures.isEmpty()) {
b.append("\n\n------ Closures encountered in this scope ------\n");
for (IRClosure c: nestedClosures)
b.append(c.toStringBody());
b.append("------------------------------------------------\n");
}
}*/

return b.toString();
}
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/persistence/IRReader.java
Original file line number Diff line number Diff line change
@@ -79,7 +79,8 @@ private static IRScope decodeScopeHeader(IRManager manager, IRReaderDecoder deco

decoder.addScope(scope);

scope.savePersistenceInfo(decoder.decodeInt(), decoder);
int instructionsOffset = decoder.decodeInt();
decoder.decodeInstructionsAt(scope, instructionsOffset);

return scope;
}
28 changes: 24 additions & 4 deletions core/src/main/java/org/jruby/ir/persistence/InstrDecoderMap.java
Original file line number Diff line number Diff line change
@@ -7,8 +7,10 @@
import org.jruby.ir.instructions.defined.GetErrorInfoInstr;
import org.jruby.ir.instructions.defined.RestoreErrorInfoInstr;
import org.jruby.ir.operands.*;
import org.jruby.ir.persistence.read.parser.NonIRObjectFactory;
import org.jruby.lexer.yacc.SimpleSourcePosition;
import org.jruby.runtime.CallType;
import org.jruby.util.RegexpOptions;

/**
*
@@ -53,10 +55,10 @@ public Instr decodeInner(Operation operation) {
case CHECK_ARITY: return new CheckArityInstr(d.decodeInt(), d.decodeInt(), d.decodeInt(), d.decodeBoolean(), d.decodeInt());
case CLASS_VAR_MODULE: return new GetClassVarContainerModuleInstr(d.decodeVariable(), d.decodeOperand(), d.decodeVariable());
case CONST_MISSING: return decodeConstMissingInstr();
// SSS FIXME: TODO
// case BUILD_COMPOUND_INSTR: return decodeBuildCompoundStringInstr();
// case BUILD_DREGEXP: return decodeBuildDynRegExpInstr();
// case BUILD_RANGE: return new Range(d.decodeOperand(), d.decodeOperand(), d.decodeBoolean());
case BUILD_COMPOUND_ARRAY: return new BuildCompoundArrayInstr(d.decodeVariable(), d.decodeOperand(), d.decodeOperand(), d.decodeBoolean());
case BUILD_COMPOUND_STRING: return decodeBuildCompoundStringInstr();
case BUILD_DREGEXP: return decodeBuildDynRegExpInstr();
case BUILD_RANGE: return new BuildRangeInstr(d.decodeVariable(), d.decodeOperand(), d.decodeOperand(), d.decodeBoolean());
case COPY: return decodeCopy();
case DEF_CLASS: return new DefineClassInstr((d.decodeVariable()), (IRClassBody) d.decodeScope(), d.decodeOperand(), d.decodeOperand());
case DEF_CLASS_METH: return new DefineClassMethodInstr(d.decodeOperand(), (IRMethod) d.decodeScope());
@@ -78,6 +80,8 @@ public Instr decodeInner(Operation operation) {
case LABEL: return new LabelInstr((Label) d.decodeOperand());
case LAMBDA: return decodeLambda();
case LEXICAL_SEARCH_CONST: return new LexicalSearchConstInstr(d.decodeVariable(), d.decodeOperand(), d.decodeString());
case LOAD_FRAME_CLOSURE: return new LoadFrameClosureInstr(d.decodeVariable());
case LOAD_IMPLICIT_CLOSURE: return new LoadImplicitClosureInstr(d.decodeVariable());
case LINE_NUM: return decodeLineNumber();
case MASGN_OPT: return new OptArgMultipleAsgnInstr(d.decodeVariable(), d.decodeOperand(), d.decodeInt(), d.decodeInt());
case MASGN_REQD: return new ReqdArgMultipleAsgnInstr(d.decodeVariable(), d.decodeOperand(), d.decodeInt(), d.decodeInt(), d.decodeInt());
@@ -142,6 +146,22 @@ private Instr decodeAttrAssignInstr() {
return AttrAssignInstr.create(op, methAddr, args);
}

private Instr decodeBuildCompoundStringInstr() {
Variable result = d.decodeVariable();
Operand[] pieces = d.decodeOperandArray();
Encoding encoding = NonIRObjectFactory.createEncoding(d.decodeString());

return new BuildCompoundStringInstr(result, pieces, encoding);
}

private Instr decodeBuildDynRegExpInstr() {
Variable result = d.decodeVariable();
Operand[] pieces = d.decodeOperandArray();
int embeddedOptions = d.decodeInt();

return new BuildDynRegExpInstr(result, pieces, RegexpOptions.fromEmbeddedOptions(embeddedOptions));
}

private Instr decodeCall() {
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding call");
Variable result = d.decodeVariable();