CheckGraalInvariants.java revision 13264:48566d838608
1153114Srwatson/*
2153114Srwatson * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3153114Srwatson * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4153114Srwatson *
5153114Srwatson * This code is free software; you can redistribute it and/or modify it
6153114Srwatson * under the terms of the GNU General Public License version 2 only, as
7153114Srwatson * published by the Free Software Foundation.
8153114Srwatson *
9153114Srwatson * This code is distributed in the hope that it will be useful, but WITHOUT
10153114Srwatson * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11153114Srwatson * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12153114Srwatson * version 2 for more details (a copy is included in the LICENSE file that
13153114Srwatson * accompanied this code).
14153114Srwatson *
15153114Srwatson * You should have received a copy of the GNU General Public License version
16153114Srwatson * 2 along with this work; if not, write to the Free Software Foundation,
17153114Srwatson * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18153114Srwatson *
19153114Srwatson * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20153114Srwatson * or visit www.oracle.com if you need additional information or have any
21153114Srwatson * questions.
22153114Srwatson */
23153114Srwatsonpackage org.graalvm.compiler.core.test;
24153114Srwatson
25153114Srwatsonimport java.io.File;
26153114Srwatsonimport java.io.IOException;
27153114Srwatsonimport java.io.PrintWriter;
28153114Srwatsonimport java.io.StringWriter;
29153114Srwatsonimport java.lang.annotation.Annotation;
30153114Srwatsonimport java.lang.reflect.Method;
31153114Srwatsonimport java.lang.reflect.Modifier;
32153114Srwatsonimport java.util.ArrayList;
33153114Srwatsonimport java.util.Collections;
34153114Srwatsonimport java.util.Enumeration;
35153114Srwatsonimport java.util.List;
36153114Srwatsonimport java.util.concurrent.LinkedBlockingQueue;
37153114Srwatsonimport java.util.concurrent.ThreadPoolExecutor;
38153114Srwatsonimport java.util.concurrent.TimeUnit;
39153114Srwatsonimport java.util.zip.ZipEntry;
40212949Savgimport java.util.zip.ZipFile;
41153114Srwatson
42153114Srwatsonimport org.graalvm.compiler.api.replacements.Snippet;
43153114Srwatsonimport org.graalvm.compiler.api.replacements.Snippet.ConstantParameter;
44166539Spjdimport org.graalvm.compiler.api.replacements.Snippet.NonNullParameter;
45153114Srwatsonimport org.graalvm.compiler.api.replacements.Snippet.VarargsParameter;
46153114Srwatsonimport org.graalvm.compiler.api.test.Graal;
47153233Srwatsonimport org.graalvm.compiler.bytecode.BridgeMethodUtils;
48153114Srwatsonimport org.graalvm.compiler.core.CompilerThreadFactory;
49153233Srwatsonimport org.graalvm.compiler.core.common.LIRKind;
50153233Srwatsonimport org.graalvm.compiler.core.common.type.ArithmeticOpTable;
51153233Srwatsonimport org.graalvm.compiler.debug.DebugCloseable;
52153114Srwatsonimport org.graalvm.compiler.debug.DebugHandlersFactory;
53153233Srwatsonimport org.graalvm.compiler.debug.DebugContext;
54153114Srwatsonimport org.graalvm.compiler.debug.GraalError;
55153114Srwatsonimport org.graalvm.compiler.graph.Node;
56153114Srwatsonimport org.graalvm.compiler.graph.NodeClass;
57153114Srwatsonimport org.graalvm.compiler.java.GraphBuilderPhase;
58153114Srwatsonimport org.graalvm.compiler.nodeinfo.NodeInfo;
59153114Srwatsonimport org.graalvm.compiler.nodes.PhiNode;
60153114Srwatsonimport org.graalvm.compiler.nodes.StructuredGraph;
61153114Srwatsonimport org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
62166539Spjdimport org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
63153114Srwatsonimport org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
64153114Srwatsonimport org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
65153114Srwatsonimport org.graalvm.compiler.options.OptionValues;
66153114Srwatsonimport org.graalvm.compiler.phases.OptimisticOptimizations;
67153114Srwatsonimport org.graalvm.compiler.phases.PhaseSuite;
68153114Srwatsonimport org.graalvm.compiler.phases.VerifyPhase;
69153114Srwatsonimport org.graalvm.compiler.phases.VerifyPhase.VerificationError;
70153114Srwatsonimport org.graalvm.compiler.phases.contract.VerifyNodeCosts;
71153114Srwatsonimport org.graalvm.compiler.phases.tiers.HighTierContext;
72153114Srwatsonimport org.graalvm.compiler.phases.util.Providers;
73153114Srwatsonimport org.graalvm.compiler.phases.verify.VerifyBailoutUsage;
74153114Srwatsonimport org.graalvm.compiler.phases.verify.VerifyCallerSensitiveMethods;
75153114Srwatsonimport org.graalvm.compiler.phases.verify.VerifyDebugUsage;
76153114Srwatsonimport org.graalvm.compiler.phases.verify.VerifyInstanceOfUsage;
77153114Srwatsonimport org.graalvm.compiler.phases.verify.VerifyUpdateUsages;
78153114Srwatsonimport org.graalvm.compiler.phases.verify.VerifyUsageWithEquals;
79153114Srwatsonimport org.graalvm.compiler.phases.verify.VerifyVirtualizableUsage;
80153114Srwatsonimport org.graalvm.compiler.runtime.RuntimeProvider;
81153114Srwatsonimport org.graalvm.word.LocationIdentity;
82249430Spluknetimport org.junit.Assert;
83153114Srwatsonimport org.junit.Assume;
84153114Srwatsonimport org.junit.Test;
85153114Srwatson
86153114Srwatsonimport jdk.vm.ci.code.BailoutException;
87153114Srwatsonimport jdk.vm.ci.code.Register;
88153114Srwatsonimport jdk.vm.ci.code.Register.RegisterCategory;
89153114Srwatsonimport jdk.vm.ci.meta.JavaField;
90153114Srwatsonimport jdk.vm.ci.meta.JavaMethod;
91153114Srwatsonimport jdk.vm.ci.meta.JavaType;
92153114Srwatsonimport jdk.vm.ci.meta.MetaAccessProvider;
93153114Srwatsonimport jdk.vm.ci.meta.ResolvedJavaMethod;
94153114Srwatsonimport jdk.vm.ci.meta.ResolvedJavaType;
95153114Srwatsonimport jdk.vm.ci.meta.Value;
96153114Srwatson
97153114Srwatson/**
98153114Srwatson * Checks that all classes in *graal*.jar and *jvmci*.jar entries on the boot class path comply with
99153114Srwatson * global invariants such as using {@link Object#equals(Object)} to compare certain types instead of
100153114Srwatson * identity comparisons.
101153114Srwatson */
102153114Srwatsonpublic class CheckGraalInvariants extends GraalCompilerTest {
103153114Srwatson
104153114Srwatson    private static boolean shouldVerifyEquals(ResolvedJavaMethod m) {
105153114Srwatson        if (m.getName().equals("identityEquals")) {
106153114Srwatson            ResolvedJavaType c = m.getDeclaringClass();
107153114Srwatson            if (c.getName().equals("Ljdk/vm/ci/meta/AbstractValue;") || c.getName().equals("jdk/vm/ci/meta/Value")) {
108153114Srwatson                return false;
109153114Srwatson            }
110153114Srwatson        }
111153114Srwatson
112153114Srwatson        return true;
113153114Srwatson    }
114153114Srwatson
115153114Srwatson    public static String relativeFileName(String absolutePath) {
116153114Srwatson        int lastFileSeparatorIndex = absolutePath.lastIndexOf(File.separator);
117153114Srwatson        return absolutePath.substring(lastFileSeparatorIndex >= 0 ? lastFileSeparatorIndex : 0);
118153114Srwatson    }
119153114Srwatson
120260307Smav    public static class InvariantsTool {
121260307Smav
122260307Smav        protected boolean shouldProcess(String classpathEntry) {
123153114Srwatson            if (classpathEntry.endsWith(".jar")) {
124153114Srwatson                String name = new File(classpathEntry).getName();
125153114Srwatson                return name.contains("jvmci") || name.contains("graal") || name.contains("jdk.internal.vm.compiler");
126153114Srwatson            }
127153114Srwatson            return false;
128153114Srwatson        }
129153114Srwatson
130153114Srwatson        protected String getClassPath() {
131153114Srwatson            String bootclasspath;
132153114Srwatson            if (Java8OrEarlier) {
133153114Srwatson                bootclasspath = System.getProperty("sun.boot.class.path");
134153114Srwatson            } else {
135153114Srwatson                bootclasspath = System.getProperty("jdk.module.path") + File.pathSeparatorChar + System.getProperty("jdk.module.upgrade.path");
136153114Srwatson            }
137153114Srwatson            return bootclasspath;
138260307Smav        }
139260307Smav
140260307Smav        protected boolean shouldLoadClass(String className) {
141260307Smav            return !className.equals("module-info");
142153114Srwatson        }
143153114Srwatson
144153114Srwatson        protected void handleClassLoadingException(Throwable t) {
145153114Srwatson            GraalError.shouldNotReachHere(t);
146153114Srwatson        }
147153114Srwatson
148153114Srwatson        protected void handleParsingException(Throwable t) {
149153114Srwatson            GraalError.shouldNotReachHere(t);
150153114Srwatson        }
151153114Srwatson    }
152153114Srwatson
153153114Srwatson    @Test
154153114Srwatson    @SuppressWarnings("try")
155153114Srwatson    public void test() {
156153114Srwatson        runTest(new InvariantsTool());
157153114Srwatson    }
158153114Srwatson
159153114Srwatson    @SuppressWarnings("try")
160249430Spluknet    public static void runTest(InvariantsTool tool) {
161153114Srwatson        RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
162153114Srwatson        Providers providers = rt.getHostBackend().getProviders();
163153114Srwatson        MetaAccessProvider metaAccess = providers.getMetaAccess();
164153114Srwatson
165153114Srwatson        PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
166153114Srwatson        Plugins plugins = new Plugins(new InvocationPlugins());
167153114Srwatson        GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
168153114Srwatson        graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
169153114Srwatson        HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
170153114Srwatson
171153114Srwatson        Assume.assumeTrue(VerifyPhase.class.desiredAssertionStatus());
172153114Srwatson
173153114Srwatson        String bootclasspath = tool.getClassPath();
174153114Srwatson        Assert.assertNotNull("Cannot find boot class path", bootclasspath);
175153114Srwatson
176153114Srwatson        final List<String> classNames = new ArrayList<>();
177153114Srwatson        for (String path : bootclasspath.split(File.pathSeparator)) {
178153114Srwatson            if (tool.shouldProcess(path)) {
179153114Srwatson                try {
180153114Srwatson                    final ZipFile zipFile = new ZipFile(new File(path));
181153114Srwatson                    for (final Enumeration<? extends ZipEntry> entry = zipFile.entries(); entry.hasMoreElements();) {
182153114Srwatson                        final ZipEntry zipEntry = entry.nextElement();
183153114Srwatson                        String name = zipEntry.getName();
184153114Srwatson                        if (name.endsWith(".class")) {
185153114Srwatson                            String className = name.substring(0, name.length() - ".class".length()).replace('/', '.');
186153114Srwatson                            classNames.add(className);
187153114Srwatson                        }
188153114Srwatson                    }
189153114Srwatson                } catch (IOException ex) {
190153114Srwatson                    Assert.fail(ex.toString());
191153114Srwatson                }
192153114Srwatson            }
193153114Srwatson        }
194153114Srwatson        Assert.assertFalse("Could not find graal jars on boot class path: " + bootclasspath, classNames.isEmpty());
195153114Srwatson
196153114Srwatson        // Allows a subset of methods to be checked through use of a system property
197153114Srwatson        String property = System.getProperty(CheckGraalInvariants.class.getName() + ".filters");
198153114Srwatson        String[] filters = property == null ? null : property.split(",");
199153114Srwatson
200153114Srwatson        OptionValues options = getInitialOptions();
201153114Srwatson        CompilerThreadFactory factory = new CompilerThreadFactory("CheckInvariantsThread");
202153114Srwatson        int availableProcessors = Runtime.getRuntime().availableProcessors();
203153114Srwatson        ThreadPoolExecutor executor = new ThreadPoolExecutor(availableProcessors, availableProcessors, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory);
204153114Srwatson
205153114Srwatson        List<String> errors = Collections.synchronizedList(new ArrayList<>());
206212949Savg
207153114Srwatson        for (Method m : BadUsageWithEquals.class.getDeclaredMethods()) {
208153114Srwatson            ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
209153114Srwatson            try (DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER)) {
210153114Srwatson                StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.YES).method(method).build();
211153114Srwatson                try (DebugCloseable s = debug.disableIntercept(); DebugContext.Scope ds = debug.scope("CheckingGraph", graph, method)) {
212153114Srwatson                    graphBuilderSuite.apply(graph, context);
213153114Srwatson                    // update phi stamps
214153114Srwatson                    graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp);
215153114Srwatson                    checkGraph(context, graph);
216153114Srwatson                    errors.add(String.format("Expected error while checking %s", m));
217153114Srwatson                } catch (VerificationError e) {
218153114Srwatson                    // expected!
219153114Srwatson                } catch (Throwable e) {
220153114Srwatson                    errors.add(String.format("Error while checking %s:%n%s", m, printStackTraceToString(e)));
221153114Srwatson                }
222153114Srwatson            }
223153114Srwatson        }
224153114Srwatson        if (errors.isEmpty()) {
225153114Srwatson            // Order outer classes before the inner classes
226153114Srwatson            classNames.sort((String a, String b) -> a.compareTo(b));
227153114Srwatson            // Initialize classes in single thread to avoid deadlocking issues during initialization
228153114Srwatson            List<Class<?>> classes = initializeClasses(tool, classNames);
229153114Srwatson            for (Class<?> c : classes) {
230153114Srwatson                String className = c.getName();
231153114Srwatson                executor.execute(() -> {
232153114Srwatson                    try {
233153114Srwatson                        checkClass(c, metaAccess);
234153114Srwatson                    } catch (Throwable e) {
235153114Srwatson                        errors.add(String.format("Error while checking %s:%n%s", className, printStackTraceToString(e)));
236153114Srwatson                    }
237153114Srwatson                });
238153114Srwatson
239153114Srwatson                for (Method m : c.getDeclaredMethods()) {
240212932Savg                    if (Modifier.isNative(m.getModifiers()) || Modifier.isAbstract(m.getModifiers())) {
241153114Srwatson                        // ignore
242153114Srwatson                    } else {
243153114Srwatson                        String methodName = className + "." + m.getName();
244153114Srwatson                        if (matches(filters, methodName)) {
245153114Srwatson                            executor.execute(() -> {
246153235Srwatson                                try (DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER)) {
247153114Srwatson                                    ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
248153114Srwatson                                    StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
249153114Srwatson                                    try (DebugCloseable s = debug.disableIntercept(); DebugContext.Scope ds = debug.scope("CheckingGraph", graph, method)) {
250153114Srwatson                                        checkMethod(method);
251153114Srwatson                                        graphBuilderSuite.apply(graph, context);
252212932Savg                                        // update phi stamps
253212932Savg                                        graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp);
254153114Srwatson                                        checkGraph(context, graph);
255153114Srwatson                                    } catch (VerificationError e) {
256153114Srwatson                                        errors.add(e.getMessage());
257153114Srwatson                                    } catch (LinkageError e) {
258153114Srwatson                                        // suppress linkages errors resulting from eager resolution
259153114Srwatson                                    } catch (BailoutException e) {
260153114Srwatson                                        // Graal bail outs on certain patterns in Java bytecode
261153114Srwatson                                        // (e.g.,
262153235Srwatson                                        // unbalanced monitors introduced by jacoco).
263153235Srwatson                                    } catch (Throwable e) {
264153235Srwatson                                        try {
265153235Srwatson                                            tool.handleParsingException(e);
266153114Srwatson                                        } catch (Throwable t) {
267153114Srwatson                                            errors.add(String.format("Error while checking %s:%n%s", methodName, printStackTraceToString(e)));
268153114Srwatson                                        }
269153114Srwatson                                    }
270153114Srwatson                                }
271153114Srwatson                            });
272153114Srwatson                        }
273153114Srwatson                    }
274153114Srwatson                }
275153235Srwatson            }
276153235Srwatson            executor.shutdown();
277153235Srwatson            try {
278153235Srwatson                executor.awaitTermination(1, TimeUnit.HOURS);
279153114Srwatson            } catch (InterruptedException e1) {
280153114Srwatson                throw new RuntimeException(e1);
281153114Srwatson            }
282153114Srwatson        }
283153114Srwatson        if (!errors.isEmpty()) {
284153114Srwatson            StringBuilder msg = new StringBuilder();
285153114Srwatson            String nl = String.format("%n");
286153114Srwatson            for (String e : errors) {
287153114Srwatson                if (msg.length() != 0) {
288153114Srwatson                    msg.append(nl);
289153114Srwatson                }
290153233Srwatson                msg.append(e);
291153114Srwatson            }
292153235Srwatson            Assert.fail(msg.toString());
293153233Srwatson        }
294166539Spjd    }
295166539Spjd
296212949Savg    private static List<Class<?>> initializeClasses(InvariantsTool tool, List<String> classNames) {
297153114Srwatson        List<Class<?>> classes = new ArrayList<>(classNames.size());
298166539Spjd        for (String className : classNames) {
299166539Spjd            if (!tool.shouldLoadClass(className)) {
300166539Spjd                continue;
301166539Spjd            }
302166539Spjd            try {
303166539Spjd                Class<?> c = Class.forName(className, true, CheckGraalInvariants.class.getClassLoader());
304166539Spjd                classes.add(c);
305166539Spjd            } catch (Throwable t) {
306166539Spjd                tool.handleClassLoadingException(t);
307166539Spjd            }
308166539Spjd        }
309166539Spjd        return classes;
310166539Spjd    }
311166539Spjd
312166539Spjd    /**
313166539Spjd     * @param metaAccess
314166539Spjd     */
315153114Srwatson    private static void checkClass(Class<?> c, MetaAccessProvider metaAccess) {
316166539Spjd        if (Node.class.isAssignableFrom(c)) {
317166539Spjd            if (c.getAnnotation(NodeInfo.class) == null) {
318153114Srwatson                throw new AssertionError(String.format("Node subclass %s requires %s annotation", c.getName(), NodeClass.class.getSimpleName()));
319212949Savg            }
320153114Srwatson            VerifyNodeCosts.verifyNodeClass(c);
321212949Savg        }
322153114Srwatson    }
323153114Srwatson
324153114Srwatson    private static void checkMethod(ResolvedJavaMethod method) {
325153114Srwatson        if (method.getAnnotation(Snippet.class) == null) {
326153114Srwatson            Annotation[][] parameterAnnotations = method.getParameterAnnotations();
327153114Srwatson            for (int i = 0; i < parameterAnnotations.length; i++) {
328153114Srwatson                for (Annotation a : parameterAnnotations[i]) {
329153114Srwatson                    Class<? extends Annotation> annotationType = a.annotationType();
330153233Srwatson                    if (annotationType == ConstantParameter.class || annotationType == VarargsParameter.class || annotationType == NonNullParameter.class) {
331153233Srwatson                        VerificationError verificationError = new VerificationError("Parameter %d of %s is annotated with %s but the method is not annotated with %s", i, method,
332153233Srwatson                                        annotationType.getSimpleName(),
333153233Srwatson                                        Snippet.class.getSimpleName());
334153233Srwatson                        throw verificationError;
335153233Srwatson                    }
336153233Srwatson                }
337153114Srwatson            }
338153114Srwatson        }
339153114Srwatson    }
340153114Srwatson
341153114Srwatson    /**
342153114Srwatson     * Checks the invariants for a single graph.
343153114Srwatson     */
344153114Srwatson    private static void checkGraph(HighTierContext context, StructuredGraph graph) {
345153114Srwatson        if (shouldVerifyEquals(graph.method())) {
346153114Srwatson            // If you add a new type to test here, be sure to add appropriate
347153114Srwatson            // methods to the BadUsageWithEquals class below
348153114Srwatson            new VerifyUsageWithEquals(Value.class).apply(graph, context);
349153114Srwatson            new VerifyUsageWithEquals(Register.class).apply(graph, context);
350153114Srwatson            new VerifyUsageWithEquals(RegisterCategory.class).apply(graph, context);
351153114Srwatson            new VerifyUsageWithEquals(JavaType.class).apply(graph, context);
352153114Srwatson            new VerifyUsageWithEquals(JavaMethod.class).apply(graph, context);
353153233Srwatson            new VerifyUsageWithEquals(JavaField.class).apply(graph, context);
354153233Srwatson            new VerifyUsageWithEquals(LocationIdentity.class).apply(graph, context);
355153233Srwatson            new VerifyUsageWithEquals(LIRKind.class).apply(graph, context);
356153233Srwatson            new VerifyUsageWithEquals(ArithmeticOpTable.class).apply(graph, context);
357153233Srwatson            new VerifyUsageWithEquals(ArithmeticOpTable.Op.class).apply(graph, context);
358156365Swkoszek        }
359153233Srwatson        new VerifyDebugUsage().apply(graph, context);
360153233Srwatson        new VerifyCallerSensitiveMethods().apply(graph, context);
361153233Srwatson        new VerifyVirtualizableUsage().apply(graph, context);
362153233Srwatson        new VerifyUpdateUsages().apply(graph, context);
363153233Srwatson        new VerifyBailoutUsage().apply(graph, context);
364153114Srwatson        new VerifyInstanceOfUsage().apply(graph, context);
365153114Srwatson        if (graph.method().isBridge()) {
366153114Srwatson            BridgeMethodUtils.getBridgedMethod(graph.method());
367153233Srwatson        }
368153233Srwatson    }
369153114Srwatson
370153233Srwatson    private static boolean matches(String[] filters, String s) {
371153114Srwatson        if (filters == null || filters.length == 0) {
372153114Srwatson            return true;
373153114Srwatson        }
374153114Srwatson        for (String filter : filters) {
375153114Srwatson            if (s.contains(filter)) {
376260307Smav                return true;
377153114Srwatson            }
378153114Srwatson        }
379153114Srwatson        return false;
380153114Srwatson    }
381260307Smav
382153114Srwatson    private static String printStackTraceToString(Throwable t) {
383153114Srwatson        StringWriter sw = new StringWriter();
384153114Srwatson        t.printStackTrace(new PrintWriter(sw));
385153114Srwatson        return sw.toString();
386153114Srwatson    }
387153114Srwatson
388153114Srwatson    static class BadUsageWithEquals {
389153114Srwatson        Value aValue;
390153114Srwatson        Register aRegister;
391153114Srwatson        RegisterCategory aRegisterCategory;
392153114Srwatson        JavaType aJavaType;
393153233Srwatson        JavaField aJavaField;
394153233Srwatson        JavaMethod aJavaMethod;
395153233Srwatson        LocationIdentity aLocationIdentity;
396153233Srwatson        LIRKind aLIRKind;
397153233Srwatson        ArithmeticOpTable anArithmeticOpTable;
398153233Srwatson        ArithmeticOpTable.Op anArithmeticOpTableOp;
399153233Srwatson
400153233Srwatson        static Value aStaticValue;
401153233Srwatson        static Register aStaticRegister;
402153233Srwatson        static RegisterCategory aStaticRegisterCategory;
403153233Srwatson        static JavaType aStaticJavaType;
404153233Srwatson        static JavaField aStaticJavaField;
405153114Srwatson        static JavaMethod aStaticJavaMethod;
406153233Srwatson        static LocationIdentity aStaticLocationIdentity;
407153233Srwatson        static LIRKind aStaticLIRKind;
408153233Srwatson        static ArithmeticOpTable aStaticArithmeticOpTable;
409153233Srwatson        static ArithmeticOpTable.Op aStaticArithmeticOpTableOp;
410153233Srwatson
411153233Srwatson        boolean test01(Value f) {
412153233Srwatson            return aValue == f;
413153233Srwatson        }
414153233Srwatson
415153233Srwatson        boolean test02(Register f) {
416153233Srwatson            return aRegister == f;
417153114Srwatson        }
418153233Srwatson
419153233Srwatson        boolean test03(RegisterCategory f) {
420153114Srwatson            return aRegisterCategory == f;
421153233Srwatson        }
422153114Srwatson
423153114Srwatson        boolean test04(JavaType f) {
424260307Smav            return aJavaType == f;
425153233Srwatson        }
426260307Smav
427153233Srwatson        boolean test05(JavaField f) {
428260307Smav            return aJavaField == f;
429153233Srwatson        }
430260307Smav
431260307Smav        boolean test06(JavaMethod f) {
432153233Srwatson            return aJavaMethod == f;
433153233Srwatson        }
434212932Savg
435260307Smav        boolean test07(LocationIdentity f) {
436153233Srwatson            return aLocationIdentity == f;
437153114Srwatson        }
438153114Srwatson
439153235Srwatson        boolean test08(LIRKind f) {
440153235Srwatson            return aLIRKind == f;
441153114Srwatson        }
442153114Srwatson
443153114Srwatson        boolean test09(ArithmeticOpTable f) {
444153233Srwatson            return anArithmeticOpTable == f;
445153233Srwatson        }
446153235Srwatson
447153235Srwatson        boolean test10(ArithmeticOpTable.Op f) {
448153114Srwatson            return anArithmeticOpTableOp == f;
449153235Srwatson        }
450153235Srwatson
451153114Srwatson        boolean test12(Value f) {
452153114Srwatson            return aStaticValue == f;
453153114Srwatson        }
454153114Srwatson
455153114Srwatson        boolean test13(Register f) {
456153114Srwatson            return aStaticRegister == f;
457153114Srwatson        }
458153233Srwatson
459153114Srwatson        boolean test14(RegisterCategory f) {
460153114Srwatson            return aStaticRegisterCategory == f;
461        }
462
463        boolean test15(JavaType f) {
464            return aStaticJavaType == f;
465        }
466
467        boolean test16(JavaField f) {
468            return aStaticJavaField == f;
469        }
470
471        boolean test17(JavaMethod f) {
472            return aStaticJavaMethod == f;
473        }
474
475        boolean test18(LocationIdentity f) {
476            return aStaticLocationIdentity == f;
477        }
478
479        boolean test19(LIRKind f) {
480            return aStaticLIRKind == f;
481        }
482
483        boolean test20(ArithmeticOpTable f) {
484            return aStaticArithmeticOpTable == f;
485        }
486
487        boolean test21(ArithmeticOpTable.Op f) {
488            return aStaticArithmeticOpTableOp == f;
489        }
490    }
491}
492