Skip to content

Commit e978b74

Browse files
committed
Move checks in CachingPEGraphDecoder to outermost method
1 parent d9ec03d commit e978b74

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/CachingPEGraphDecoder.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
*/
2525
package jdk.graal.compiler.replacements;
2626

27-
import static jdk.graal.compiler.core.common.NativeImageSupport.inRuntimeCode;
28-
2927
import java.util.concurrent.ConcurrentHashMap;
3028
import java.util.function.Supplier;
3129

@@ -118,14 +116,9 @@ public CachingPEGraphDecoder(Architecture architecture,
118116
}
119117

120118
@SuppressWarnings("try")
121-
private EncodedGraph createGraph(ResolvedJavaMethod method, BytecodeProvider intrinsicBytecodeProvider) {
119+
private EncodedGraph createGraph(ResolvedJavaMethod method) {
122120
CanonicalizerPhase canonicalizer = CanonicalizerPhase.create();
123-
StructuredGraph graphToEncode;
124-
if (graph.isSubstitution() && inRuntimeCode()) {
125-
throw GraalError.shouldNotReachHere("dead path"); // ExcludeFromJacocoGeneratedReport
126-
} else {
127-
graphToEncode = buildGraph(method, intrinsicBytecodeProvider, canonicalizer);
128-
}
121+
StructuredGraph graphToEncode = buildGraph(method, canonicalizer);
129122

130123
/*
131124
* ConvertDeoptimizeToGuardPhase reduces the number of merges in the graph, so that fewer
@@ -145,7 +138,7 @@ private EncodedGraph createGraph(ResolvedJavaMethod method, BytecodeProvider int
145138
}
146139

147140
@SuppressWarnings("try")
148-
private StructuredGraph buildGraph(ResolvedJavaMethod method, BytecodeProvider intrinsicBytecodeProvider, CanonicalizerPhase canonicalizer) {
141+
private StructuredGraph buildGraph(ResolvedJavaMethod method, CanonicalizerPhase canonicalizer) {
149142
StructuredGraph graphToEncode;
150143
/*
151144
* Always parse graphs without assumptions, this is required when graphs are cached across
@@ -163,9 +156,6 @@ private StructuredGraph buildGraph(ResolvedJavaMethod method, BytecodeProvider i
163156
build();
164157
// @formatter:on
165158
try (DebugContext.Scope scope = debug.scope("buildGraph", graphToEncode); DebugCloseable a = BuildGraphTimer.start(debug)) {
166-
if (intrinsicBytecodeProvider != null) {
167-
throw GraalError.shouldNotReachHere("isn't this dead?"); // ExcludeFromJacocoGeneratedReport
168-
}
169159
graphBuilderPhaseInstance.apply(graphToEncode);
170160
canonicalizer.apply(graphToEncode, graphCacheProviders);
171161
if (postParsingPhase != null) {
@@ -177,14 +167,14 @@ private StructuredGraph buildGraph(ResolvedJavaMethod method, BytecodeProvider i
177167
return graphToEncode;
178168
}
179169

180-
@SuppressWarnings({"unused", "try"})
181-
private EncodedGraph lookupOrCreatePersistentEncodedGraph(ResolvedJavaMethod method, BytecodeProvider intrinsicBytecodeProvider) {
170+
@SuppressWarnings("try")
171+
private EncodedGraph lookupOrCreatePersistentEncodedGraph(ResolvedJavaMethod method) {
182172
EncodedGraph result = persistentGraphCache.get(method);
183173
if (result == null && method.hasBytecodes()) {
184174
try (AutoCloseable scope = createPersistentCachedGraphScope.get()) {
185175
// Encoded graphs creation must be wrapped by "scopes" provided by
186176
// createCachedGraphScope.
187-
result = createGraph(method, intrinsicBytecodeProvider);
177+
result = createGraph(method);
188178
} catch (Throwable ex) {
189179
throw debug.handle(ex);
190180
}
@@ -195,17 +185,22 @@ private EncodedGraph lookupOrCreatePersistentEncodedGraph(ResolvedJavaMethod met
195185

196186
@Override
197187
protected EncodedGraph lookupEncodedGraph(ResolvedJavaMethod method, BytecodeProvider intrinsicBytecodeProvider) {
188+
if (intrinsicBytecodeProvider != null) {
189+
// intrinsicBytecodeProvider is read from InlineInvokePlugin.InlineInfo#getIntrinsicBytecodeProvider which is always null because the only source is PartialEvaluator#asInlineInfo
190+
throw GraalError.shouldNotReachHere("dead path"); // ExcludeFromJacocoGeneratedReport
191+
}
192+
198193
EncodedGraph result = localGraphCache.get(method);
199194
if (result != null) {
200195
return result;
201196
}
202197

203-
result = lookupOrCreatePersistentEncodedGraph(method, intrinsicBytecodeProvider);
198+
result = lookupOrCreatePersistentEncodedGraph(method);
204199
// Cached graph from previous compilation may not have source positions, re-parse and
205200
// store in compilation-local cache.
206201
if (result != null && !result.trackNodeSourcePosition() && graph.trackNodeSourcePosition()) {
207202
assert method.hasBytecodes();
208-
result = createGraph(method, intrinsicBytecodeProvider);
203+
result = createGraph(method);
209204
assert result.trackNodeSourcePosition();
210205
}
211206

0 commit comments

Comments
 (0)