# HG changeset patch # User Christian Haeubl # Date 1331602805 25200 # Node ID 95b8a32a7cc38d20809c088f49d1fa0396a90a04 # Parent 6e7c1fb1980f1d30103dff1237a77a3e6b56ff53 preparations to avoid endless recompilations because of not updated profiling information diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Mon Mar 12 18:40:05 2012 -0700 @@ -140,6 +140,7 @@ public static int TraceLIRGeneratorLevel = 0; public static boolean TraceEscapeAnalysis = ____; public static int TraceBytecodeParserLevel = 0; + public static boolean PrintBailouts = true; public static boolean ExitVMOnBailout = ____; public static boolean ExitVMOnException = true; @@ -148,7 +149,8 @@ // Code generator settings public static boolean PropagateTypes = ____; - public static boolean UseBranchPrediction = true; + public static boolean UseProfilingInformation = true; + public static boolean RemoveNeverExecutedCode = true; public static boolean UseExceptionProbability = true; public static boolean AllowExplicitExceptionChecks = true; public static boolean OmitHotExceptionStacktrace = ____; diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Mon Mar 12 18:40:05 2012 -0700 @@ -56,7 +56,6 @@ import com.oracle.graal.lir.StandardOp.PhiLabelOp; import com.oracle.graal.lir.cfg.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.DeoptimizeNode.DeoptAction; import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; @@ -753,7 +752,7 @@ } else { // Fall back to a normal branch. LIRDebugInfo info = state(); - LabelRef stubEntry = createDeoptStub(DeoptAction.InvalidateReprofile, info, comp); + LabelRef stubEntry = createDeoptStub(RiDeoptAction.InvalidateReprofile, info, comp); emitBranch(comp, null, stubEntry, info); } } @@ -986,7 +985,7 @@ } - protected abstract LabelRef createDeoptStub(DeoptAction action, LIRDebugInfo info, Object deoptInfo); + protected abstract LabelRef createDeoptStub(RiDeoptAction action, LIRDebugInfo info, Object deoptInfo); @Override public Variable emitCallToRuntime(CiRuntimeCall runtimeCall, boolean canTrap, CiValue... args) { diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64DeoptimizationStub.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64DeoptimizationStub.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64DeoptimizationStub.java Mon Mar 12 18:40:05 2012 -0700 @@ -24,29 +24,27 @@ import java.util.*; +import com.oracle.graal.compiler.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.amd64.*; +import com.oracle.graal.lir.asm.*; import com.oracle.max.asm.*; import com.oracle.max.asm.target.amd64.*; import com.oracle.max.cri.ci.*; -import com.oracle.graal.compiler.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.amd64.*; -import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.DeoptimizeNode.DeoptAction; +import com.oracle.max.cri.ri.*; public class AMD64DeoptimizationStub extends AMD64SlowPath { public final Label label = new Label(); public final LIRDebugInfo info; - public final DeoptAction action; + public final RiDeoptAction action; public final Object deoptInfo; - public AMD64DeoptimizationStub(DeoptAction action, LIRDebugInfo info, Object deoptInfo) { + public AMD64DeoptimizationStub(RiDeoptAction action, LIRDebugInfo info, Object deoptInfo) { this.action = action; this.info = info; this.deoptInfo = deoptInfo; } - private static ArrayList keepAlive = new ArrayList<>(); @Override @@ -62,27 +60,8 @@ // TODO Make this an explicit calling convention instead of using a scratch register AMD64Call.directCall(tasm, masm, CiRuntimeCall.SetDeoptInfo, info); } - int code; - switch(action) { - case None: - code = 0; - break; - case Recompile: - code = 1; - break; - case InvalidateReprofile: - code = 2; - break; - case InvalidateRecompile: - code = 3; - break; - case InvalidateStopCompiling: - code = 4; - break; - default: - throw GraalInternalError.shouldNotReachHere(); - } - masm.movq(scratch, code); + + masm.movq(scratch, action.value()); // TODO Make this an explicit calling convention instead of using a scratch register AMD64Call.directCall(tasm, masm, CiRuntimeCall.Deoptimize, info); AMD64Call.shouldNotReachHere(tasm, masm); diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java Mon Mar 12 18:40:05 2012 -0700 @@ -66,7 +66,6 @@ import com.oracle.graal.lir.amd64.AMD64Move.NullCheckOp; import com.oracle.graal.lir.amd64.AMD64Move.SpillMoveOp; import com.oracle.graal.lir.amd64.AMD64Move.StoreOp; -import com.oracle.graal.nodes.DeoptimizeNode.DeoptAction; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; @@ -500,7 +499,7 @@ @Override - public void emitDeoptimizeOn(Condition cond, DeoptAction action, Object deoptInfo) { + public void emitDeoptimizeOn(Condition cond, RiDeoptAction action, Object deoptInfo) { LIRDebugInfo info = state(); LabelRef stubEntry = createDeoptStub(action, info, deoptInfo); if (cond != null) { @@ -547,7 +546,7 @@ } @Override - protected LabelRef createDeoptStub(DeoptAction action, LIRDebugInfo info, Object deoptInfo) { + protected LabelRef createDeoptStub(RiDeoptAction action, LIRDebugInfo info, Object deoptInfo) { assert info.topFrame.bci >= 0 : "invalid bci for deopt framestate"; AMD64DeoptimizationStub stub = new AMD64DeoptimizationStub(action, info, deoptInfo); lir.deoptimizationStubs.add(stub); diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java Mon Mar 12 18:40:05 2012 -0700 @@ -35,7 +35,6 @@ import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.DeoptimizeNode.DeoptAction; import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; @@ -304,7 +303,7 @@ if (shouldFallbackToInvoke()) { unknownTypeNode = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, 1, notRecordedTypeProbability, false); } else { - unknownTypeNode = graph.add(new DeoptimizeNode(DeoptAction.InvalidateReprofile)); + unknownTypeNode = graph.add(new DeoptimizeNode(RiDeoptAction.InvalidateReprofile)); } // replace the invoke exception edge @@ -369,7 +368,7 @@ ReadHubNode objectClassNode = graph.add(new ReadHubNode(invoke.callTarget().receiver())); graph.addBeforeFixed(invoke.node(), objectClassNode); - FixedNode unknownTypeNode = graph.add(new DeoptimizeNode(DeoptAction.InvalidateReprofile)); + FixedNode unknownTypeNode = graph.add(new DeoptimizeNode(RiDeoptAction.InvalidateReprofile)); FixedNode dispatchOnType = createDispatchOnType(graph, objectClassNode, new BeginNode[] {calleeEntryNode}, unknownTypeNode); FixedWithNextNode pred = (FixedWithNextNode) invoke.node().predecessor(); @@ -812,7 +811,7 @@ } else { if (unwindNode != null) { UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode); - DeoptimizeNode deoptimizeNode = new DeoptimizeNode(DeoptAction.InvalidateRecompile); + DeoptimizeNode deoptimizeNode = new DeoptimizeNode(RiDeoptAction.InvalidateRecompile); unwindDuplicate.replaceAndDelete(graph.add(deoptimizeNode)); // move the deopt upwards if there is a monitor exit that tries to use the "after exception" frame state // (because there is no "after exception" frame state!) diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Mar 12 18:40:05 2012 -0700 @@ -299,7 +299,7 @@ public void run() { try { final PhasePlan plan = getDefaultPhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime()); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime(), GraphBuilderConfiguration.getDefault()); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); long startTime = System.nanoTime(); int index = compiledMethodCount++; @@ -330,9 +330,13 @@ compiler.getRuntime().installMethod(method, result); } catch (CiBailout bailout) { Debug.metric("Bailouts").increment(); - if (GraalOptions.ExitVMOnBailout) { + if (GraalOptions.PrintBailouts || GraalOptions.ExitVMOnBailout) { + TTY.println("WARN: Compilation bailout"); bailout.printStackTrace(TTY.cachedOut); - System.exit(-1); + + if (GraalOptions.ExitVMOnBailout) { + System.exit(-1); + } } } catch (Throwable t) { if (GraalOptions.ExitVMOnException) { diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotMethodResolvedImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotMethodResolvedImpl.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotMethodResolvedImpl.java Mon Mar 12 18:40:05 2012 -0700 @@ -30,6 +30,7 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; import com.oracle.max.criutils.*; +import com.oracle.graal.compiler.*; import com.oracle.graal.java.bytecode.*; /** @@ -213,12 +214,13 @@ @Override public RiProfilingInfo profilingInfo() { - if (methodData == null) { + if (GraalOptions.UseProfilingInformation && methodData == null) { methodData = compiler.getVMEntries().RiMethod_methodData(this); } if (methodData == null) { - return new HotSpotNoProfilingInfo(compiler); + // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in case of a deoptimization. + return BaseProfilingInfo.get(RiExceptionSeen.FALSE); } else { return new HotSpotProfilingInfo(compiler, methodData); } diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java Mon Mar 12 18:40:05 2012 -0700 @@ -423,7 +423,7 @@ @Override public CiTargetMethod compile(RiResolvedMethod method, StructuredGraph graph) { final PhasePlan plan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime()); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime(), GraphBuilderConfiguration.getDefault()); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); return compiler.getCompiler().compileMethod(method, graph, -1, plan); } diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java Mon Mar 12 18:40:05 2012 -0700 @@ -712,7 +712,7 @@ } XirOperand scratch = asm.createRegisterTemp("scratch", target.wordKind, AMD64.r10); - asm.mov(scratch, wordConst(asm, 2)); + asm.mov(scratch, wordConst(asm, RiDeoptAction.InvalidateReprofile.value())); asm.callRuntime(CiRuntimeCall.Deoptimize, null); asm.shouldNotReachHere(); @@ -891,7 +891,7 @@ if (is(BOUNDS_CHECK, flags)) { asm.bindOutOfLine(failBoundsCheck); XirOperand scratch = asm.createRegisterTemp("scratch", target.wordKind, AMD64.r10); - asm.mov(scratch, wordConst(asm, 0)); + asm.mov(scratch, wordConst(asm, RiDeoptAction.None.value())); asm.callRuntime(CiRuntimeCall.Deoptimize, null); asm.shouldNotReachHere(); } @@ -1081,7 +1081,7 @@ checkSubtype(asm, temp, valueHub, compHub); asm.jneq(store, temp, wordConst(asm, 0)); XirOperand scratch = asm.createRegisterTemp("scratch", target.wordKind, AMD64.r10); - asm.mov(scratch, wordConst(asm, 0)); + asm.mov(scratch, wordConst(asm, RiDeoptAction.None.value())); asm.callRuntime(CiRuntimeCall.Deoptimize, null); asm.jmp(store); } @@ -1162,7 +1162,7 @@ if (is(BOUNDS_CHECK, flags)) { asm.bindOutOfLine(failBoundsCheck); XirOperand scratch = asm.createRegisterTemp("scratch", target.wordKind, AMD64.r10); - asm.mov(scratch, wordConst(asm, 0)); + asm.mov(scratch, wordConst(asm, RiDeoptAction.None.value())); asm.callRuntime(CiRuntimeCall.Deoptimize, null); asm.shouldNotReachHere(); } @@ -1172,7 +1172,7 @@ checkSubtype(asm, temp, valueHub, compHub); asm.jneq(store, temp, wordConst(asm, 0)); XirOperand scratch = asm.createRegisterTemp("scratch", target.wordKind, AMD64.r10); - asm.mov(scratch, wordConst(asm, 0)); + asm.mov(scratch, wordConst(asm, RiDeoptAction.None.value())); asm.callRuntime(CiRuntimeCall.Deoptimize, null); asm.shouldNotReachHere(); } diff -r 6e7c1fb1980f -r 95b8a32a7cc3 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 Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Mon Mar 12 18:40:05 2012 -0700 @@ -198,20 +198,17 @@ public Block startBlock; - public final boolean useBranchPrediction; - /** * Creates a new BlockMap instance from bytecode of the given method . * @param method the compiler interface method containing the code */ - public BciBlockMapping(RiResolvedMethod method, boolean useBranchPrediction) { + public BciBlockMapping(RiResolvedMethod method) { this.method = method; exceptionHandlers = method.exceptionHandlers(); stream = new BytecodeStream(method.code()); this.blockMap = new Block[method.codeSize()]; this.canTrap = new BitSet(blockMap.length); this.blocks = new ArrayList<>(); - this.useBranchPrediction = useBranchPrediction; } public RiExceptionHandler[] exceptionHandlers() { diff -r 6e7c1fb1980f -r 95b8a32a7cc3 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 Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon Mar 12 18:40:05 2012 -0700 @@ -42,7 +42,6 @@ import com.oracle.graal.java.BciBlockMapping.ExceptionBlock; import com.oracle.graal.java.bytecode.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.DeoptimizeNode.DeoptAction; import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; @@ -106,11 +105,6 @@ } } - - public GraphBuilderPhase(RiRuntime runtime) { - this(runtime, GraphBuilderConfiguration.getDefault()); - } - public GraphBuilderPhase(RiRuntime runtime, GraphBuilderConfiguration config) { this.config = config; this.runtime = runtime; @@ -139,7 +133,7 @@ } private BciBlockMapping createBlockMap() { - BciBlockMapping map = new BciBlockMapping(method, config.useBranchPrediction()); + BciBlockMapping map = new BciBlockMapping(method); map.build(); Debug.dump(map, CiUtil.format("After block building %f %R %H.%n(%P)", method)); @@ -328,7 +322,7 @@ if (riType instanceof RiResolvedType) { frameState.push(CiKind.Object, append(ConstantNode.forCiConstant(((RiResolvedType) riType).getEncoding(Representation.JavaClass), runtime, currentGraph))); } else { - append(currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + append(currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); frameState.push(CiKind.Object, append(ConstantNode.forObject(null, runtime, currentGraph))); } } else if (con instanceof CiConstant) { @@ -697,7 +691,7 @@ frameState.ipush(append(MaterializeNode.create(currentGraph.unique(instanceOfNode), currentGraph))); } else { BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode()); - DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile)); + DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile)); IfNode ifNode = currentGraph.add(new IfNode(currentGraph.unique(new NullCheckNode(object, true)), trueSucc, deopt, 1)); append(ifNode); lastInstr = trueSucc; @@ -711,7 +705,7 @@ NewInstanceNode n = currentGraph.add(new NewInstanceNode((RiResolvedType) type)); frameState.apush(append(n)); } else { - append(currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + append(currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); frameState.apush(appendConstant(CiConstant.NULL_OBJECT)); } } @@ -752,7 +746,7 @@ NewArrayNode n = currentGraph.add(new NewObjectArrayNode((RiResolvedType) type, length)); frameState.apush(append(n)); } else { - append(currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + append(currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); frameState.apush(appendConstant(CiConstant.NULL_OBJECT)); } @@ -769,7 +763,7 @@ FixedWithNextNode n = currentGraph.add(new NewMultiArrayNode((RiResolvedType) type, dims)); frameState.apush(append(n)); } else { - append(currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + append(currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); frameState.apush(appendConstant(CiConstant.NULL_OBJECT)); } } @@ -783,7 +777,7 @@ LoadFieldNode load = currentGraph.add(new LoadFieldNode(receiver, (RiResolvedField) field)); appendOptimizedLoadField(kind, load); } else { - append(currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + append(currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); frameState.push(kind.stackKind(), append(ConstantNode.defaultForKind(kind, currentGraph))); } } @@ -884,7 +878,7 @@ StoreFieldNode store = currentGraph.add(new StoreFieldNode(receiver, (RiResolvedField) field, value)); appendOptimizedStoreField(store); } else { - append(currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + append(currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); } } @@ -926,7 +920,7 @@ if (initialized) { return appendConstant(((RiResolvedType) holder).getEncoding(representation)); } else { - append(currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + append(currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); return null; } } @@ -987,7 +981,7 @@ } private void genInvokeDeopt(RiMethod unresolvedTarget, boolean withReceiver) { - append(currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + append(currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); frameState.popArguments(unresolvedTarget.signature().argumentSlots(withReceiver), unresolvedTarget.signature().argumentCount(withReceiver)); CiKind kind = unresolvedTarget.signature().returnKind(false); if (kind != CiKind.Void) { @@ -1024,7 +1018,7 @@ private void appendInvoke(InvokeKind invokeKind, RiResolvedMethod targetMethod, ValueNode[] args) { CiKind resultType = targetMethod.signature().returnKind(false); if (GraalOptions.DeoptALot) { - DeoptimizeNode deoptimize = currentGraph.add(new DeoptimizeNode(DeoptAction.None)); + DeoptimizeNode deoptimize = currentGraph.add(new DeoptimizeNode(RiDeoptAction.None)); deoptimize.setMessage("invoke " + targetMethod.name()); append(deoptimize); frameState.pushReturn(resultType, ConstantNode.defaultForKind(resultType, currentGraph)); @@ -1198,8 +1192,8 @@ private FixedNode createTarget(double probability, Block block, FrameStateBuilder stateAfter) { assert probability >= 0 && probability <= 1; - if (probability == 0 && config.useBranchPrediction()) { - return currentGraph.add(new DeoptimizeNode(DeoptAction.InvalidateReprofile)); + if (probability == 0 && GraalOptions.RemoveNeverExecutedCode) { + return currentGraph.add(new DeoptimizeNode(RiDeoptAction.InvalidateReprofile)); } else { return createTarget(block, stateAfter); } diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java Mon Mar 12 18:40:05 2012 -0700 @@ -25,26 +25,19 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; +import com.oracle.max.cri.ri.*; @NodeInfo(shortName = "Deopt") public class DeoptimizeNode extends FixedNode implements Node.IterableNodeType, LIRLowerable { - public static enum DeoptAction { - None, // just interpret, do not invalidate nmethod - Recompile, // recompile the nmethod; need not invalidate - InvalidateReprofile, // invalidate the nmethod, reset IC, maybe recompile - InvalidateRecompile, // invalidate the nmethod, recompile (probably) - InvalidateStopCompiling, // invalidate the nmethod and do not compile + @Data private String message; + @Data private final RiDeoptAction action; + + public DeoptimizeNode() { + this(RiDeoptAction.InvalidateReprofile); } - @Data private String message; - @Data private final DeoptAction action; - - public DeoptimizeNode() { - this(DeoptAction.InvalidateReprofile); - } - - public DeoptimizeNode(DeoptAction action) { + public DeoptimizeNode(RiDeoptAction action) { super(StampFactory.illegal()); this.action = action; } @@ -57,7 +50,7 @@ return message; } - public DeoptAction action() { + public RiDeoptAction action() { return action; } diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Mon Mar 12 18:40:05 2012 -0700 @@ -24,9 +24,9 @@ import com.oracle.graal.cri.*; import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.DeoptimizeNode.DeoptAction; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; +import com.oracle.max.cri.ri.*; public final class FixedGuardNode extends FixedWithNextNode implements Simplifiable, Lowerable, LIRLowerable { @@ -64,7 +64,7 @@ if (next != null) { tool.deleteBranch(next); } - setNext(graph().add(new DeoptimizeNode(DeoptAction.InvalidateRecompile))); + setNext(graph().add(new DeoptimizeNode(RiDeoptAction.InvalidateRecompile))); return; } } diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Fri Mar 09 13:14:54 2012 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Mon Mar 12 18:40:05 2012 -0700 @@ -23,8 +23,8 @@ package com.oracle.graal.nodes.spi; import com.oracle.max.cri.ci.*; +import com.oracle.max.cri.ri.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.DeoptimizeNode.DeoptAction; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; @@ -79,7 +79,7 @@ public abstract CiValue emitConvert(ConvertNode.Op opcode, CiValue inputVal); public abstract void emitMembar(int barriers); - public abstract void emitDeoptimizeOn(Condition of, DeoptAction action, Object deoptInfo); + public abstract void emitDeoptimizeOn(Condition of, RiDeoptAction action, Object deoptInfo); public abstract CiValue emitCallToRuntime(CiRuntimeCall runtimeCall, boolean canTrap, CiValue... args); public abstract void emitIf(IfNode i); diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiDeoptAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiDeoptAction.java Mon Mar 12 18:40:05 2012 -0700 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.cri.ri; + + +public enum RiDeoptAction { + None(0), // just interpret, do not invalidate nmethod + RecompileIfTooManyDeopts(1), // recompile the nmethod; need not invalidate + InvalidateReprofile(2), // invalidate the nmethod, reset IC, maybe recompile + InvalidateRecompile(3), // invalidate the nmethod, recompile (probably) + InvalidateStopCompiling(4); // invalidate the nmethod and do not compile + + private final int value; + + private RiDeoptAction(int value) { + this.value = value; + } + + public int value() { + return value; + } +} diff -r 6e7c1fb1980f -r 95b8a32a7cc3 graal/com.oracle.max.criutils/src/com/oracle/max/criutils/BaseProfilingInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.criutils/src/com/oracle/max/criutils/BaseProfilingInfo.java Mon Mar 12 18:40:05 2012 -0700 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.criutils; + +import com.oracle.max.cri.ri.*; + + +/** + * Dummy profiling information in case that a method was not executed frequently enough so that + * no profiling information does exist yet, or in case that the profiling information should not be used. + */ +public final class BaseProfilingInfo implements RiProfilingInfo { + private static final RiProfilingInfo[] NO_PROFILING_INFO = new RiProfilingInfo[] { + new BaseProfilingInfo(RiExceptionSeen.TRUE), + new BaseProfilingInfo(RiExceptionSeen.FALSE), + new BaseProfilingInfo(RiExceptionSeen.NOT_SUPPORTED) + }; + + private final RiExceptionSeen exceptionSeen; + + BaseProfilingInfo(RiExceptionSeen exceptionSeen) { + this.exceptionSeen = exceptionSeen; + } + + @Override + public RiTypeProfile getTypeProfile(int bci) { + return null; + } + + @Override + public double getBranchTakenProbability(int bci) { + return -1; + } + + @Override + public double[] getSwitchProbabilities(int bci) { + return null; + } + + @Override + public RiExceptionSeen getExceptionSeen(int bci) { + return exceptionSeen; + } + + @Override + public int getExecutionCount(int bci) { + return -1; + } + + public static RiProfilingInfo get(RiExceptionSeen exceptionSeen) { + return NO_PROFILING_INFO[exceptionSeen.ordinal()]; + } +} diff -r 6e7c1fb1980f -r 95b8a32a7cc3 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Fri Mar 09 13:14:54 2012 -0800 +++ b/src/share/vm/graal/graalCompiler.cpp Mon Mar 12 18:40:05 2012 -0700 @@ -276,7 +276,7 @@ HotSpotMethodResolved::set_accessFlags(obj, method->access_flags().as_int()); HotSpotMethodResolved::set_maxLocals(obj, method->max_locals()); HotSpotMethodResolved::set_maxStackSize(obj, method->max_stack()); - HotSpotMethodResolved::set_canBeInlined(obj, !CompilerOracle::should_not_inline(method)); + HotSpotMethodResolved::set_canBeInlined(obj, !method->is_not_compilable() && !CompilerOracle::should_not_inline(method)); method->set_graal_mirror(obj()); return obj; diff -r 6e7c1fb1980f -r 95b8a32a7cc3 src/share/vm/oops/methodOop.cpp --- a/src/share/vm/oops/methodOop.cpp Fri Mar 09 13:14:54 2012 -0800 +++ b/src/share/vm/oops/methodOop.cpp Mon Mar 12 18:40:05 2012 -0700 @@ -51,6 +51,9 @@ #include "runtime/signature.hpp" #include "utilities/quickSort.hpp" #include "utilities/xmlstream.hpp" +#ifdef GRAAL +#include "graal/graalJavaAccess.hpp" +#endif // Implementation of methodOopDesc @@ -658,6 +661,13 @@ } } CompilationPolicy::policy()->disable_compilation(this); + +#ifdef GRAAL + oop graal_mirror = this->graal_mirror(); + if (graal_mirror != NULL) { + HotSpotMethodResolved::set_canBeInlined(graal_mirror, false); + } +#endif } // Revert to using the interpreter and clear out the nmethod