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

Commits on Feb 18, 2015

  1. Added debugOutput method to IRScope

    * Output CFG and instrs OR instrs only depending on whether
      CFG has been built or not.
    
    * Use the new method to emit debug output during interpretation.
    subbuss committed Feb 18, 2015
    Copy the full SHA
    952f539 View commit details
  2. Copy the full SHA
    b4787ab View commit details
Original file line number Diff line number Diff line change
@@ -230,9 +230,7 @@ protected void doDebug() {
ensureInstrsReady();
LOG.info("Executing '" + method.getName() + "'");
if (!displayedCFG) {
CFG cfg = method.getCFG();
LOG.info("Graph:\n" + cfg.toStringGraph());
LOG.info("CFG:\n" + cfg.toStringInstrs());
LOG.info(method.debugOutput());
displayedCFG = true;
}
}
14 changes: 11 additions & 3 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -641,9 +641,7 @@ private void setupLinearization() {
depends(linearization());
} catch (RuntimeException e) {
LOG.error("Error linearizing cfg: ", e);
CFG c = cfg();
LOG.error("\nGraph:\n" + c.toStringGraph());
LOG.error("\nInstructions:\n" + c.toStringInstrs());
LOG.error(this.debugOutput());
throw e;
}
}
@@ -764,6 +762,16 @@ public String toString() {
return getScopeType() + " " + getName() + "[" + getFileName() + ":" + getLineNumber() + "]";
}

public String debugOutput() {
if (this.cfg == null) {
return "Instructions:\n" + this.toStringInstrs();
} else {
return
"\nCFG:\n" + this.cfg.toStringGraph() +
"\nInstructions:\n" + this.cfg.toStringInstrs();
}
}

public String toStringInstrs() {
StringBuilder b = new StringBuilder();

3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
@@ -235,8 +235,7 @@ private static BeginEndInterpreterContext prepareIC(ThreadContext context, Dynam
BeginEndInterpreterContext ic = (BeginEndInterpreterContext) script.prepareForInterpretation();

if (IRRuntimeHelpers.isDebug()) {
LOG.info("Graph:\n" + script.cfg().toStringGraph());
LOG.info("CFG:\n" + script.cfg().toStringInstrs());
LOG.info(script.debugOutput());
}

return ic;
Original file line number Diff line number Diff line change
@@ -161,7 +161,16 @@ public String toString() {
buf.append(fileName).append(':').append(lineNumber);
if (name != null) buf.append(' ').append(name);

buf.append("\nCFG:\n").append(cfg.toStringInstrs());
if (cfg != null) {
buf.append("\nCFG:\n").append(cfg.toStringInstrs());
} else {
int i = 0;
for (Instr instr : instructions) {
if (i > 0) buf.append("\n");
buf.append(" ").append(i).append('\t').append(instr);
i++;
}
}

return buf.toString();
}
Original file line number Diff line number Diff line change
@@ -29,9 +29,7 @@ public InterpretedIRBlockBody(IRClosure closure, Signature signature) {
public InterpreterContext ensureInstrsReady() {
if (IRRuntimeHelpers.isDebug() && !displayedCFG) {
LOG.info("Executing '" + closure + "' (pushScope=" + pushScope + ", reuseParentScope=" + reuseParentScope);
CFG cfg = closure.getCFG();
LOG.info("Graph:\n" + cfg.toStringGraph());
LOG.info("CFG:\n" + cfg.toStringInstrs());
LOG.info(closure.debugOutput());
displayedCFG = true;
}
// Always prepared in the context of parent scope -- so a null value here is a bug.