# HG changeset patch # User Christian Wimmer # Date 1410918530 25200 # Node ID 4e15850b67bb958ea1749c665932827ee2b9a782 # Parent f396d15ddce221abe2634c8320423808d187b628 Make liveness analysis configurable by graph builder configuration diff -r f396d15ddce2 -r 4e15850b67bb graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java --- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Tue Sep 16 18:43:39 2014 -0700 +++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Tue Sep 16 18:48:50 2014 -0700 @@ -95,7 +95,7 @@ BciBlockMapping blockMap; try (Scope ds = Debug.scope("BciBlockMapping")) { // compute the block map, setup exception handlers and get the entrypoint(s) - blockMap = BciBlockMapping.create(method); + blockMap = BciBlockMapping.create(method, graphBuilderConfig.doLivenessAnalysis()); } catch (Throwable e) { throw Debug.handle(e); } @@ -158,7 +158,7 @@ try (Scope s = Debug.scope("Allocator")) { if (backend.shouldAllocateRegisters()) { - GraalCompiler.runLinearScan(target, lir, frameMap); + LinearScan.allocate(target, lir, frameMap); } } catch (Throwable e) { throw Debug.handle(e); diff -r f396d15ddce2 -r 4e15850b67bb 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 Sep 16 18:43:39 2014 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Tue Sep 16 18:48:50 2014 -0700 @@ -64,7 +64,7 @@ protected F frameState; protected BytecodeStream stream; - private GraphBuilderConfiguration graphBuilderConfig; + protected GraphBuilderConfiguration graphBuilderConfig; protected ResolvedJavaMethod method; protected BciBlock currentBlock; protected ProfilingInfo profilingInfo; diff -r f396d15ddce2 -r 4e15850b67bb graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Tue Sep 16 18:43:39 2014 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Tue Sep 16 18:48:50 2014 -0700 @@ -273,6 +273,7 @@ private BciBlock[] blockMap; public BciBlock[] loopHeaders; + private final boolean doLivenessAnalysis; public LocalLiveness liveness; /** @@ -280,7 +281,8 @@ * * @param method the compiler interface method containing the code */ - private BciBlockMapping(ResolvedJavaMethod method) { + private BciBlockMapping(ResolvedJavaMethod method, boolean doLivenessAnalysis) { + this.doLivenessAnalysis = doLivenessAnalysis; this.method = method; exceptionHandlers = method.getExceptionHandlers(); stream = new BytecodeStream(method.getCode()); @@ -319,7 +321,7 @@ if (Debug.isLogEnabled()) { this.log("Before LivenessAnalysis"); } - if (OptLivenessAnalysis.getValue()) { + if (doLivenessAnalysis) { try (Scope s = Debug.scope("LivenessAnalysis")) { liveness = method.getMaxLocals() <= 64 ? new SmallLocalLiveness() : new LargeLocalLiveness(); liveness.computeLiveness(); @@ -1058,8 +1060,8 @@ } } - public static BciBlockMapping create(ResolvedJavaMethod method) { - BciBlockMapping map = new BciBlockMapping(method); + public static BciBlockMapping create(ResolvedJavaMethod method, boolean doLivenessAnalysis) { + BciBlockMapping map = new BciBlockMapping(method, doLivenessAnalysis); map.build(); if (Debug.isDumpEnabled()) { Debug.dump(map, method.format("After block building %f %R %H.%n(%P)")); diff -r f396d15ddce2 -r 4e15850b67bb graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java Tue Sep 16 18:43:39 2014 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java Tue Sep 16 18:48:50 2014 -0700 @@ -25,6 +25,7 @@ import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.nodes.*; public class GraphBuilderConfiguration { @@ -34,6 +35,7 @@ private final boolean omitAllExceptionEdges; private final ResolvedJavaType[] skippedExceptionTypes; private final DebugInfoMode debugInfoMode; + private final boolean doLivenessAnalysis; public static enum DebugInfoMode { SafePointsOnly, @@ -59,20 +61,25 @@ Full, } - protected GraphBuilderConfiguration(boolean eagerResolving, boolean omitAllExceptionEdges, DebugInfoMode debugInfoMode, ResolvedJavaType[] skippedExceptionTypes) { + protected GraphBuilderConfiguration(boolean eagerResolving, boolean omitAllExceptionEdges, DebugInfoMode debugInfoMode, ResolvedJavaType[] skippedExceptionTypes, boolean doLivenessAnalysis) { this.eagerResolving = eagerResolving; this.omitAllExceptionEdges = omitAllExceptionEdges; this.debugInfoMode = debugInfoMode; this.skippedExceptionTypes = skippedExceptionTypes; + this.doLivenessAnalysis = doLivenessAnalysis; } public GraphBuilderConfiguration withSkippedExceptionTypes(ResolvedJavaType[] newSkippedExceptionTypes) { - return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, debugInfoMode, newSkippedExceptionTypes); + return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, debugInfoMode, newSkippedExceptionTypes, doLivenessAnalysis); } public GraphBuilderConfiguration withDebugInfoMode(DebugInfoMode newDebugInfoMode) { ResolvedJavaType[] newSkippedExceptionTypes = skippedExceptionTypes == EMPTY ? EMPTY : Arrays.copyOf(skippedExceptionTypes, skippedExceptionTypes.length); - return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, newDebugInfoMode, newSkippedExceptionTypes); + return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, newDebugInfoMode, newSkippedExceptionTypes, doLivenessAnalysis); + } + + public GraphBuilderConfiguration withDoLivenessAnalysis(boolean newLivenessAnalysis) { + return new GraphBuilderConfiguration(eagerResolving, omitAllExceptionEdges, debugInfoMode, skippedExceptionTypes, newLivenessAnalysis); } public ResolvedJavaType[] getSkippedExceptionTypes() { @@ -95,20 +102,24 @@ return debugInfoMode.ordinal() >= DebugInfoMode.Full.ordinal(); } + public boolean doLivenessAnalysis() { + return doLivenessAnalysis; + } + public static GraphBuilderConfiguration getDefault() { - return new GraphBuilderConfiguration(false, false, DebugInfoMode.SafePointsOnly, EMPTY); + return new GraphBuilderConfiguration(false, false, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptLivenessAnalysis.getValue()); } public static GraphBuilderConfiguration getEagerDefault() { - return new GraphBuilderConfiguration(true, false, DebugInfoMode.SafePointsOnly, EMPTY); + return new GraphBuilderConfiguration(true, false, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptLivenessAnalysis.getValue()); } public static GraphBuilderConfiguration getSnippetDefault() { - return new GraphBuilderConfiguration(true, true, DebugInfoMode.SafePointsOnly, EMPTY); + return new GraphBuilderConfiguration(true, true, DebugInfoMode.SafePointsOnly, EMPTY, GraalOptions.OptLivenessAnalysis.getValue()); } public static GraphBuilderConfiguration getFullDebugDefault() { - return new GraphBuilderConfiguration(true, false, DebugInfoMode.Full, EMPTY); + return new GraphBuilderConfiguration(true, false, DebugInfoMode.Full, EMPTY, GraalOptions.OptLivenessAnalysis.getValue()); } /** diff -r f396d15ddce2 -r 4e15850b67bb 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 Sep 16 18:43:39 2014 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Sep 16 18:48:50 2014 -0700 @@ -230,7 +230,7 @@ try (Indent indent = Debug.logAndIndent("build graph for %s", method)) { // compute the block map, setup exception handlers and get the entrypoint(s) - BciBlockMapping blockMap = BciBlockMapping.create(method); + BciBlockMapping blockMap = BciBlockMapping.create(method, graphBuilderConfig.doLivenessAnalysis()); loopHeaders = blockMap.loopHeaders; liveness = blockMap.liveness;