43972
|
1 |
/*
|
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
50858
|
23 |
|
|
24 |
|
43972
|
25 |
package org.graalvm.compiler.core.test;
|
|
26 |
|
|
27 |
import java.io.File;
|
|
28 |
import java.io.IOException;
|
|
29 |
import java.io.PrintWriter;
|
|
30 |
import java.io.StringWriter;
|
46344
|
31 |
import java.lang.annotation.Annotation;
|
43972
|
32 |
import java.lang.reflect.Method;
|
|
33 |
import java.lang.reflect.Modifier;
|
|
34 |
import java.util.ArrayList;
|
|
35 |
import java.util.Collections;
|
|
36 |
import java.util.Enumeration;
|
|
37 |
import java.util.List;
|
|
38 |
import java.util.concurrent.LinkedBlockingQueue;
|
|
39 |
import java.util.concurrent.ThreadPoolExecutor;
|
|
40 |
import java.util.concurrent.TimeUnit;
|
|
41 |
import java.util.zip.ZipEntry;
|
|
42 |
import java.util.zip.ZipFile;
|
|
43 |
|
46344
|
44 |
import org.graalvm.compiler.api.replacements.Snippet;
|
|
45 |
import org.graalvm.compiler.api.replacements.Snippet.ConstantParameter;
|
|
46 |
import org.graalvm.compiler.api.replacements.Snippet.NonNullParameter;
|
|
47 |
import org.graalvm.compiler.api.replacements.Snippet.VarargsParameter;
|
43972
|
48 |
import org.graalvm.compiler.api.test.Graal;
|
|
49 |
import org.graalvm.compiler.bytecode.BridgeMethodUtils;
|
|
50 |
import org.graalvm.compiler.core.CompilerThreadFactory;
|
|
51 |
import org.graalvm.compiler.core.common.LIRKind;
|
|
52 |
import org.graalvm.compiler.core.common.type.ArithmeticOpTable;
|
46640
|
53 |
import org.graalvm.compiler.debug.DebugCloseable;
|
47798
|
54 |
import org.graalvm.compiler.debug.DebugContext;
|
46640
|
55 |
import org.graalvm.compiler.debug.DebugHandlersFactory;
|
46393
|
56 |
import org.graalvm.compiler.debug.GraalError;
|
43972
|
57 |
import org.graalvm.compiler.graph.Node;
|
|
58 |
import org.graalvm.compiler.graph.NodeClass;
|
|
59 |
import org.graalvm.compiler.java.GraphBuilderPhase;
|
|
60 |
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
|
61 |
import org.graalvm.compiler.nodes.PhiNode;
|
|
62 |
import org.graalvm.compiler.nodes.StructuredGraph;
|
|
63 |
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
|
64 |
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
|
|
65 |
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
|
|
66 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
46344
|
67 |
import org.graalvm.compiler.options.OptionValues;
|
43972
|
68 |
import org.graalvm.compiler.phases.OptimisticOptimizations;
|
|
69 |
import org.graalvm.compiler.phases.PhaseSuite;
|
|
70 |
import org.graalvm.compiler.phases.VerifyPhase;
|
|
71 |
import org.graalvm.compiler.phases.VerifyPhase.VerificationError;
|
46393
|
72 |
import org.graalvm.compiler.phases.contract.VerifyNodeCosts;
|
43972
|
73 |
import org.graalvm.compiler.phases.tiers.HighTierContext;
|
|
74 |
import org.graalvm.compiler.phases.util.Providers;
|
|
75 |
import org.graalvm.compiler.phases.verify.VerifyBailoutUsage;
|
|
76 |
import org.graalvm.compiler.phases.verify.VerifyCallerSensitiveMethods;
|
|
77 |
import org.graalvm.compiler.phases.verify.VerifyDebugUsage;
|
47798
|
78 |
import org.graalvm.compiler.phases.verify.VerifyGetOptionsUsage;
|
|
79 |
import org.graalvm.compiler.phases.verify.VerifyGraphAddUsage;
|
46459
|
80 |
import org.graalvm.compiler.phases.verify.VerifyInstanceOfUsage;
|
43972
|
81 |
import org.graalvm.compiler.phases.verify.VerifyUpdateUsages;
|
|
82 |
import org.graalvm.compiler.phases.verify.VerifyUsageWithEquals;
|
|
83 |
import org.graalvm.compiler.phases.verify.VerifyVirtualizableUsage;
|
|
84 |
import org.graalvm.compiler.runtime.RuntimeProvider;
|
49873
|
85 |
import jdk.internal.vm.compiler.word.LocationIdentity;
|
46344
|
86 |
import org.junit.Assert;
|
|
87 |
import org.junit.Assume;
|
|
88 |
import org.junit.Test;
|
43972
|
89 |
|
|
90 |
import jdk.vm.ci.code.BailoutException;
|
|
91 |
import jdk.vm.ci.code.Register;
|
|
92 |
import jdk.vm.ci.code.Register.RegisterCategory;
|
|
93 |
import jdk.vm.ci.meta.JavaField;
|
|
94 |
import jdk.vm.ci.meta.JavaMethod;
|
|
95 |
import jdk.vm.ci.meta.JavaType;
|
|
96 |
import jdk.vm.ci.meta.MetaAccessProvider;
|
|
97 |
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
|
98 |
import jdk.vm.ci.meta.ResolvedJavaType;
|
|
99 |
import jdk.vm.ci.meta.Value;
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Checks that all classes in *graal*.jar and *jvmci*.jar entries on the boot class path comply with
|
|
103 |
* global invariants such as using {@link Object#equals(Object)} to compare certain types instead of
|
|
104 |
* identity comparisons.
|
|
105 |
*/
|
46344
|
106 |
public class CheckGraalInvariants extends GraalCompilerTest {
|
43972
|
107 |
|
|
108 |
private static boolean shouldVerifyEquals(ResolvedJavaMethod m) {
|
|
109 |
if (m.getName().equals("identityEquals")) {
|
|
110 |
ResolvedJavaType c = m.getDeclaringClass();
|
|
111 |
if (c.getName().equals("Ljdk/vm/ci/meta/AbstractValue;") || c.getName().equals("jdk/vm/ci/meta/Value")) {
|
|
112 |
return false;
|
|
113 |
}
|
|
114 |
}
|
|
115 |
|
|
116 |
return true;
|
|
117 |
}
|
|
118 |
|
46393
|
119 |
public static String relativeFileName(String absolutePath) {
|
|
120 |
int lastFileSeparatorIndex = absolutePath.lastIndexOf(File.separator);
|
|
121 |
return absolutePath.substring(lastFileSeparatorIndex >= 0 ? lastFileSeparatorIndex : 0);
|
|
122 |
}
|
|
123 |
|
|
124 |
public static class InvariantsTool {
|
|
125 |
|
|
126 |
protected boolean shouldProcess(String classpathEntry) {
|
|
127 |
if (classpathEntry.endsWith(".jar")) {
|
|
128 |
String name = new File(classpathEntry).getName();
|
|
129 |
return name.contains("jvmci") || name.contains("graal") || name.contains("jdk.internal.vm.compiler");
|
|
130 |
}
|
|
131 |
return false;
|
43972
|
132 |
}
|
46393
|
133 |
|
|
134 |
protected String getClassPath() {
|
|
135 |
String bootclasspath;
|
|
136 |
if (Java8OrEarlier) {
|
|
137 |
bootclasspath = System.getProperty("sun.boot.class.path");
|
|
138 |
} else {
|
|
139 |
bootclasspath = System.getProperty("jdk.module.path") + File.pathSeparatorChar + System.getProperty("jdk.module.upgrade.path");
|
|
140 |
}
|
|
141 |
return bootclasspath;
|
|
142 |
}
|
|
143 |
|
|
144 |
protected boolean shouldLoadClass(String className) {
|
51436
|
145 |
if (className.equals("module-info") || className.startsWith("META-INF.versions.")) {
|
|
146 |
return false;
|
|
147 |
}
|
|
148 |
if (!Java8OrEarlier) {
|
|
149 |
// @formatter:off
|
|
150 |
/*
|
|
151 |
* Work around to prevent:
|
|
152 |
*
|
|
153 |
* org.graalvm.compiler.debug.GraalError: java.lang.IllegalAccessError: class org.graalvm.compiler.serviceprovider.GraalServices$Lazy (in module
|
|
154 |
* jdk.internal.vm.compiler) cannot access class java.lang.management.ManagementFactory (in module java.management) because module
|
|
155 |
* jdk.internal.vm.compiler does not read module java.management
|
|
156 |
* at jdk.internal.vm.compiler/org.graalvm.compiler.debug.GraalError.shouldNotReachHere(GraalError.java:55)
|
|
157 |
* at org.graalvm.compiler.core.test.CheckGraalInvariants$InvariantsTool.handleClassLoadingException(CheckGraalInvariants.java:149)
|
|
158 |
* at org.graalvm.compiler.core.test.CheckGraalInvariants.initializeClasses(CheckGraalInvariants.java:321)
|
|
159 |
* at org.graalvm.compiler.core.test.CheckGraalInvariants.runTest(CheckGraalInvariants.java:239)
|
|
160 |
*
|
|
161 |
* which occurs because JDK8 overlays are in modular jars. They are never used normally.
|
|
162 |
*/
|
|
163 |
// @formatter:on
|
|
164 |
if (className.equals("org.graalvm.compiler.serviceprovider.GraalServices$Lazy")) {
|
|
165 |
return false;
|
|
166 |
}
|
|
167 |
}
|
|
168 |
return true;
|
46393
|
169 |
}
|
|
170 |
|
|
171 |
protected void handleClassLoadingException(Throwable t) {
|
|
172 |
GraalError.shouldNotReachHere(t);
|
|
173 |
}
|
|
174 |
|
|
175 |
protected void handleParsingException(Throwable t) {
|
|
176 |
GraalError.shouldNotReachHere(t);
|
|
177 |
}
|
43972
|
178 |
}
|
|
179 |
|
|
180 |
@Test
|
|
181 |
@SuppressWarnings("try")
|
|
182 |
public void test() {
|
46393
|
183 |
runTest(new InvariantsTool());
|
|
184 |
}
|
|
185 |
|
|
186 |
@SuppressWarnings("try")
|
|
187 |
public static void runTest(InvariantsTool tool) {
|
43972
|
188 |
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
|
|
189 |
Providers providers = rt.getHostBackend().getProviders();
|
|
190 |
MetaAccessProvider metaAccess = providers.getMetaAccess();
|
|
191 |
|
|
192 |
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
|
46459
|
193 |
Plugins plugins = new Plugins(new InvocationPlugins());
|
47667
|
194 |
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
|
43972
|
195 |
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
|
|
196 |
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
|
|
197 |
|
|
198 |
Assume.assumeTrue(VerifyPhase.class.desiredAssertionStatus());
|
|
199 |
|
46393
|
200 |
String bootclasspath = tool.getClassPath();
|
46344
|
201 |
Assert.assertNotNull("Cannot find boot class path", bootclasspath);
|
43972
|
202 |
|
|
203 |
final List<String> classNames = new ArrayList<>();
|
|
204 |
for (String path : bootclasspath.split(File.pathSeparator)) {
|
46393
|
205 |
if (tool.shouldProcess(path)) {
|
43972
|
206 |
try {
|
|
207 |
final ZipFile zipFile = new ZipFile(new File(path));
|
|
208 |
for (final Enumeration<? extends ZipEntry> entry = zipFile.entries(); entry.hasMoreElements();) {
|
|
209 |
final ZipEntry zipEntry = entry.nextElement();
|
|
210 |
String name = zipEntry.getName();
|
49873
|
211 |
if (name.endsWith(".class") && !name.startsWith("META-INF/versions/")) {
|
43972
|
212 |
String className = name.substring(0, name.length() - ".class".length()).replace('/', '.');
|
46680
|
213 |
if (isInNativeImage(className)) {
|
|
214 |
/*
|
|
215 |
* Native Image is an external tool and does not need to follow the
|
|
216 |
* Graal invariants.
|
|
217 |
*/
|
|
218 |
continue;
|
|
219 |
}
|
43972
|
220 |
classNames.add(className);
|
|
221 |
}
|
|
222 |
}
|
|
223 |
} catch (IOException ex) {
|
|
224 |
Assert.fail(ex.toString());
|
|
225 |
}
|
|
226 |
}
|
|
227 |
}
|
|
228 |
Assert.assertFalse("Could not find graal jars on boot class path: " + bootclasspath, classNames.isEmpty());
|
|
229 |
|
|
230 |
// Allows a subset of methods to be checked through use of a system property
|
|
231 |
String property = System.getProperty(CheckGraalInvariants.class.getName() + ".filters");
|
|
232 |
String[] filters = property == null ? null : property.split(",");
|
|
233 |
|
46344
|
234 |
OptionValues options = getInitialOptions();
|
46640
|
235 |
CompilerThreadFactory factory = new CompilerThreadFactory("CheckInvariantsThread");
|
43972
|
236 |
int availableProcessors = Runtime.getRuntime().availableProcessors();
|
|
237 |
ThreadPoolExecutor executor = new ThreadPoolExecutor(availableProcessors, availableProcessors, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory);
|
|
238 |
|
|
239 |
List<String> errors = Collections.synchronizedList(new ArrayList<>());
|
|
240 |
|
46344
|
241 |
for (Method m : BadUsageWithEquals.class.getDeclaredMethods()) {
|
|
242 |
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
|
46640
|
243 |
try (DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER)) {
|
|
244 |
StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.YES).method(method).build();
|
|
245 |
try (DebugCloseable s = debug.disableIntercept(); DebugContext.Scope ds = debug.scope("CheckingGraph", graph, method)) {
|
|
246 |
graphBuilderSuite.apply(graph, context);
|
|
247 |
// update phi stamps
|
|
248 |
graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp);
|
|
249 |
checkGraph(context, graph);
|
|
250 |
errors.add(String.format("Expected error while checking %s", m));
|
|
251 |
} catch (VerificationError e) {
|
|
252 |
// expected!
|
|
253 |
} catch (Throwable e) {
|
|
254 |
errors.add(String.format("Error while checking %s:%n%s", m, printStackTraceToString(e)));
|
|
255 |
}
|
46344
|
256 |
}
|
|
257 |
}
|
|
258 |
if (errors.isEmpty()) {
|
|
259 |
// Order outer classes before the inner classes
|
|
260 |
classNames.sort((String a, String b) -> a.compareTo(b));
|
|
261 |
// Initialize classes in single thread to avoid deadlocking issues during initialization
|
46393
|
262 |
List<Class<?>> classes = initializeClasses(tool, classNames);
|
46344
|
263 |
for (Class<?> c : classes) {
|
|
264 |
String className = c.getName();
|
|
265 |
executor.execute(() -> {
|
|
266 |
try {
|
|
267 |
checkClass(c, metaAccess);
|
|
268 |
} catch (Throwable e) {
|
|
269 |
errors.add(String.format("Error while checking %s:%n%s", className, printStackTraceToString(e)));
|
|
270 |
}
|
|
271 |
});
|
43972
|
272 |
|
46344
|
273 |
for (Method m : c.getDeclaredMethods()) {
|
|
274 |
if (Modifier.isNative(m.getModifiers()) || Modifier.isAbstract(m.getModifiers())) {
|
|
275 |
// ignore
|
|
276 |
} else {
|
|
277 |
String methodName = className + "." + m.getName();
|
|
278 |
if (matches(filters, methodName)) {
|
|
279 |
executor.execute(() -> {
|
46640
|
280 |
try (DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER)) {
|
|
281 |
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
|
|
282 |
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
|
|
283 |
try (DebugCloseable s = debug.disableIntercept(); DebugContext.Scope ds = debug.scope("CheckingGraph", graph, method)) {
|
|
284 |
checkMethod(method);
|
|
285 |
graphBuilderSuite.apply(graph, context);
|
|
286 |
// update phi stamps
|
|
287 |
graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp);
|
|
288 |
checkGraph(context, graph);
|
|
289 |
} catch (VerificationError e) {
|
|
290 |
errors.add(e.getMessage());
|
|
291 |
} catch (LinkageError e) {
|
|
292 |
// suppress linkages errors resulting from eager resolution
|
|
293 |
} catch (BailoutException e) {
|
|
294 |
// Graal bail outs on certain patterns in Java bytecode
|
|
295 |
// (e.g.,
|
|
296 |
// unbalanced monitors introduced by jacoco).
|
|
297 |
} catch (Throwable e) {
|
|
298 |
try {
|
|
299 |
tool.handleParsingException(e);
|
|
300 |
} catch (Throwable t) {
|
|
301 |
errors.add(String.format("Error while checking %s:%n%s", methodName, printStackTraceToString(e)));
|
|
302 |
}
|
46393
|
303 |
}
|
46344
|
304 |
}
|
|
305 |
});
|
|
306 |
}
|
43972
|
307 |
}
|
|
308 |
}
|
|
309 |
}
|
46344
|
310 |
executor.shutdown();
|
|
311 |
try {
|
|
312 |
executor.awaitTermination(1, TimeUnit.HOURS);
|
|
313 |
} catch (InterruptedException e1) {
|
|
314 |
throw new RuntimeException(e1);
|
|
315 |
}
|
43972
|
316 |
}
|
|
317 |
if (!errors.isEmpty()) {
|
|
318 |
StringBuilder msg = new StringBuilder();
|
|
319 |
String nl = String.format("%n");
|
|
320 |
for (String e : errors) {
|
|
321 |
if (msg.length() != 0) {
|
|
322 |
msg.append(nl);
|
|
323 |
}
|
|
324 |
msg.append(e);
|
|
325 |
}
|
|
326 |
Assert.fail(msg.toString());
|
|
327 |
}
|
|
328 |
}
|
|
329 |
|
46680
|
330 |
private static boolean isInNativeImage(String className) {
|
|
331 |
return className.startsWith("org.graalvm.nativeimage");
|
|
332 |
}
|
|
333 |
|
46393
|
334 |
private static List<Class<?>> initializeClasses(InvariantsTool tool, List<String> classNames) {
|
43972
|
335 |
List<Class<?>> classes = new ArrayList<>(classNames.size());
|
|
336 |
for (String className : classNames) {
|
46393
|
337 |
if (!tool.shouldLoadClass(className)) {
|
43972
|
338 |
continue;
|
|
339 |
}
|
|
340 |
try {
|
|
341 |
Class<?> c = Class.forName(className, true, CheckGraalInvariants.class.getClassLoader());
|
|
342 |
classes.add(c);
|
46393
|
343 |
} catch (Throwable t) {
|
|
344 |
tool.handleClassLoadingException(t);
|
43972
|
345 |
}
|
|
346 |
}
|
|
347 |
return classes;
|
|
348 |
}
|
|
349 |
|
|
350 |
/**
|
|
351 |
* @param metaAccess
|
|
352 |
*/
|
|
353 |
private static void checkClass(Class<?> c, MetaAccessProvider metaAccess) {
|
|
354 |
if (Node.class.isAssignableFrom(c)) {
|
|
355 |
if (c.getAnnotation(NodeInfo.class) == null) {
|
|
356 |
throw new AssertionError(String.format("Node subclass %s requires %s annotation", c.getName(), NodeClass.class.getSimpleName()));
|
|
357 |
}
|
46393
|
358 |
VerifyNodeCosts.verifyNodeClass(c);
|
43972
|
359 |
}
|
|
360 |
}
|
|
361 |
|
46344
|
362 |
private static void checkMethod(ResolvedJavaMethod method) {
|
|
363 |
if (method.getAnnotation(Snippet.class) == null) {
|
|
364 |
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
|
|
365 |
for (int i = 0; i < parameterAnnotations.length; i++) {
|
|
366 |
for (Annotation a : parameterAnnotations[i]) {
|
|
367 |
Class<? extends Annotation> annotationType = a.annotationType();
|
|
368 |
if (annotationType == ConstantParameter.class || annotationType == VarargsParameter.class || annotationType == NonNullParameter.class) {
|
|
369 |
VerificationError verificationError = new VerificationError("Parameter %d of %s is annotated with %s but the method is not annotated with %s", i, method,
|
|
370 |
annotationType.getSimpleName(),
|
|
371 |
Snippet.class.getSimpleName());
|
|
372 |
throw verificationError;
|
|
373 |
}
|
|
374 |
}
|
|
375 |
}
|
43972
|
376 |
}
|
|
377 |
}
|
|
378 |
|
|
379 |
/**
|
|
380 |
* Checks the invariants for a single graph.
|
|
381 |
*/
|
|
382 |
private static void checkGraph(HighTierContext context, StructuredGraph graph) {
|
|
383 |
if (shouldVerifyEquals(graph.method())) {
|
46344
|
384 |
// If you add a new type to test here, be sure to add appropriate
|
|
385 |
// methods to the BadUsageWithEquals class below
|
43972
|
386 |
new VerifyUsageWithEquals(Value.class).apply(graph, context);
|
|
387 |
new VerifyUsageWithEquals(Register.class).apply(graph, context);
|
|
388 |
new VerifyUsageWithEquals(RegisterCategory.class).apply(graph, context);
|
|
389 |
new VerifyUsageWithEquals(JavaType.class).apply(graph, context);
|
|
390 |
new VerifyUsageWithEquals(JavaMethod.class).apply(graph, context);
|
|
391 |
new VerifyUsageWithEquals(JavaField.class).apply(graph, context);
|
|
392 |
new VerifyUsageWithEquals(LocationIdentity.class).apply(graph, context);
|
|
393 |
new VerifyUsageWithEquals(LIRKind.class).apply(graph, context);
|
|
394 |
new VerifyUsageWithEquals(ArithmeticOpTable.class).apply(graph, context);
|
|
395 |
new VerifyUsageWithEquals(ArithmeticOpTable.Op.class).apply(graph, context);
|
|
396 |
}
|
|
397 |
new VerifyDebugUsage().apply(graph, context);
|
|
398 |
new VerifyCallerSensitiveMethods().apply(graph, context);
|
|
399 |
new VerifyVirtualizableUsage().apply(graph, context);
|
|
400 |
new VerifyUpdateUsages().apply(graph, context);
|
|
401 |
new VerifyBailoutUsage().apply(graph, context);
|
46459
|
402 |
new VerifyInstanceOfUsage().apply(graph, context);
|
47798
|
403 |
new VerifyGraphAddUsage().apply(graph, context);
|
|
404 |
new VerifyGetOptionsUsage().apply(graph, context);
|
43972
|
405 |
if (graph.method().isBridge()) {
|
|
406 |
BridgeMethodUtils.getBridgedMethod(graph.method());
|
|
407 |
}
|
|
408 |
}
|
|
409 |
|
|
410 |
private static boolean matches(String[] filters, String s) {
|
|
411 |
if (filters == null || filters.length == 0) {
|
|
412 |
return true;
|
|
413 |
}
|
|
414 |
for (String filter : filters) {
|
|
415 |
if (s.contains(filter)) {
|
|
416 |
return true;
|
|
417 |
}
|
|
418 |
}
|
|
419 |
return false;
|
|
420 |
}
|
|
421 |
|
|
422 |
private static String printStackTraceToString(Throwable t) {
|
|
423 |
StringWriter sw = new StringWriter();
|
|
424 |
t.printStackTrace(new PrintWriter(sw));
|
|
425 |
return sw.toString();
|
|
426 |
}
|
46344
|
427 |
|
|
428 |
static class BadUsageWithEquals {
|
|
429 |
Value aValue;
|
|
430 |
Register aRegister;
|
|
431 |
RegisterCategory aRegisterCategory;
|
|
432 |
JavaType aJavaType;
|
|
433 |
JavaField aJavaField;
|
|
434 |
JavaMethod aJavaMethod;
|
|
435 |
LocationIdentity aLocationIdentity;
|
|
436 |
LIRKind aLIRKind;
|
|
437 |
ArithmeticOpTable anArithmeticOpTable;
|
|
438 |
ArithmeticOpTable.Op anArithmeticOpTableOp;
|
|
439 |
|
|
440 |
static Value aStaticValue;
|
|
441 |
static Register aStaticRegister;
|
|
442 |
static RegisterCategory aStaticRegisterCategory;
|
|
443 |
static JavaType aStaticJavaType;
|
|
444 |
static JavaField aStaticJavaField;
|
|
445 |
static JavaMethod aStaticJavaMethod;
|
|
446 |
static LocationIdentity aStaticLocationIdentity;
|
|
447 |
static LIRKind aStaticLIRKind;
|
|
448 |
static ArithmeticOpTable aStaticArithmeticOpTable;
|
|
449 |
static ArithmeticOpTable.Op aStaticArithmeticOpTableOp;
|
|
450 |
|
|
451 |
boolean test01(Value f) {
|
|
452 |
return aValue == f;
|
|
453 |
}
|
|
454 |
|
|
455 |
boolean test02(Register f) {
|
|
456 |
return aRegister == f;
|
|
457 |
}
|
|
458 |
|
|
459 |
boolean test03(RegisterCategory f) {
|
|
460 |
return aRegisterCategory == f;
|
|
461 |
}
|
|
462 |
|
|
463 |
boolean test04(JavaType f) {
|
|
464 |
return aJavaType == f;
|
|
465 |
}
|
|
466 |
|
|
467 |
boolean test05(JavaField f) {
|
|
468 |
return aJavaField == f;
|
|
469 |
}
|
|
470 |
|
|
471 |
boolean test06(JavaMethod f) {
|
|
472 |
return aJavaMethod == f;
|
|
473 |
}
|
|
474 |
|
|
475 |
boolean test07(LocationIdentity f) {
|
|
476 |
return aLocationIdentity == f;
|
|
477 |
}
|
|
478 |
|
|
479 |
boolean test08(LIRKind f) {
|
|
480 |
return aLIRKind == f;
|
|
481 |
}
|
|
482 |
|
|
483 |
boolean test09(ArithmeticOpTable f) {
|
|
484 |
return anArithmeticOpTable == f;
|
|
485 |
}
|
|
486 |
|
|
487 |
boolean test10(ArithmeticOpTable.Op f) {
|
|
488 |
return anArithmeticOpTableOp == f;
|
|
489 |
}
|
|
490 |
|
|
491 |
boolean test12(Value f) {
|
|
492 |
return aStaticValue == f;
|
|
493 |
}
|
|
494 |
|
|
495 |
boolean test13(Register f) {
|
|
496 |
return aStaticRegister == f;
|
|
497 |
}
|
|
498 |
|
|
499 |
boolean test14(RegisterCategory f) {
|
|
500 |
return aStaticRegisterCategory == f;
|
|
501 |
}
|
|
502 |
|
|
503 |
boolean test15(JavaType f) {
|
|
504 |
return aStaticJavaType == f;
|
|
505 |
}
|
|
506 |
|
|
507 |
boolean test16(JavaField f) {
|
|
508 |
return aStaticJavaField == f;
|
|
509 |
}
|
|
510 |
|
|
511 |
boolean test17(JavaMethod f) {
|
|
512 |
return aStaticJavaMethod == f;
|
|
513 |
}
|
|
514 |
|
|
515 |
boolean test18(LocationIdentity f) {
|
|
516 |
return aStaticLocationIdentity == f;
|
|
517 |
}
|
|
518 |
|
|
519 |
boolean test19(LIRKind f) {
|
|
520 |
return aStaticLIRKind == f;
|
|
521 |
}
|
|
522 |
|
|
523 |
boolean test20(ArithmeticOpTable f) {
|
|
524 |
return aStaticArithmeticOpTable == f;
|
|
525 |
}
|
|
526 |
|
|
527 |
boolean test21(ArithmeticOpTable.Op f) {
|
|
528 |
return aStaticArithmeticOpTableOp == f;
|
|
529 |
}
|
|
530 |
}
|
43972
|
531 |
}
|