changeset 21710:26774dc3a5e7

removed ExcludeFromIdentityComparisonVerification and replaced it with a white list in CheckGraalInvariants
author Doug Simon <doug.simon@oracle.com>
date Wed, 03 Jun 2015 21:34:21 +0200
parents 3c17c0c41a6b
children 1c41d00e6b2f
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/HexCodeFile.java graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/BitOpsTest.java graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/IncrementDecrementMacroTest.java graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/SimpleAssemblerTest.java graal/com.oracle.jvmci.asm.amd64/src/com/oracle/jvmci/asm/amd64/AMD64Address.java graal/com.oracle.jvmci.asm.amd64/src/com/oracle/jvmci/asm/amd64/AMD64AsmOptions.java graal/com.oracle.jvmci.asm.amd64/src/com/oracle/jvmci/asm/amd64/AMD64Assembler.java graal/com.oracle.jvmci.asm.amd64/src/com/oracle/jvmci/asm/amd64/AMD64MacroAssembler.java graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCAddress.java graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCAssembler.java graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCInstructionCounter.java graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCMacroAssembler.java graal/com.oracle.jvmci.asm.test/src/com/oracle/jvmci/asm/test/AssemblerTest.java graal/com.oracle.jvmci.asm/overview.html graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/AsmOptions.java graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/Assembler.java graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/Buffer.java graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/Label.java graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/NumUtil.java graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/AbstractValue.java graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ExcludeFromIdentityComparisonVerification.java graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Value.java graal/com.oracle.jvmci.test/src/com/oracle/jvmci/test/TestBase.java mx/suite.py
diffstat 5 files changed, 56 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- 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<String> 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<? extends ZipEntry> 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);
--- 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;
     }
--- 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 {
-
-}
--- 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;
     }
--- 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" : {