Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-57553] Delay the canonicalization of TestDeoptimizeNode #9719

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, 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
Expand All @@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.hosted.nodes;
package com.oracle.svm.core.graal.nodes;

import com.oracle.svm.hosted.code.SubstrateCompilationDirectives;
import com.oracle.svm.core.BuildPhaseProvider;
import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.util.VMError;

import jdk.graal.compiler.core.common.type.StampFactory;
import jdk.graal.compiler.graph.Node;
Expand All @@ -40,8 +42,8 @@
import jdk.vm.ci.meta.DeoptimizationReason;

/**
* For deoptimzation testing. The node performs a deoptimization in a normally compiled method, but
* is a no-op in the deoptimization target method.
* For deoptimization testing. The node performs a deoptimization, but the lowering to
* DeoptimizeNode is delayed, so that the analysis sees a return from original method.
*/
@NodeInfo(cycles = NodeCycles.CYCLES_IGNORED, size = NodeSize.SIZE_IGNORED)
public class TestDeoptimizeNode extends FixedWithNextNode implements Canonicalizable {
Expand All @@ -53,12 +55,12 @@ public TestDeoptimizeNode() {

@Override
public Node canonical(CanonicalizerTool tool) {
if (SubstrateCompilationDirectives.isDeoptTarget(graph().method())) {
/* no-op for deoptimization target methods. */
return null;
} else {
/* deoptimization for all other methods. */
if (SubstrateUtil.HOSTED) {
if (!BuildPhaseProvider.isAnalysisFinished()) {
return this;
}
return new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.TransferToInterpreter);
}
throw VMError.shouldNotReachHere("Should only be used in hosted.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
import com.oracle.svm.core.graal.nodes.DeoptProxyAnchorNode;
import com.oracle.svm.core.graal.nodes.LoweredDeadEndNode;
import com.oracle.svm.core.graal.nodes.NewPodInstanceNode;
import com.oracle.svm.core.graal.nodes.TestDeoptimizeNode;
import com.oracle.svm.core.heap.Pod;
import com.oracle.svm.core.heap.Pod.RuntimeSupport.PodFactory;
import com.oracle.svm.hosted.annotation.CustomSubstitutionMethod;
import com.oracle.svm.hosted.code.SubstrateCompilationDirectives;
import com.oracle.svm.hosted.nodes.DeoptProxyNode;
import com.oracle.svm.hosted.nodes.TestDeoptimizeNode;
import com.oracle.svm.hosted.phases.HostedGraphKit;

import jdk.graal.compiler.core.common.type.StampFactory;
Expand Down Expand Up @@ -133,7 +133,9 @@ public StructuredGraph buildGraph(DebugContext debug, AnalysisMethod method, Hos
int nextDeoptIndex = startMethod(kit, deoptInfo, 0);
instantiatePod(kit, factoryType, podConcreteType, instanceLocal);
if (isAnnotationPresent(DeoptTest.class)) {
kit.append(new TestDeoptimizeNode());
if (!SubstrateCompilationDirectives.isDeoptTarget(method)) {
kit.append(new TestDeoptimizeNode());
}
}
nextDeoptIndex = invokeConstructor(kit, deoptInfo, nextDeoptIndex, targetCtor, instanceLocal);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import com.oracle.svm.core.graal.nodes.SubstrateCompressionNode;
import com.oracle.svm.core.graal.nodes.SubstrateNarrowOopStamp;
import com.oracle.svm.core.graal.nodes.SubstrateReflectionGetCallerClassNode;
import com.oracle.svm.core.graal.nodes.TestDeoptimizeNode;
import com.oracle.svm.core.graal.stackvalue.LateStackValueNode;
import com.oracle.svm.core.graal.stackvalue.StackValueNode;
import com.oracle.svm.core.graal.stackvalue.UnsafeLateStackValue;
Expand All @@ -100,7 +101,6 @@
import com.oracle.svm.hosted.code.SubstrateCompilationDirectives;
import com.oracle.svm.hosted.nodes.DeoptProxyNode;
import com.oracle.svm.hosted.nodes.ReadReservedRegister;
import com.oracle.svm.hosted.nodes.TestDeoptimizeNode;
import com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor;

import jdk.graal.compiler.core.common.CompressEncoding;
Expand Down Expand Up @@ -951,7 +951,9 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
r.register(new RequiredInvocationPlugin("testDeoptimize") {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.add(new TestDeoptimizeNode());
if (!SubstrateCompilationDirectives.isDeoptTarget(b.getMethod())) {
b.add(new TestDeoptimizeNode());
}
return true;
}
});
Expand Down
Loading