From d1f6e404da17e069a1daaae9f863f7a421b671a0 Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Thu, 3 Sep 2020 20:39:35 +0200 Subject: [PATCH 1/6] Use rootGraph's speculation log for type guard inlining. --- .../info/MultiTypeGuardInlineInfo.java | 20 ++++++++----------- .../inlining/info/TypeGuardInlineInfo.java | 11 ++++------ .../common/inlining/walker/InliningData.java | 18 +++++++++++++---- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java index 780d8dbfaad6..cc33f181cb69 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java @@ -67,8 +67,7 @@ import jdk.vm.ci.meta.JavaTypeProfile.ProfiledType; import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.SpeculationLog; -import jdk.vm.ci.meta.SpeculationLog.SpeculationReason; +import jdk.vm.ci.meta.SpeculationLog.Speculation; /** * Polymorphic inlining of m methods with n type checks (n ≥ m) in case that the profiling @@ -84,10 +83,11 @@ public class MultiTypeGuardInlineInfo extends AbstractInlineInfo { private final ArrayList ptypes; private final double notRecordedTypeProbability; private final Inlineable[] inlineableElements; - private final SpeculationReason speculation; + private final boolean maySpeculate; + private final Speculation speculation; public MultiTypeGuardInlineInfo(Invoke invoke, ArrayList concretes, ArrayList ptypes, - ArrayList typesToConcretes, double notRecordedTypeProbability, SpeculationReason speculation) { + ArrayList typesToConcretes, double notRecordedTypeProbability, boolean maySpeculate, Speculation speculation) { super(invoke); assert concretes.size() > 0 : "must have at least one method"; assert ptypes.size() == typesToConcretes.size() : "array lengths must match"; @@ -100,6 +100,7 @@ public MultiTypeGuardInlineInfo(Invoke invoke, ArrayList con this.methodProbabilities = computeMethodProbabilities(); this.maximumMethodProbability = maximumMethodProbability(); assert maximumMethodProbability > 0; + this.maySpeculate = maySpeculate; this.speculation = speculation; assert assertUniqueTypes(ptypes); } @@ -187,8 +188,7 @@ private boolean hasSingleMethod() { } private boolean shouldFallbackToInvoke() { - SpeculationLog speculationLog = invoke.asNode().graph().getSpeculationLog(); - return notRecordedTypeProbability > 0 || (speculationLog != null && speculation != null && !speculationLog.maySpeculate(speculation)); + return notRecordedTypeProbability > 0 || !maySpeculate; } private EconomicSet inlineMultipleMethods(StructuredGraph graph, CoreProviders providers, String reason) { @@ -232,9 +232,7 @@ private EconomicSet inlineMultipleMethods(StructuredGraph graph, CoreProvi if (shouldFallbackToInvoke()) { unknownTypeSux = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, false); } else { - SpeculationLog speculationLog = graph.getSpeculationLog(); - unknownTypeSux = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, - speculationLog != null && speculation != null ? speculationLog.speculate(speculation) : SpeculationLog.NO_SPECULATION)); + unknownTypeSux = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, speculation)); } successors[successors.length - 1] = BeginNode.begin(unknownTypeSux); @@ -474,9 +472,7 @@ private void devirtualizeWithTypeSwitch(StructuredGraph graph, InvokeKind kind, } private AbstractBeginNode createUnknownTypeSuccessor(StructuredGraph graph) { - SpeculationLog speculationLog = graph.getSpeculationLog(); - return BeginNode.begin(graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, - speculationLog == null || speculation == null ? SpeculationLog.NO_SPECULATION : speculationLog.speculate(speculation)))); + return BeginNode.begin(graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated, speculation))); } @Override diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/TypeGuardInlineInfo.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/TypeGuardInlineInfo.java index 550933921525..c8090b0b5803 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/TypeGuardInlineInfo.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/TypeGuardInlineInfo.java @@ -47,8 +47,7 @@ import jdk.vm.ci.meta.DeoptimizationReason; import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.SpeculationLog; -import jdk.vm.ci.meta.SpeculationLog.SpeculationReason; +import jdk.vm.ci.meta.SpeculationLog.Speculation; /** * Represents an inlining opportunity for which profiling information suggests a monomorphic @@ -60,9 +59,9 @@ public class TypeGuardInlineInfo extends AbstractInlineInfo { private final ResolvedJavaMethod concrete; private final ResolvedJavaType type; private Inlineable inlineableElement; - private final SpeculationReason speculation; + private final Speculation speculation; - public TypeGuardInlineInfo(Invoke invoke, ResolvedJavaMethod concrete, ResolvedJavaType type, SpeculationReason speculation) { + public TypeGuardInlineInfo(Invoke invoke, ResolvedJavaMethod concrete, ResolvedJavaType type, Speculation speculation) { super(invoke); this.concrete = concrete; this.type = type; @@ -125,9 +124,7 @@ private void createGuard(StructuredGraph graph, CoreProviders providers) { ConstantNode typeHub = ConstantNode.forConstant(receiverHub.stamp(NodeView.DEFAULT), providers.getConstantReflection().asObjectHub(type), providers.getMetaAccess(), graph); LogicNode typeCheck = CompareNode.createCompareNode(graph, CanonicalCondition.EQ, receiverHub, typeHub, providers.getConstantReflection(), NodeView.DEFAULT); - SpeculationLog speculationLog = graph.getSpeculationLog(); - FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, - speculationLog != null && speculation != null ? speculationLog.speculate(speculation) : SpeculationLog.NO_SPECULATION, false)); + FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, speculation, false)); assert invoke.predecessor() != null; ValueNode anchoredReceiver = InliningUtil.createAnchoredReceiver(graph, guard, type, nonNullReceiver, true); diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java index 07e048c5f3d9..ba20bdba27d9 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java @@ -276,10 +276,20 @@ private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod ta final OptimisticOptimizations optimisticOpts = context.getOptimisticOptimizations(); OptionValues options = invoke.asNode().getOptions(); - SpeculationLog speculationLog = graph.getSpeculationLog(); - SpeculationLog.SpeculationReason speculation = notRecordedTypeProbability == 0 ? InliningUtil.createSpeculation(invoke, typeProfile) : null; + boolean maySpeculate = true; + SpeculationLog speculationLog = rootGraph.getSpeculationLog(); + SpeculationLog.Speculation speculation = SpeculationLog.NO_SPECULATION; + + if (speculationLog != null && notRecordedTypeProbability == 0) { + SpeculationLog.SpeculationReason speculationReason = InliningUtil.createSpeculation(invoke, typeProfile); + if (speculationLog.maySpeculate(speculationReason)) { + speculation = speculationLog.speculate(speculationReason); + } else { + maySpeculate = false; + } + } - if (ptypes.length == 1 && notRecordedTypeProbability == 0 && (speculationLog == null || speculationLog.maySpeculate(speculation))) { + if (ptypes.length == 1 && notRecordedTypeProbability == 0 && maySpeculate) { if (!optimisticOpts.inlineMonomorphicCalls(options)) { InliningUtil.traceNotInlinedMethod(invoke, inliningDepth(), targetMethod, "inlining monomorphic calls is disabled"); inliningLog.addDecision(invoke, false, "InliningPhase", null, null, "inlining monomorphic calls is disabled"); @@ -393,7 +403,7 @@ private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod ta return null; } } - return new MultiTypeGuardInlineInfo(invoke, concreteMethods, usedTypes, typesToConcretes, notRecordedTypeProbability, speculation); + return new MultiTypeGuardInlineInfo(invoke, concreteMethods, usedTypes, typesToConcretes, notRecordedTypeProbability, maySpeculate, speculation); } } From daf73dd5ff1437c6c560c0bd7e7a81f3618e875e Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Fri, 4 Sep 2020 23:35:29 +0200 Subject: [PATCH 2/6] Devirtualizing interface call should respect the maySpeculate flag. --- .../phases/common/inlining/info/MultiTypeGuardInlineInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java index cc33f181cb69..bf5272f8c425 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java @@ -442,7 +442,7 @@ public void tryToDevirtualizeInvoke(Providers providers) { private void tryToDevirtualizeMultipleMethods(StructuredGraph graph, StampProvider stampProvider, ConstantReflectionProvider constantReflection) { MethodCallTargetNode methodCallTarget = (MethodCallTargetNode) invoke.callTarget(); - if (methodCallTarget.invokeKind() == InvokeKind.Interface) { + if (methodCallTarget.invokeKind() == InvokeKind.Interface && maySpeculate) { ResolvedJavaMethod targetMethod = methodCallTarget.targetMethod(); ResolvedJavaType leastCommonType = getLeastCommonType(); ResolvedJavaType contextType = invoke.getContextType(); From 5e9306f128e57005f316f3e28af84e69fb618d8b Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Wed, 9 Sep 2020 21:31:10 +0200 Subject: [PATCH 3/6] Propagate speculation log to sub-graphs. --- .../phases/common/inlining/info/elem/InlineableGraph.java | 8 ++++++-- .../phases/common/inlining/walker/InliningData.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java index a3587e9827a6..b31b08818fbd 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java @@ -191,8 +191,12 @@ private static ArrayList trackParameterUsages(ParameterNode param, ArrayLi @SuppressWarnings("try") private static StructuredGraph parseBytecodes(ResolvedJavaMethod method, HighTierContext context, CanonicalizerPhase canonicalizer, StructuredGraph caller, boolean trackNodeSourcePosition) { DebugContext debug = caller.getDebug(); - StructuredGraph newGraph = new StructuredGraph.Builder(caller.getOptions(), debug, caller.allowAssumptions()).method(method).trackNodeSourcePosition( - trackNodeSourcePosition).useProfilingInfo(caller.useProfilingInfo()).build(); + StructuredGraph newGraph = new StructuredGraph.Builder(caller.getOptions(), debug, caller.allowAssumptions()) + .method(method) + .trackNodeSourcePosition(trackNodeSourcePosition) + .useProfilingInfo(caller.useProfilingInfo()) + .speculationLog(caller.getSpeculationLog()) + .build(); try (DebugContext.Scope s = debug.scope("InlineGraph", newGraph)) { if (!caller.isUnsafeAccessTrackingEnabled()) { newGraph.disableUnsafeAccessTracking(); diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java index ba20bdba27d9..40aa79bb37ef 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java @@ -277,7 +277,7 @@ private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod ta OptionValues options = invoke.asNode().getOptions(); boolean maySpeculate = true; - SpeculationLog speculationLog = rootGraph.getSpeculationLog(); + SpeculationLog speculationLog = graph.getSpeculationLog(); SpeculationLog.Speculation speculation = SpeculationLog.NO_SPECULATION; if (speculationLog != null && notRecordedTypeProbability == 0) { From f2f5e6a4fd76b461516aa42c4acd3aec62909945 Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Thu, 10 Sep 2020 20:15:43 +0200 Subject: [PATCH 4/6] Address comments. --- .../common/inlining/info/MultiTypeGuardInlineInfo.java | 10 +++++----- .../common/inlining/info/elem/InlineableGraph.java | 8 ++------ .../phases/common/inlining/walker/InliningData.java | 8 ++++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java index bf5272f8c425..6581467f1dae 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/MultiTypeGuardInlineInfo.java @@ -83,11 +83,11 @@ public class MultiTypeGuardInlineInfo extends AbstractInlineInfo { private final ArrayList ptypes; private final double notRecordedTypeProbability; private final Inlineable[] inlineableElements; - private final boolean maySpeculate; + private final boolean speculationFailed; private final Speculation speculation; public MultiTypeGuardInlineInfo(Invoke invoke, ArrayList concretes, ArrayList ptypes, - ArrayList typesToConcretes, double notRecordedTypeProbability, boolean maySpeculate, Speculation speculation) { + ArrayList typesToConcretes, double notRecordedTypeProbability, boolean speculationFailed, Speculation speculation) { super(invoke); assert concretes.size() > 0 : "must have at least one method"; assert ptypes.size() == typesToConcretes.size() : "array lengths must match"; @@ -100,7 +100,7 @@ public MultiTypeGuardInlineInfo(Invoke invoke, ArrayList con this.methodProbabilities = computeMethodProbabilities(); this.maximumMethodProbability = maximumMethodProbability(); assert maximumMethodProbability > 0; - this.maySpeculate = maySpeculate; + this.speculationFailed = speculationFailed; this.speculation = speculation; assert assertUniqueTypes(ptypes); } @@ -188,7 +188,7 @@ private boolean hasSingleMethod() { } private boolean shouldFallbackToInvoke() { - return notRecordedTypeProbability > 0 || !maySpeculate; + return notRecordedTypeProbability > 0 || speculationFailed; } private EconomicSet inlineMultipleMethods(StructuredGraph graph, CoreProviders providers, String reason) { @@ -442,7 +442,7 @@ public void tryToDevirtualizeInvoke(Providers providers) { private void tryToDevirtualizeMultipleMethods(StructuredGraph graph, StampProvider stampProvider, ConstantReflectionProvider constantReflection) { MethodCallTargetNode methodCallTarget = (MethodCallTargetNode) invoke.callTarget(); - if (methodCallTarget.invokeKind() == InvokeKind.Interface && maySpeculate) { + if (methodCallTarget.invokeKind() == InvokeKind.Interface && !speculationFailed) { ResolvedJavaMethod targetMethod = methodCallTarget.targetMethod(); ResolvedJavaType leastCommonType = getLeastCommonType(); ResolvedJavaType contextType = invoke.getContextType(); diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java index b31b08818fbd..26ec55ea7cb6 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java @@ -191,12 +191,8 @@ private static ArrayList trackParameterUsages(ParameterNode param, ArrayLi @SuppressWarnings("try") private static StructuredGraph parseBytecodes(ResolvedJavaMethod method, HighTierContext context, CanonicalizerPhase canonicalizer, StructuredGraph caller, boolean trackNodeSourcePosition) { DebugContext debug = caller.getDebug(); - StructuredGraph newGraph = new StructuredGraph.Builder(caller.getOptions(), debug, caller.allowAssumptions()) - .method(method) - .trackNodeSourcePosition(trackNodeSourcePosition) - .useProfilingInfo(caller.useProfilingInfo()) - .speculationLog(caller.getSpeculationLog()) - .build(); + StructuredGraph newGraph = new StructuredGraph.Builder(caller.getOptions(), debug, caller.allowAssumptions()).method(method).trackNodeSourcePosition(trackNodeSourcePosition) + .useProfilingInfo(caller.useProfilingInfo()).speculationLog(caller.getSpeculationLog()).build(); try (DebugContext.Scope s = debug.scope("InlineGraph", newGraph)) { if (!caller.isUnsafeAccessTrackingEnabled()) { newGraph.disableUnsafeAccessTracking(); diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java index 40aa79bb37ef..c54c7c4fba4f 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java @@ -276,7 +276,7 @@ private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod ta final OptimisticOptimizations optimisticOpts = context.getOptimisticOptimizations(); OptionValues options = invoke.asNode().getOptions(); - boolean maySpeculate = true; + boolean speculationFailed = false; SpeculationLog speculationLog = graph.getSpeculationLog(); SpeculationLog.Speculation speculation = SpeculationLog.NO_SPECULATION; @@ -285,11 +285,11 @@ private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod ta if (speculationLog.maySpeculate(speculationReason)) { speculation = speculationLog.speculate(speculationReason); } else { - maySpeculate = false; + speculationFailed = true; } } - if (ptypes.length == 1 && notRecordedTypeProbability == 0 && maySpeculate) { + if (ptypes.length == 1 && notRecordedTypeProbability == 0 && !speculationFailed) { if (!optimisticOpts.inlineMonomorphicCalls(options)) { InliningUtil.traceNotInlinedMethod(invoke, inliningDepth(), targetMethod, "inlining monomorphic calls is disabled"); inliningLog.addDecision(invoke, false, "InliningPhase", null, null, "inlining monomorphic calls is disabled"); @@ -403,7 +403,7 @@ private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod ta return null; } } - return new MultiTypeGuardInlineInfo(invoke, concreteMethods, usedTypes, typesToConcretes, notRecordedTypeProbability, maySpeculate, speculation); + return new MultiTypeGuardInlineInfo(invoke, concreteMethods, usedTypes, typesToConcretes, notRecordedTypeProbability, speculationFailed, speculation); } } From 47501c25764966b3193fca74067e299ea97fa78c Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Thu, 10 Sep 2020 20:30:39 +0200 Subject: [PATCH 5/6] Assert upon inlining that callee and caller share the same speculation log, --- .../graalvm/compiler/phases/common/inlining/InliningUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java index af0b0dff9f8c..d78a7c939e7f 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java @@ -502,6 +502,7 @@ public static EconomicSet inlineForCanonicalization(Invoke invoke, Structu @SuppressWarnings("try") public static EconomicSet inlineForCanonicalization(Invoke invoke, StructuredGraph inlineGraph, boolean receiverNullCheck, ResolvedJavaMethod inlineeMethod, Consumer> duplicatesConsumer, String reason, String phase) { + assert invoke.asNode().graph().getSpeculationLog() == inlineGraph.getSpeculationLog(); EconomicSetNodeEventListener listener = new EconomicSetNodeEventListener(); /* * This code relies on the fact that Graph.addDuplicates doesn't trigger the From 98c1eb3c6e8bbc0961f65ab928f9c041cb5b7041 Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Fri, 11 Sep 2020 10:57:06 +0200 Subject: [PATCH 6/6] Update assert. --- .../graalvm/compiler/phases/common/inlining/InliningUtil.java | 2 +- .../phases/common/inlining/info/elem/InlineableGraph.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java index d78a7c939e7f..caca0c82322d 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/InliningUtil.java @@ -502,7 +502,7 @@ public static EconomicSet inlineForCanonicalization(Invoke invoke, Structu @SuppressWarnings("try") public static EconomicSet inlineForCanonicalization(Invoke invoke, StructuredGraph inlineGraph, boolean receiverNullCheck, ResolvedJavaMethod inlineeMethod, Consumer> duplicatesConsumer, String reason, String phase) { - assert invoke.asNode().graph().getSpeculationLog() == inlineGraph.getSpeculationLog(); + assert inlineGraph.isSubstitution() || invoke.asNode().graph().getSpeculationLog() == inlineGraph.getSpeculationLog(); EconomicSetNodeEventListener listener = new EconomicSetNodeEventListener(); /* * This code relies on the fact that Graph.addDuplicates doesn't trigger the diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java index 26ec55ea7cb6..37eb2b71fa05 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/info/elem/InlineableGraph.java @@ -191,8 +191,8 @@ private static ArrayList trackParameterUsages(ParameterNode param, ArrayLi @SuppressWarnings("try") private static StructuredGraph parseBytecodes(ResolvedJavaMethod method, HighTierContext context, CanonicalizerPhase canonicalizer, StructuredGraph caller, boolean trackNodeSourcePosition) { DebugContext debug = caller.getDebug(); - StructuredGraph newGraph = new StructuredGraph.Builder(caller.getOptions(), debug, caller.allowAssumptions()).method(method).trackNodeSourcePosition(trackNodeSourcePosition) - .useProfilingInfo(caller.useProfilingInfo()).speculationLog(caller.getSpeculationLog()).build(); + StructuredGraph newGraph = new StructuredGraph.Builder(caller.getOptions(), debug, caller.allowAssumptions()).method(method).trackNodeSourcePosition(trackNodeSourcePosition).useProfilingInfo( + caller.useProfilingInfo()).speculationLog(caller.getSpeculationLog()).build(); try (DebugContext.Scope s = debug.scope("InlineGraph", newGraph)) { if (!caller.isUnsafeAccessTrackingEnabled()) { newGraph.disableUnsafeAccessTracking();