133 Arrays.asList(DebugContext.ENABLED_LEVEL, BASIC_LEVEL, DebugContext.INFO_LEVEL, DebugContext.VERBOSE_LEVEL, DebugContext.DETAILED_LEVEL, DebugContext.VERY_DETAILED_LEVEL)); 134 135 /** 136 * The set of methods allowed to call a {@code Debug.dump(...)} method with the {@code level} 137 * parameter bound to {@link DebugContext#BASIC_LEVEL} and the {@code object} parameter bound to 138 * a {@link StructuredGraph} value. 139 * 140 * This whitelist exists to ensure any increase in graph dumps is in line with the policy 141 * outlined by {@link DebugContext#BASIC_LEVEL}. If you add a *justified* graph dump at this 142 * level, then update the whitelist. 143 */ 144 private static final Set<String> BasicLevelStructuredGraphDumpWhitelist = new HashSet<>(Arrays.asList( 145 "org.graalvm.compiler.phases.BasePhase.dumpAfter", 146 "org.graalvm.compiler.phases.BasePhase.dumpBefore", 147 "org.graalvm.compiler.core.GraalCompiler.emitFrontEnd", 148 "org.graalvm.compiler.truffle.compiler.PartialEvaluator.fastPartialEvaluation", 149 "org.graalvm.compiler.truffle.compiler.PartialEvaluator$PerformanceInformationHandler.reportPerformanceWarnings", 150 "org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl.compilePEGraph", 151 "org.graalvm.compiler.core.test.VerifyDebugUsageTest$ValidDumpUsagePhase.run", 152 "org.graalvm.compiler.core.test.VerifyDebugUsageTest$InvalidConcatDumpUsagePhase.run", 153 "org.graalvm.compiler.core.test.VerifyDebugUsageTest$InvalidDumpUsagePhase.run")); 154 155 /** 156 * The set of methods allowed to call a {@code Debug.dump(...)} method with the {@code level} 157 * parameter bound to {@link DebugContext#INFO_LEVEL} and the {@code object} parameter bound to 158 * a {@link StructuredGraph} value. 159 * 160 * This whitelist exists to ensure any increase in graph dumps is in line with the policy 161 * outlined by {@link DebugContext#INFO_LEVEL}. If you add a *justified* graph dump at this 162 * level, then update the whitelist. 163 */ 164 private static final Set<String> InfoLevelStructuredGraphDumpWhitelist = new HashSet<>(Arrays.asList( 165 "org.graalvm.compiler.core.GraalCompiler.emitFrontEnd", 166 "org.graalvm.compiler.phases.BasePhase.dumpAfter", 167 "org.graalvm.compiler.replacements.ReplacementsImpl$GraphMaker.makeGraph", 168 "org.graalvm.compiler.replacements.SnippetTemplate.instantiate")); 169 170 private void verifyParameters(StructuredGraph callerGraph, MethodCallTargetNode debugCallTarget, List<? extends ValueNode> args, ResolvedJavaType stringType, int startArgIdx, 171 int varArgsIndex) { 172 ResolvedJavaMethod verifiedCallee = debugCallTarget.targetMethod(); 173 Integer dumpLevel = null; 174 int argIdx = startArgIdx; 175 int varArgsElementIndex = 0; 176 boolean reportVarArgs = false; 177 for (int i = 0; i < args.size(); i++) { 178 ValueNode arg = args.get(i); 179 if (arg instanceof Invoke) { 180 reportVarArgs = varArgsIndex >= 0 && argIdx >= varArgsIndex; 181 Invoke invoke = (Invoke) arg; 182 CallTargetNode callTarget = invoke.callTarget(); 183 if (callTarget instanceof MethodCallTargetNode) { 184 ResolvedJavaMethod m = ((MethodCallTargetNode) callTarget).targetMethod(); 185 if (m.getName().equals("toString")) { 186 int bci = invoke.bci(); 187 int nonVarArgIdx = reportVarArgs ? argIdx - varArgsElementIndex : argIdx; 188 verifyStringConcat(callerGraph, verifiedCallee, bci, nonVarArgIdx, reportVarArgs ? varArgsElementIndex : -1, m); | 133 Arrays.asList(DebugContext.ENABLED_LEVEL, BASIC_LEVEL, DebugContext.INFO_LEVEL, DebugContext.VERBOSE_LEVEL, DebugContext.DETAILED_LEVEL, DebugContext.VERY_DETAILED_LEVEL)); 134 135 /** 136 * The set of methods allowed to call a {@code Debug.dump(...)} method with the {@code level} 137 * parameter bound to {@link DebugContext#BASIC_LEVEL} and the {@code object} parameter bound to 138 * a {@link StructuredGraph} value. 139 * 140 * This whitelist exists to ensure any increase in graph dumps is in line with the policy 141 * outlined by {@link DebugContext#BASIC_LEVEL}. If you add a *justified* graph dump at this 142 * level, then update the whitelist. 143 */ 144 private static final Set<String> BasicLevelStructuredGraphDumpWhitelist = new HashSet<>(Arrays.asList( 145 "org.graalvm.compiler.phases.BasePhase.dumpAfter", 146 "org.graalvm.compiler.phases.BasePhase.dumpBefore", 147 "org.graalvm.compiler.core.GraalCompiler.emitFrontEnd", 148 "org.graalvm.compiler.truffle.compiler.PartialEvaluator.fastPartialEvaluation", 149 "org.graalvm.compiler.truffle.compiler.PartialEvaluator$PerformanceInformationHandler.reportPerformanceWarnings", 150 "org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl.compilePEGraph", 151 "org.graalvm.compiler.core.test.VerifyDebugUsageTest$ValidDumpUsagePhase.run", 152 "org.graalvm.compiler.core.test.VerifyDebugUsageTest$InvalidConcatDumpUsagePhase.run", 153 "org.graalvm.compiler.core.test.VerifyDebugUsageTest$InvalidDumpUsagePhase.run", 154 "org.graalvm.compiler.hotspot.SymbolicSnippetEncoder.verifySnippetEncodeDecode")); 155 156 /** 157 * The set of methods allowed to call a {@code Debug.dump(...)} method with the {@code level} 158 * parameter bound to {@link DebugContext#INFO_LEVEL} and the {@code object} parameter bound to 159 * a {@link StructuredGraph} value. 160 * 161 * This whitelist exists to ensure any increase in graph dumps is in line with the policy 162 * outlined by {@link DebugContext#INFO_LEVEL}. If you add a *justified* graph dump at this 163 * level, then update the whitelist. 164 */ 165 private static final Set<String> InfoLevelStructuredGraphDumpWhitelist = new HashSet<>(Arrays.asList( 166 "org.graalvm.compiler.core.GraalCompiler.emitFrontEnd", 167 "org.graalvm.compiler.phases.BasePhase.dumpAfter", 168 "org.graalvm.compiler.replacements.ReplacementsImpl$GraphMaker.makeGraph", 169 "org.graalvm.compiler.replacements.SnippetTemplate.instantiate", 170 "org.graalvm.compiler.hotspot.SymbolicSnippetEncoder.verifySnippetEncodeDecode")); 171 172 private void verifyParameters(StructuredGraph callerGraph, MethodCallTargetNode debugCallTarget, List<? extends ValueNode> args, ResolvedJavaType stringType, int startArgIdx, 173 int varArgsIndex) { 174 ResolvedJavaMethod verifiedCallee = debugCallTarget.targetMethod(); 175 Integer dumpLevel = null; 176 int argIdx = startArgIdx; 177 int varArgsElementIndex = 0; 178 boolean reportVarArgs = false; 179 for (int i = 0; i < args.size(); i++) { 180 ValueNode arg = args.get(i); 181 if (arg instanceof Invoke) { 182 reportVarArgs = varArgsIndex >= 0 && argIdx >= varArgsIndex; 183 Invoke invoke = (Invoke) arg; 184 CallTargetNode callTarget = invoke.callTarget(); 185 if (callTarget instanceof MethodCallTargetNode) { 186 ResolvedJavaMethod m = ((MethodCallTargetNode) callTarget).targetMethod(); 187 if (m.getName().equals("toString")) { 188 int bci = invoke.bci(); 189 int nonVarArgIdx = reportVarArgs ? argIdx - varArgsElementIndex : argIdx; 190 verifyStringConcat(callerGraph, verifiedCallee, bci, nonVarArgIdx, reportVarArgs ? varArgsElementIndex : -1, m); |