# HG changeset patch # User Josef Eisl # Date 1396357526 -7200 # Node ID ea57ed7085cff1bd7c03c545f97fc50dfe4db192 # Parent 88dfaf6448e0f5d8c77bb3248446b56c04ba92ce Move options from GraphBuilderPhase to AbstractBytecodeParser. diff -r 88dfaf6448e0 -r ea57ed7085cf graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Tue Apr 01 15:23:21 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Tue Apr 01 15:05:26 2014 +0200 @@ -40,10 +40,30 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; +import com.oracle.graal.options.*; import com.oracle.graal.phases.*; public abstract class AbstractBytecodeParser> { + static class Options { + // @formatter:off + @Option(help = "The trace level for the bytecode parser used when building a graph from bytecode") + public static final OptionValue TraceBytecodeParserLevel = new OptionValue<>(0); + // @formatter:on + } + + /** + * The minimum value to which {@link Options#TraceBytecodeParserLevel} must be set to trace the + * bytecode instructions as they are parsed. + */ + public static final int TRACELEVEL_INSTRUCTIONS = 1; + + /** + * The minimum value to which {@link Options#TraceBytecodeParserLevel} must be set to trace the + * frame state before each bytecode instruction as it is parsed. + */ + public static final int TRACELEVEL_STATE = 2; + protected F frameState; protected BytecodeStream stream; // the bytecode stream private GraphBuilderConfiguration graphBuilderConfig; @@ -55,6 +75,11 @@ private final MetaAccessProvider metaAccess; protected int entryBCI; + /** + * Meters the number of actual bytecodes parsed. + */ + public static final DebugMetric BytecodesParsed = Debug.metric("BytecodesParsed"); + public AbstractBytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, F frameState, BytecodeStream stream, ProfilingInfo profilingInfo, ConstantPool constantPool, int entryBCI) { this.frameState = frameState; @@ -1198,4 +1223,26 @@ return frameState; } + protected final int traceLevel = Options.TraceBytecodeParserLevel.getValue(); + + protected void traceInstruction(int bci, int opcode, boolean blockStart) { + if (traceLevel >= TRACELEVEL_INSTRUCTIONS && Debug.isLogEnabled()) { + StringBuilder sb = new StringBuilder(40); + sb.append(blockStart ? '+' : '|'); + if (bci < 10) { + sb.append(" "); + } else if (bci < 100) { + sb.append(' '); + } + sb.append(bci).append(": ").append(Bytecodes.nameOf(opcode)); + for (int i = bci + 1; i < stream.nextBCI(); ++i) { + sb.append(' ').append(stream.readUByte(i)); + } + if (!currentBlock.jsrScope.isEmpty()) { + sb.append(' ').append(currentBlock.jsrScope); + } + Debug.log("%s", sb); + } + } + } diff -r 88dfaf6448e0 -r ea57ed7085cf graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Apr 01 15:23:21 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Apr 01 15:05:26 2014 +0200 @@ -39,7 +39,7 @@ import com.oracle.graal.bytecode.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; -import com.oracle.graal.graph.Node.*; +import com.oracle.graal.graph.Node.ValueNumberable; import com.oracle.graal.java.BciBlockMapping.BciBlock; import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock; import com.oracle.graal.java.BciBlockMapping.LocalLiveness; @@ -51,7 +51,6 @@ import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; -import com.oracle.graal.options.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; @@ -60,31 +59,12 @@ */ public class GraphBuilderPhase extends BasePhase { - static class Options { - // @formatter:off - @Option(help = "The trace level for the bytecode parser used when building a graph from bytecode") - public static final OptionValue TraceBytecodeParserLevel = new OptionValue<>(0); - // @formatter:on - } - public static final class RuntimeCalls { public static final ForeignCallDescriptor CREATE_NULL_POINTER_EXCEPTION = new ForeignCallDescriptor("createNullPointerException", NullPointerException.class); public static final ForeignCallDescriptor CREATE_OUT_OF_BOUNDS_EXCEPTION = new ForeignCallDescriptor("createOutOfBoundsException", ArrayIndexOutOfBoundsException.class, int.class); } - /** - * The minimum value to which {@link Options#TraceBytecodeParserLevel} must be set to trace the - * bytecode instructions as they are parsed. - */ - public static final int TRACELEVEL_INSTRUCTIONS = 1; - - /** - * The minimum value to which {@link Options#TraceBytecodeParserLevel} must be set to trace the - * frame state before each bytecode instruction as it is parsed. - */ - public static final int TRACELEVEL_STATE = 2; - private final GraphBuilderConfiguration graphBuilderConfig; public GraphBuilderPhase(GraphBuilderConfiguration graphBuilderConfig) { @@ -117,11 +97,6 @@ private final OptimisticOptimizations optimisticOpts; /** - * Meters the number of actual bytecodes parsed. - */ - public static final DebugMetric BytecodesParsed = Debug.metric("BytecodesParsed"); - - /** * Node that marks the begin of block during bytecode parsing. When a block is identified * the first time as a jump target, the placeholder is created and used as the successor for * the jump. When the block is seen the second time, a {@link MergeNode} is created to @@ -1383,8 +1358,6 @@ return instr; } - private final int traceLevel = Options.TraceBytecodeParserLevel.getValue(); - private void traceState() { if (traceLevel >= TRACELEVEL_STATE && Debug.isLogEnabled()) { Debug.log(String.format("| state [nr locals = %d, stack depth = %d, method = %s]", frameState.localsSize(), frameState.stackSize(), method)); @@ -1399,26 +1372,6 @@ } } - private void traceInstruction(int bci, int opcode, boolean blockStart) { - if (traceLevel >= TRACELEVEL_INSTRUCTIONS && Debug.isLogEnabled()) { - StringBuilder sb = new StringBuilder(40); - sb.append(blockStart ? '+' : '|'); - if (bci < 10) { - sb.append(" "); - } else if (bci < 100) { - sb.append(' '); - } - sb.append(bci).append(": ").append(Bytecodes.nameOf(opcode)); - for (int i = bci + 1; i < stream.nextBCI(); ++i) { - sb.append(' ').append(stream.readUByte(i)); - } - if (!currentBlock.jsrScope.isEmpty()) { - sb.append(' ').append(currentBlock.jsrScope); - } - Debug.log("%s", sb); - } - } - } } }