# HG changeset patch # User Lukas Stadler # Date 1361955229 -3600 # Node ID fed868d1aefdd9b54884df6340309cd75f920f4d # Parent d81109e2d7beab795a00f11c9f3d2e03f52a69e9 simplify GraphBuilderConfiguration and add omitAllExceptionEdges diff -r d81109e2d7be -r fed868d1aefd graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompiledMethodTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompiledMethodTest.java Tue Feb 26 20:10:02 2013 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompiledMethodTest.java Wed Feb 27 09:53:49 2013 +0100 @@ -112,7 +112,7 @@ Method method = CompilableObjectImpl.class.getDeclaredMethod("executeHelper", ObjectCompiler.class, String.class); ResolvedJavaMethod javaMethod = runtime.lookupJavaMethod(method); StructuredGraph graph = new StructuredGraph(javaMethod); - new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph); + new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.NONE).apply(graph); new CanonicalizerPhase(runtime, new Assumptions(false)).apply(graph); new DeadCodeEliminationPhase().apply(graph); diff -r d81109e2d7be -r fed868d1aefd graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Tue Feb 26 20:10:02 2013 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Feb 27 09:53:49 2013 +0100 @@ -407,7 +407,7 @@ protected StructuredGraph parse(Method m) { ResolvedJavaMethod javaMethod = runtime.lookupJavaMethod(m); StructuredGraph graph = new StructuredGraph(javaMethod); - new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.ALL).apply(graph); + new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); return graph; } @@ -423,7 +423,7 @@ protected PhasePlan getDefaultPhasePlan() { PhasePlan plan = new PhasePlan(); - plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.ALL)); + plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL)); return plan; } } diff -r d81109e2d7be -r fed868d1aefd 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 Feb 26 20:10:02 2013 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java Wed Feb 27 09:53:49 2013 +0100 @@ -23,21 +23,16 @@ package com.oracle.graal.java; import com.oracle.graal.api.meta.*; -import com.oracle.graal.phases.*; public class GraphBuilderConfiguration { - public static enum ResolvePolicy { - Default, EagerForSnippets, Eager, - } - - private final ResolvePolicy resolving; - private final PhasePlan plan; + private final boolean eagerResolving; + private final boolean omitAllExceptionEdges; private ResolvedJavaType[] skippedExceptionTypes; - public GraphBuilderConfiguration(ResolvePolicy resolving, PhasePlan plan) { - this.resolving = resolving; - this.plan = plan; + protected GraphBuilderConfiguration(boolean eagerResolving, boolean omitAllExceptionEdges) { + this.eagerResolving = eagerResolving; + this.omitAllExceptionEdges = omitAllExceptionEdges; } public void setSkippedExceptionTypes(ResolvedJavaType[] skippedExceptionTypes) { @@ -48,31 +43,23 @@ return skippedExceptionTypes; } - public boolean eagerResolvingForSnippets() { - return (resolving == ResolvePolicy.EagerForSnippets || resolving == ResolvePolicy.Eager); + public boolean eagerResolving() { + return eagerResolving; } - public boolean eagerResolving() { - return (resolving == ResolvePolicy.Eager); - } - - public PhasePlan plan() { - return plan; + public boolean omitAllExceptionEdges() { + return omitAllExceptionEdges; } public static GraphBuilderConfiguration getDefault() { - return getDefault(null); + return new GraphBuilderConfiguration(false, false); } - public static GraphBuilderConfiguration getDefault(PhasePlan plan) { - return new GraphBuilderConfiguration(ResolvePolicy.Default, plan); + public static GraphBuilderConfiguration getEagerDefault() { + return new GraphBuilderConfiguration(true, false); } public static GraphBuilderConfiguration getSnippetDefault() { - return getSnippetDefault(null); - } - - public static GraphBuilderConfiguration getSnippetDefault(PhasePlan plan) { - return new GraphBuilderConfiguration(ResolvePolicy.EagerForSnippets, plan); + return new GraphBuilderConfiguration(true, true); } } diff -r d81109e2d7be -r fed868d1aefd 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 Feb 26 20:10:02 2013 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Feb 27 09:53:49 2013 +0100 @@ -182,11 +182,12 @@ currentBlock = blockMap.startBlock; blockMap.startBlock.entryState = frameState; if (blockMap.startBlock.isLoopHeader) { - // TODO(lstadler,gduboscq) createTarget might not be safe at this position, since it - // expects currentBlock, - // etc. to be set up correctly. A better solution to this problem of start blocks that - // are loop headers - // would be to create a dummy block in BciBlockMapping. + /* + * TODO(lstadler,gduboscq) createTarget might not be safe at this position, since it + * expects currentBlock, etc. to be set up correctly. A better solution to this problem + * of start blocks that are loop headers would be to create a dummy block in + * BciBlockMapping. + */ appendGoto(createTarget(blockMap.startBlock, frameState)); } else { blockMap.startBlock.firstInstruction = lastInstr; @@ -635,21 +636,21 @@ private JavaType lookupType(int cpi, int bytecode) { eagerResolvingForSnippets(cpi, bytecode); JavaType result = constantPool.lookupType(cpi, bytecode); - assert !graphBuilderConfig.eagerResolvingForSnippets() || result instanceof ResolvedJavaType; + assert !graphBuilderConfig.eagerResolving() || result instanceof ResolvedJavaType; return result; } private JavaMethod lookupMethod(int cpi, int opcode) { eagerResolvingForSnippets(cpi, opcode); JavaMethod result = constantPool.lookupMethod(cpi, opcode); - assert !graphBuilderConfig.eagerResolvingForSnippets() || ((result instanceof ResolvedJavaMethod) && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized()) : result; + assert !graphBuilderConfig.eagerResolving() || ((result instanceof ResolvedJavaMethod) && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized()) : result; return result; } private JavaField lookupField(int cpi, int opcode) { eagerResolvingForSnippets(cpi, opcode); JavaField result = constantPool.lookupField(cpi, opcode); - assert !graphBuilderConfig.eagerResolvingForSnippets() || (result instanceof ResolvedJavaField && ((ResolvedJavaField) result).getDeclaringClass().isInitialized()) : result; + assert !graphBuilderConfig.eagerResolving() || (result instanceof ResolvedJavaField && ((ResolvedJavaField) result).getDeclaringClass().isInitialized()) : result; return result; } @@ -660,14 +661,8 @@ return result; } - // private void eagerResolving(int cpi, int bytecode) { - // if (graphBuilderConfig.eagerResolving()) { - // constantPool.loadReferencedType(cpi, bytecode); - // } - // } - private void eagerResolvingForSnippets(int cpi, int bytecode) { - if (graphBuilderConfig.eagerResolvingForSnippets()) { + if (graphBuilderConfig.eagerResolving()) { constantPool.loadReferencedType(cpi, bytecode); } } @@ -1038,13 +1033,13 @@ } JavaType returnType = targetMethod.getSignature().getReturnType(method.getDeclaringClass()); - if (graphBuilderConfig.eagerResolvingForSnippets()) { + if (graphBuilderConfig.eagerResolving()) { returnType = returnType.resolve(targetMethod.getDeclaringClass()); } MethodCallTargetNode callTarget = currentGraph.add(new MethodCallTargetNode(invokeKind, targetMethod, args, returnType)); // be conservative if information was not recorded (could result in endless recompiles // otherwise) - if (optimisticOpts.useExceptionProbability() && profilingInfo.getExceptionSeen(bci()) == ExceptionSeen.FALSE) { + if (graphBuilderConfig.omitAllExceptionEdges() || (optimisticOpts.useExceptionProbability() && profilingInfo.getExceptionSeen(bci()) == ExceptionSeen.FALSE)) { ValueNode result = appendWithBCI(currentGraph.add(new InvokeNode(callTarget, bci()))); frameState.pushReturn(resultType, result);