# HG changeset patch # User Doug Simon # Date 1433360061 -7200 # Node ID 26774dc3a5e77c0ec8e24404ee1bae3d5e426d68 # Parent 3c17c0c41a6bcb60b025a836dc4e11086baa5866 removed ExcludeFromIdentityComparisonVerification and replaced it with a white list in CheckGraalInvariants diff -r 3c17c0c41a6b -r 26774dc3a5e7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Wed Jun 03 18:33:23 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Wed Jun 03 21:34:21 2015 +0200 @@ -22,19 +22,6 @@ */ package com.oracle.graal.compiler.test; -import com.oracle.jvmci.code.BailoutException; -import com.oracle.jvmci.code.Register; -import com.oracle.jvmci.meta.ResolvedJavaMethod; -import com.oracle.jvmci.meta.JavaType; -import com.oracle.jvmci.meta.Value; -import com.oracle.jvmci.meta.JavaMethod; -import com.oracle.jvmci.meta.LocationIdentity; -import com.oracle.jvmci.meta.LIRKind; -import com.oracle.jvmci.meta.ExcludeFromIdentityComparisonVerification; -import com.oracle.jvmci.meta.MetaAccessProvider; -import com.oracle.jvmci.meta.JavaField; -import com.oracle.jvmci.test.*; - import static com.oracle.jvmci.debug.DelegatingDebugConfig.Feature.*; import java.io.*; @@ -45,7 +32,6 @@ import org.junit.*; -import com.oracle.jvmci.code.Register.RegisterCategory; import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.CompilerThreadFactory.DebugConfigAccess; @@ -64,14 +50,38 @@ import com.oracle.graal.phases.verify.*; import com.oracle.graal.printer.*; import com.oracle.graal.runtime.*; +import com.oracle.jvmci.code.*; +import com.oracle.jvmci.code.Register.RegisterCategory; import com.oracle.jvmci.debug.*; +import com.oracle.jvmci.meta.*; +import com.oracle.jvmci.test.*; /** - * Checks that all classes in graal*.jar from the boot classpath comply with global invariants such - * as using {@link Object#equals(Object)} to compare certain types instead of identity comparisons. + * Checks that all classes in *graal*.jar and *jvmci*.jar entries on the boot class path comply with + * global invariants such as using {@link Object#equals(Object)} to compare certain types instead of + * identity comparisons. */ public class CheckGraalInvariants extends TestBase { + private static boolean shouldVerifyEquals(ResolvedJavaMethod m) { + if (m.getName().equals("identityEquals")) { + ResolvedJavaType c = m.getDeclaringClass(); + if (c.getName().equals("Lcom/oracle/jvmci/meta/AbstractValue;") || c.getName().equals("com/oracle/jvmci/meta/Value")) { + return false; + } + } + + return true; + } + + private static boolean shouldProcess(String classpathEntry) { + if (classpathEntry.endsWith(".jar")) { + String name = new File(classpathEntry).getName(); + return name.contains("jvmci") || name.contains("graal"); + } + return false; + } + @Test public void test() { RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class); @@ -92,11 +102,9 @@ final List classNames = new ArrayList<>(); for (String path : bootclasspath.split(File.pathSeparator)) { - File file = new File(path); - String fileName = file.getName(); - if (fileName.startsWith("graal") && fileName.endsWith(".jar")) { + if (shouldProcess(path)) { try { - final ZipFile zipFile = new ZipFile(file); + final ZipFile zipFile = new ZipFile(new File(path)); for (final Enumeration entry = zipFile.entries(); entry.hasMoreElements();) { final ZipEntry zipEntry = entry.nextElement(); String name = zipEntry.getName(); @@ -141,7 +149,6 @@ // ignore } else { String methodName = className + "." + m.getName(); - boolean verifyEquals = !m.isAnnotationPresent(ExcludeFromIdentityComparisonVerification.class); if (matches(filters, methodName)) { executor.execute(() -> { ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m); @@ -150,7 +157,7 @@ graphBuilderSuite.apply(graph, context); // update phi stamps graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp); - checkGraph(context, graph, verifyEquals); + checkGraph(context, graph); } catch (VerificationError e) { errors.add(e.getMessage()); } catch (LinkageError e) { @@ -204,8 +211,8 @@ /** * Checks the invariants for a single graph. */ - private static void checkGraph(HighTierContext context, StructuredGraph graph, boolean verifyEquals) { - if (verifyEquals) { + private static void checkGraph(HighTierContext context, StructuredGraph graph) { + if (shouldVerifyEquals(graph.method())) { new VerifyUsageWithEquals(Value.class).apply(graph, context); new VerifyUsageWithEquals(Register.class).apply(graph, context); new VerifyUsageWithEquals(RegisterCategory.class).apply(graph, context); diff -r 3c17c0c41a6b -r 26774dc3a5e7 graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/AbstractValue.java --- a/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/AbstractValue.java Wed Jun 03 18:33:23 2015 +0200 +++ b/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/AbstractValue.java Wed Jun 03 21:34:21 2015 +0200 @@ -92,7 +92,6 @@ * Warning: Use with caution! Usually equivalence {@link #equals(Object)} is sufficient and * should be used. */ - @ExcludeFromIdentityComparisonVerification public final boolean identityEquals(AbstractValue other) { return this == other; } diff -r 3c17c0c41a6b -r 26774dc3a5e7 graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ExcludeFromIdentityComparisonVerification.java --- a/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ExcludeFromIdentityComparisonVerification.java Wed Jun 03 18:33:23 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.jvmci.meta; - -import java.lang.annotation.*; - -/** - * This annotation denotes methods which are allowed to use identity checks (==/!=) on restricted - * types. - * - * @see CheckGraalInvariants - */ -@SuppressWarnings("javadoc") -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ExcludeFromIdentityComparisonVerification { - -} diff -r 3c17c0c41a6b -r 26774dc3a5e7 graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Value.java --- a/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Value.java Wed Jun 03 18:33:23 2015 +0200 +++ b/graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Value.java Wed Jun 03 21:34:21 2015 +0200 @@ -56,7 +56,6 @@ * Warning: Use with caution! Usually equivalence {@link #equals(Object)} is sufficient and * should be used. */ - @ExcludeFromIdentityComparisonVerification default boolean identityEquals(Value other) { return this == other; } diff -r 3c17c0c41a6b -r 26774dc3a5e7 mx/suite.py --- a/mx/suite.py Wed Jun 03 18:33:23 2015 +0200 +++ b/mx/suite.py Wed Jun 03 21:34:21 2015 +0200 @@ -429,6 +429,31 @@ "workingSets" : "JVMCI,HotSpot", }, + "com.oracle.jvmci.asm.test" : { + "subDir" : "graal", + "sourceDirs" : ["src"], + "dependencies" : [ + "com.oracle.jvmci.test", + "com.oracle.jvmci.common", + "com.oracle.jvmci.runtime", + ], + "checkstyle" : "com.oracle.graal.graph", + "javaCompliance" : "1.8", + "workingSets" : "JVMCI,Assembler,Test", + }, + + "com.oracle.jvmci.asm.amd64.test" : { + "subDir" : "graal", + "sourceDirs" : ["src"], + "dependencies" : [ + "com.oracle.jvmci.asm.test", + "com.oracle.jvmci.asm.amd64", + ], + "checkstyle" : "com.oracle.graal.graph", + "javaCompliance" : "1.8", + "workingSets" : "JVMCI,Assembler,AMD64,Test", + }, + # ------------- NFI ------------- "com.oracle.nfi" : { @@ -1037,31 +1062,6 @@ "jacoco" : "exclude", }, - "com.oracle.jvmci.asm.test" : { - "subDir" : "graal", - "sourceDirs" : ["src"], - "dependencies" : [ - "com.oracle.jvmci.test", - "com.oracle.jvmci.common", - "com.oracle.jvmci.runtime", - ], - "checkstyle" : "com.oracle.graal.graph", - "javaCompliance" : "1.8", - "workingSets" : "Graal,Assembler,Test", - }, - - "com.oracle.jvmci.asm.amd64.test" : { - "subDir" : "graal", - "sourceDirs" : ["src"], - "dependencies" : [ - "com.oracle.jvmci.asm.test", - "com.oracle.jvmci.asm.amd64", - ], - "checkstyle" : "com.oracle.graal.graph", - "javaCompliance" : "1.8", - "workingSets" : "Graal,Assembler,AMD64,Test", - }, - # ------------- Truffle ------------- "com.oracle.truffle.api" : {