Skip to content

Commit a76eff1

Browse files
committed
Add node source positions to pod factory methods for inlining in runtime compilations.
1 parent 1455675 commit a76eff1

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/replacements/SubstrateGraphKit.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public class SubstrateGraphKit extends GraphKit {
9696
private final FrameStateBuilder frameState;
9797
private int nextBCI;
9898

99-
public SubstrateGraphKit(DebugContext debug, ResolvedJavaMethod stubMethod, Providers providers, WordTypes wordTypes, GraphBuilderConfiguration.Plugins graphBuilderPlugins,
100-
CompilationIdentifier compilationId) {
101-
super(debug, stubMethod, providers, wordTypes, graphBuilderPlugins, compilationId, null, SubstrateOptions.parseOnce(), false);
99+
public SubstrateGraphKit(DebugContext debug, ResolvedJavaMethod stubMethod, Providers providers, WordTypes wordTypes,
100+
GraphBuilderConfiguration.Plugins graphBuilderPlugins, CompilationIdentifier compilationId, boolean forceTrackNodeSourcePosition) {
101+
super(debug, stubMethod, providers, wordTypes, graphBuilderPlugins, compilationId, null, forceTrackNodeSourcePosition || SubstrateOptions.parseOnce(), false);
102102
assert wordTypes != null : "Support for Word types is mandatory";
103103
frameState = new FrameStateBuilder(this, stubMethod, graph);
104104
frameState.disableKindVerification();

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/PodFactorySubstitutionMethod.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.graalvm.compiler.core.common.type.StampFactory;
3333
import org.graalvm.compiler.debug.DebugContext;
3434
import org.graalvm.compiler.debug.GraalError;
35+
import org.graalvm.compiler.graph.NodeSourcePosition;
3536
import org.graalvm.compiler.nodes.CallTargetNode.InvokeKind;
3637
import org.graalvm.compiler.nodes.ConstantNode;
3738
import org.graalvm.compiler.nodes.FixedNode;
@@ -103,7 +104,11 @@ public int getModifiers() {
103104

104105
@Override
105106
public StructuredGraph buildGraph(DebugContext debug, ResolvedJavaMethod method, HostedProviders providers, Purpose purpose) {
106-
HostedGraphKit kit = new HostedGraphKit(debug, providers, method);
107+
// Needed to match type flows to invokes so invoked methods can be inlined in runtime
108+
// compilations, see GraalFeature.processMethod() and MethodTypeFlowBuilder.uniqueKey()
109+
boolean trackNodeSourcePosition = (purpose == Purpose.ANALYSIS);
110+
111+
HostedGraphKit kit = new HostedGraphKit(debug, providers, method, trackNodeSourcePosition);
107112
boolean isDeoptTarget = (method instanceof SharedMethod) && ((SharedMethod) method).isDeoptTarget();
108113

109114
ResolvedJavaType factoryType = method.getDeclaringClass();
@@ -168,7 +173,9 @@ private static int invokeConstructor(HostedGraphKit kit, ResolvedJavaMethod meth
168173

169174
/** @see com.oracle.svm.hosted.phases.HostedGraphBuilderPhase */
170175
private static int invokeWithDeoptAndExceptionUnwind(HostedGraphKit kit, boolean isDeoptTarget, int initialNextDeoptIndex, ResolvedJavaMethod target, InvokeKind invokeKind, ValueNode... args) {
171-
InvokeWithExceptionNode invoke = kit.startInvokeWithException(target, invokeKind, kit.getFrameState(), kit.bci(), args);
176+
int bci = kit.bci();
177+
InvokeWithExceptionNode invoke = kit.startInvokeWithException(target, invokeKind, kit.getFrameState(), bci, args);
178+
invoke.setNodeSourcePosition(NodeSourcePosition.placeholder(kit.getGraph().method(), bci));
172179
kit.exceptionPart();
173180
ExceptionObjectNode exception = kit.exceptionObject();
174181

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/HostedGraphKit.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@
7070
public class HostedGraphKit extends SubstrateGraphKit {
7171

7272
public HostedGraphKit(DebugContext debug, HostedProviders providers, ResolvedJavaMethod method) {
73-
super(debug, method, providers, providers.getWordTypes(), providers.getGraphBuilderPlugins(), new SubstrateCompilationIdentifier());
73+
this(debug, providers, method, false);
74+
}
75+
76+
public HostedGraphKit(DebugContext debug, HostedProviders providers, ResolvedJavaMethod method, boolean forceTrackNodeSourcePosition) {
77+
super(debug, method, providers, providers.getWordTypes(), providers.getGraphBuilderPlugins(), new SubstrateCompilationIdentifier(), forceTrackNodeSourcePosition);
7478
}
7579

7680
@Override

0 commit comments

Comments
 (0)