# HG changeset patch # User Gilles Duboscq # Date 1394126029 -3600 # Node ID 85969b1aba788ffe2e6db7ccd4fb249c27d73c98 # Parent 98d38009bb2b600ccf2e91fa905ee087255b974b Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope diff -r 98d38009bb2b -r 85969b1aba78 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Fri Mar 07 09:23:53 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Thu Mar 06 18:13:49 2014 +0100 @@ -914,76 +914,78 @@ } private void reportFailure(int numBlocks) { - Indent indent = Debug.logAndIndent("report failure, graph: %s", getGraphFromDebugContext()); + try (Scope s = Debug.forceLog()) { + Indent indent = Debug.logAndIndent("report failure, graph: %s", getGraphFromDebugContext()); - BitSet startBlockLiveIn = blockData.get(ir.cfg.getStartBlock()).liveIn; - try (Indent indent2 = Debug.logAndIndent("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined):")) { + BitSet startBlockLiveIn = blockData.get(ir.cfg.getStartBlock()).liveIn; + try (Indent indent2 = Debug.logAndIndent("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined):")) { + for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { + Value operand = operandFor(operandNum); + Debug.log("var %d; operand=%s; node=%s", operandNum, operand, getValueForOperandFromDebugContext(operand)); + } + } + + // print some additional information to simplify debugging for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { Value operand = operandFor(operandNum); - Debug.log("var %d; operand=%s; node=%s", operandNum, operand, getValueForOperandFromDebugContext(operand)); - } - } + final Indent indent2 = Debug.logAndIndent("---- Detailed information for var %d; operand=%s; node=%s ----", operandNum, operand, getValueForOperandFromDebugContext(operand)); - // print some additional information to simplify debugging - for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { - Value operand = operandFor(operandNum); - final Indent indent2 = Debug.logAndIndent("---- Detailed information for var %d; operand=%s; node=%s ----", operandNum, operand, getValueForOperandFromDebugContext(operand)); + Deque definedIn = new ArrayDeque<>(); + HashSet usedIn = new HashSet<>(); + for (Block block : sortedBlocks) { + if (blockData.get(block).liveGen.get(operandNum)) { + usedIn.add(block); + try (Indent indent3 = Debug.logAndIndent("used in block B%d", block.getId())) { + for (LIRInstruction ins : ir.lir(block)) { + try (Indent indent4 = Debug.logAndIndent("%d: %s", ins.id(), ins)) { + ins.forEachState(new ValueProcedure() { - Deque definedIn = new ArrayDeque<>(); - HashSet usedIn = new HashSet<>(); - for (Block block : sortedBlocks) { - if (blockData.get(block).liveGen.get(operandNum)) { - usedIn.add(block); - try (Indent indent3 = Debug.logAndIndent("used in block B%d", block.getId())) { - for (LIRInstruction ins : ir.lir(block)) { - try (Indent indent4 = Debug.logAndIndent("%d: %s", ins.id(), ins)) { - ins.forEachState(new ValueProcedure() { - - @Override - public Value doValue(Value liveStateOperand) { - Debug.log("operand=%s", liveStateOperand); - return liveStateOperand; - } - }); + @Override + public Value doValue(Value liveStateOperand) { + Debug.log("operand=%s", liveStateOperand); + return liveStateOperand; + } + }); + } + } + } + } + if (blockData.get(block).liveKill.get(operandNum)) { + definedIn.add(block); + try (Indent indent3 = Debug.logAndIndent("defined in block B%d", block.getId())) { + for (LIRInstruction ins : ir.lir(block)) { + Debug.log("%d: %s", ins.id(), ins); } } } } - if (blockData.get(block).liveKill.get(operandNum)) { - definedIn.add(block); - try (Indent indent3 = Debug.logAndIndent("defined in block B%d", block.getId())) { - for (LIRInstruction ins : ir.lir(block)) { - Debug.log("%d: %s", ins.id(), ins); + + int[] hitCount = new int[numBlocks]; + + while (!definedIn.isEmpty()) { + Block block = definedIn.removeFirst(); + usedIn.remove(block); + for (Block successor : block.getSuccessors()) { + if (successor.isLoopHeader()) { + if (!block.isLoopEnd()) { + definedIn.add(successor); + } + } else { + if (++hitCount[successor.getId()] == successor.getPredecessorCount()) { + definedIn.add(successor); + } } } } - } - - int[] hitCount = new int[numBlocks]; - - while (!definedIn.isEmpty()) { - Block block = definedIn.removeFirst(); - usedIn.remove(block); - for (Block successor : block.getSuccessors()) { - if (successor.isLoopHeader()) { - if (!block.isLoopEnd()) { - definedIn.add(successor); - } - } else { - if (++hitCount[successor.getId()] == successor.getPredecessorCount()) { - definedIn.add(successor); - } + try (Indent indent3 = Debug.logAndIndent("**** offending usages are in: ")) { + for (Block block : usedIn) { + Debug.log("B%d", block.getId()); } } + indent2.outdent(); } - try (Indent indent3 = Debug.logAndIndent("**** offending usages are in: ")) { - for (Block block : usedIn) { - Debug.log("B%d", block.getId()); - } - } - indent2.outdent(); + indent.outdent(); } - indent.outdent(); } private void verifyLiveness() { diff -r 98d38009bb2b -r 85969b1aba78 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Fri Mar 07 09:23:53 2014 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Mar 06 18:13:49 2014 +0100 @@ -204,6 +204,20 @@ } } + public static Scope forceLog() { + return Debug.sandbox("forceLog", new DelegatingDebugConfig(DebugScope.getConfig()) { + @Override + public boolean isLogEnabled() { + return true; + } + + @Override + public boolean isLogEnabledForMethod() { + return true; + } + }); + } + /** * Handles an exception in the context of the debug scope just exited. The just exited scope * must have the current scope as its parent which will be the case if the try-with-resource diff -r 98d38009bb2b -r 85969b1aba78 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Fri Mar 07 09:23:53 2014 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Thu Mar 06 18:13:49 2014 +0100 @@ -228,17 +228,16 @@ * @param name the name of the new scope * @param sandboxConfig the configuration to use for a new top level scope, or null if the new * scope should be a child scope - * @param context objects to be appended to the debug context + * @param newContextObjects objects to be appended to the debug context * @return the new scope which will be exited when its {@link #close()} method is called */ - @SuppressWarnings("hiding") - public DebugScope scope(String name, DebugConfig sandboxConfig, Object... context) { + public DebugScope scope(String name, DebugConfig sandboxConfig, Object... newContextObjects) { DebugScope newScope = null; if (sandboxConfig != null) { - newScope = new DebugScope(name, name, this, true, context); + newScope = new DebugScope(name, name, this, true, newContextObjects); configTL.set(sandboxConfig); } else { - newScope = this.createChild(name, context); + newScope = this.createChild(name, newContextObjects); } instanceTL.set(newScope); newScope.updateFlags();