< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/OnStackReplacementPhase.java

Print this page

        

*** 34,43 **** --- 34,44 ---- import org.graalvm.compiler.debug.DebugCloseable; import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.graph.Node; import org.graalvm.compiler.graph.iterators.NodeIterable; + import org.graalvm.compiler.loop.LoopEx; import org.graalvm.compiler.loop.LoopsData; import org.graalvm.compiler.loop.phases.LoopTransformations; import org.graalvm.compiler.nodeinfo.InputType; import org.graalvm.compiler.nodeinfo.Verbosity; import org.graalvm.compiler.nodes.AbstractBeginNode;
*** 69,78 **** --- 70,80 ---- import org.graalvm.compiler.options.OptionKey; import org.graalvm.compiler.options.OptionType; import org.graalvm.compiler.options.OptionValues; import org.graalvm.compiler.phases.Phase; import org.graalvm.compiler.phases.common.DeadCodeEliminationPhase; + import org.graalvm.compiler.serviceprovider.SpeculationReasonGroup; import jdk.vm.ci.meta.DeoptimizationAction; import jdk.vm.ci.meta.DeoptimizationReason; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.SpeculationLog;
*** 85,95 **** // @formatter:off @Option(help = "Deoptimize OSR compiled code when the OSR entry loop is finished " + "if there is no mature profile available for the rest of the method.", type = OptionType.Debug) public static final OptionKey<Boolean> DeoptAfterOSR = new OptionKey<>(true); @Option(help = "Support OSR compilations with locks. If DeoptAfterOSR is true we can per definition not have " + ! "unbalaced enter/extis mappings. If DeoptAfterOSR is false insert artificial monitor enters after " + "the OSRStart to have balanced enter/exits in the graph.", type = OptionType.Debug) public static final OptionKey<Boolean> SupportOSRWithLocks = new OptionKey<>(true); // @formatter:on } --- 87,97 ---- // @formatter:off @Option(help = "Deoptimize OSR compiled code when the OSR entry loop is finished " + "if there is no mature profile available for the rest of the method.", type = OptionType.Debug) public static final OptionKey<Boolean> DeoptAfterOSR = new OptionKey<>(true); @Option(help = "Support OSR compilations with locks. If DeoptAfterOSR is true we can per definition not have " + ! "unbalanced enter/exits mappings. If DeoptAfterOSR is false insert artificial monitor enters after " + "the OSRStart to have balanced enter/exits in the graph.", type = OptionType.Debug) public static final OptionKey<Boolean> SupportOSRWithLocks = new OptionKey<>(true); // @formatter:on }
*** 97,106 **** --- 99,110 ---- private static boolean supportOSRWithLocks(OptionValues options) { return Options.SupportOSRWithLocks.getValue(options); } + private static final SpeculationReasonGroup OSR_LOCAL_SPECULATIONS = new SpeculationReasonGroup("OSRLocal", int.class, Stamp.class, int.class); + @Override @SuppressWarnings("try") protected void run(StructuredGraph graph) { DebugContext debug = graph.getDebug(); if (graph.getEntryBCI() == JVMCICompiler.INVOCATION_ENTRY_BCI) {
*** 150,160 **** // Peel the outermost loop first while (l.getParent() != null) { l = l.getParent(); } ! LoopTransformations.peel(loops.loop(l)); osr.replaceAtUsages(InputType.Guard, AbstractBeginNode.prevBegin((FixedNode) osr.predecessor())); for (Node usage : osr.usages().snapshot()) { EntryProxyNode proxy = (EntryProxyNode) usage; proxy.replaceAndDelete(proxy.value()); } --- 154,166 ---- // Peel the outermost loop first while (l.getParent() != null) { l = l.getParent(); } ! LoopEx loop = loops.loop(l); ! loop.loopBegin().markOsrLoop(); ! LoopTransformations.peel(loop); osr.replaceAtUsages(InputType.Guard, AbstractBeginNode.prevBegin((FixedNode) osr.predecessor())); for (Node usage : osr.usages().snapshot()) { EntryProxyNode proxy = (EntryProxyNode) usage; proxy.replaceAndDelete(proxy.value()); }
*** 177,187 **** debug.dump(DebugContext.DETAILED_LEVEL, graph, "OnStackReplacement after setting OSR start"); final int localsSize = osrState.localsSize(); final int locksSize = osrState.locksSize(); for (int i = 0; i < localsSize + locksSize; i++) { ! ValueNode value = null; if (i >= localsSize) { value = osrState.lockAt(i - localsSize); } else { value = osrState.localAt(i); } --- 183,193 ---- debug.dump(DebugContext.DETAILED_LEVEL, graph, "OnStackReplacement after setting OSR start"); final int localsSize = osrState.localsSize(); final int locksSize = osrState.locksSize(); for (int i = 0; i < localsSize + locksSize; i++) { ! ValueNode value; if (i >= localsSize) { value = osrState.lockAt(i - localsSize); } else { value = osrState.localAt(i); }
*** 199,209 **** osrLocal = graph.addOrUnique(new OSRLockNode(i - localsSize, unrestrictedStamp)); } else { osrLocal = graph.addOrUnique(new OSRLocalNode(i, unrestrictedStamp)); } // Speculate on the OSRLocal stamps that could be more precise. ! OSRLocalSpeculationReason reason = new OSRLocalSpeculationReason(osrState.bci, narrowedStamp, i); if (graph.getSpeculationLog().maySpeculate(reason) && osrLocal instanceof OSRLocalNode && value.getStackKind().equals(JavaKind.Object) && !narrowedStamp.isUnrestricted()) { // Add guard. LogicNode check = graph.addOrUniqueWithInputs(InstanceOfNode.createHelper((ObjectStamp) narrowedStamp, osrLocal, null, null)); SpeculationLog.Speculation constant = graph.getSpeculationLog().speculate(reason); FixedGuardNode guard = graph.add(new FixedGuardNode(check, DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, constant, false)); --- 205,215 ---- osrLocal = graph.addOrUnique(new OSRLockNode(i - localsSize, unrestrictedStamp)); } else { osrLocal = graph.addOrUnique(new OSRLocalNode(i, unrestrictedStamp)); } // Speculate on the OSRLocal stamps that could be more precise. ! SpeculationReason reason = OSR_LOCAL_SPECULATIONS.createSpeculationReason(osrState.bci, narrowedStamp, i); if (graph.getSpeculationLog().maySpeculate(reason) && osrLocal instanceof OSRLocalNode && value.getStackKind().equals(JavaKind.Object) && !narrowedStamp.isUnrestricted()) { // Add guard. LogicNode check = graph.addOrUniqueWithInputs(InstanceOfNode.createHelper((ObjectStamp) narrowedStamp, osrLocal, null, null)); SpeculationLog.Speculation constant = graph.getSpeculationLog().speculate(reason); FixedGuardNode guard = graph.add(new FixedGuardNode(check, DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, constant, false));
*** 303,334 **** @Override public float codeSizeIncrease() { return 5.0f; } - - private static class OSRLocalSpeculationReason implements SpeculationReason { - private int bci; - private Stamp speculatedStamp; - private int localIndex; - - OSRLocalSpeculationReason(int bci, Stamp speculatedStamp, int localIndex) { - this.bci = bci; - this.speculatedStamp = speculatedStamp; - this.localIndex = localIndex; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof OSRLocalSpeculationReason) { - OSRLocalSpeculationReason that = (OSRLocalSpeculationReason) obj; - return this.bci == that.bci && this.speculatedStamp.equals(that.speculatedStamp) && this.localIndex == that.localIndex; - } - return false; - } - - @Override - public int hashCode() { - return (bci << 16) ^ speculatedStamp.hashCode() ^ localIndex; - } - } } --- 309,314 ----
< prev index next >