Skip to content

Commit e8c3dd4

Browse files
committed
Adjust VerifyDebugUsage to allow parameterized dumpLevel in calls to DebugContext#dump from explicitly listed methods.
1 parent 21e00a6 commit e8c3dd4

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/VerifyDebugUsage.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ protected void verify(StructuredGraph graph, CoreProviders context) {
137137
MethodSource.of("com.oracle.graal.pointsto.phases.InlineBeforeAnalysis", "decodeGraph"),
138138
MethodSource.of("com.oracle.svm.hosted.classinitialization.SimulateClassInitializerSupport", "decodeGraph"),
139139
MethodSource.of("com.oracle.svm.hosted.classinitialization.SimulateClassInitializerAbortException", "doAbort"),
140-
MethodSource.of(CallTree.class, "dumpBasic"),
141-
MethodSource.of(CallTree.class, "GraphManager", "peRoot"));
140+
MethodSource.of(CallTree.class, "dumpBasic"));
142141

143142
/**
144143
* The set of methods allowed to call a {@code Debug.dump(...)} method with the {@code level}
@@ -156,7 +155,17 @@ protected void verify(StructuredGraph graph, CoreProviders context) {
156155
MethodSource.of(SnippetTemplate.class, "instantiate"),
157156
MethodSource.of(SnippetTemplate.class, "<init>"),
158157
MethodSource.of(SymbolicSnippetEncoder.class, "verifySnippetEncodeDecode"),
159-
MethodSource.of(CallTree.class, "dumpInfo"),
158+
MethodSource.of(CallTree.class, "dumpInfo"));
159+
160+
/**
161+
* The set of methods allowed to call a {@code Debug.dump(...)} method with a variable
162+
* {@code level} parameter and the {@code object} parameter bound to a {@link StructuredGraph}
163+
* value.
164+
*
165+
* If you add a *justified* graph dump with variable level parameter, then update the allow
166+
* list.
167+
*/
168+
private static final Set<MethodSource> ParameterizedLevelStructuredGraphDumpAllowList = CollectionsUtil.setOf(
160169
MethodSource.of(CallTree.class, "GraphManager", "pe"));
161170

162171
@Override
@@ -175,7 +184,10 @@ protected void verifyParameters(MetaAccessProvider metaAccess1, MethodCallTarget
175184
allowedClasses.add(ReportHotCodePhase.class.getName());
176185
String callerClassName = debugCallTarget.graph().method().format("%H");
177186
if (!allowedClasses.contains(callerClassName)) {
178-
int dumpLevel = verifyDumpLevelParameter(debugCallTarget, verifiedCallee, args.get(1));
187+
ResolvedJavaMethod callerMethod = debugCallTarget.graph().method();
188+
Integer dumpLevel = ParameterizedLevelStructuredGraphDumpAllowList.stream().noneMatch(ms -> ms.matches(callerMethod))
189+
? verifyDumpLevelParameter(debugCallTarget, verifiedCallee, args.get(1))
190+
: null;
179191
verifyDumpObjectParameter(debugCallTarget, args.get(2), verifiedCallee, dumpLevel);
180192
}
181193
}
@@ -220,7 +232,13 @@ protected void verifyDumpObjectParameter(MethodCallTargetNode debugCallTarget, V
220232
protected void verifyStructuredGraphDumping(MethodCallTargetNode debugCallTarget, ResolvedJavaMethod verifiedCallee, Integer dumpLevel)
221233
throws VerifyPhase.VerificationError {
222234
ResolvedJavaMethod method = debugCallTarget.graph().method();
223-
if (dumpLevel == DebugContext.BASIC_LEVEL) {
235+
if (dumpLevel == null) {
236+
if (ParameterizedLevelStructuredGraphDumpAllowList.stream().noneMatch(ms -> ms.matches(method))) {
237+
throw new VerificationError(
238+
debugCallTarget, "call to %s with parameterized level not in %s.ParameterizedLevelStructuredGraphDumpAllowList.%n", verifiedCallee.format("%H.%n(%p)"),
239+
getClass().getName());
240+
}
241+
} else if (dumpLevel == DebugContext.BASIC_LEVEL) {
224242
if (BasicLevelStructuredGraphDumpAllowList.stream().noneMatch(ms -> ms.matches(method))) {
225243
throw new VerificationError(
226244
debugCallTarget, "call to %s with level == DebugContext.BASIC_LEVEL not in %s.BasicLevelStructuredGraphDumpAllowList.%n", verifiedCallee.format("%H.%n(%p)"),

0 commit comments

Comments
 (0)