--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/CheckGraalInvariants.java Sat Dec 08 05:04:19 2018 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/CheckGraalInvariants.java Sat Dec 08 00:56:10 2018 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -72,16 +72,8 @@
import org.graalvm.compiler.phases.VerifyPhase.VerificationError;
import org.graalvm.compiler.phases.contract.VerifyNodeCosts;
import org.graalvm.compiler.phases.tiers.HighTierContext;
+import org.graalvm.compiler.phases.tiers.PhaseContext;
import org.graalvm.compiler.phases.util.Providers;
-import org.graalvm.compiler.phases.verify.VerifyBailoutUsage;
-import org.graalvm.compiler.phases.verify.VerifyCallerSensitiveMethods;
-import org.graalvm.compiler.phases.verify.VerifyDebugUsage;
-import org.graalvm.compiler.phases.verify.VerifyGetOptionsUsage;
-import org.graalvm.compiler.phases.verify.VerifyGraphAddUsage;
-import org.graalvm.compiler.phases.verify.VerifyInstanceOfUsage;
-import org.graalvm.compiler.phases.verify.VerifyUpdateUsages;
-import org.graalvm.compiler.phases.verify.VerifyUsageWithEquals;
-import org.graalvm.compiler.phases.verify.VerifyVirtualizableUsage;
import org.graalvm.compiler.runtime.RuntimeProvider;
import jdk.internal.vm.compiler.word.LocationIdentity;
import org.junit.Assert;
@@ -176,6 +168,10 @@
protected void handleParsingException(Throwable t) {
GraalError.shouldNotReachHere(t);
}
+
+ public boolean shouldVerifyFoldableMethods() {
+ return true;
+ }
}
@Test
@@ -219,6 +215,12 @@
*/
continue;
}
+ if (isGSON(className)) {
+ /*
+ * GSON classes are compiled with old JDK
+ */
+ continue;
+ }
classNames.add(className);
}
}
@@ -240,6 +242,35 @@
List<String> errors = Collections.synchronizedList(new ArrayList<>());
+ List<VerifyPhase<PhaseContext>> verifiers = new ArrayList<>();
+
+ // If you add a new type to test here, be sure to add appropriate
+ // methods to the BadUsageWithEquals class below
+ verifiers.add(new VerifyUsageWithEquals(Value.class));
+ verifiers.add(new VerifyUsageWithEquals(Register.class));
+ verifiers.add(new VerifyUsageWithEquals(RegisterCategory.class));
+ verifiers.add(new VerifyUsageWithEquals(JavaType.class));
+ verifiers.add(new VerifyUsageWithEquals(JavaMethod.class));
+ verifiers.add(new VerifyUsageWithEquals(JavaField.class));
+ verifiers.add(new VerifyUsageWithEquals(LocationIdentity.class));
+ verifiers.add(new VerifyUsageWithEquals(LIRKind.class));
+ verifiers.add(new VerifyUsageWithEquals(ArithmeticOpTable.class));
+ verifiers.add(new VerifyUsageWithEquals(ArithmeticOpTable.Op.class));
+
+ verifiers.add(new VerifyDebugUsage());
+ verifiers.add(new VerifyCallerSensitiveMethods());
+ verifiers.add(new VerifyVirtualizableUsage());
+ verifiers.add(new VerifyUpdateUsages());
+ verifiers.add(new VerifyBailoutUsage());
+ verifiers.add(new VerifyInstanceOfUsage());
+ verifiers.add(new VerifyGraphAddUsage());
+ verifiers.add(new VerifyGetOptionsUsage());
+
+ VerifyFoldableMethods foldableMethodsVerifier = new VerifyFoldableMethods();
+ if (tool.shouldVerifyFoldableMethods()) {
+ verifiers.add(foldableMethodsVerifier);
+ }
+
for (Method m : BadUsageWithEquals.class.getDeclaredMethods()) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
try (DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER)) {
@@ -248,7 +279,7 @@
graphBuilderSuite.apply(graph, context);
// update phi stamps
graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp);
- checkGraph(context, graph);
+ checkGraph(verifiers, context, graph);
errors.add(String.format("Expected error while checking %s", m));
} catch (VerificationError e) {
// expected!
@@ -288,7 +319,7 @@
graphBuilderSuite.apply(graph, context);
// update phi stamps
graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp);
- checkGraph(context, graph);
+ checkGraph(verifiers, context, graph);
} catch (VerificationError e) {
errors.add(e.getMessage());
} catch (LinkageError e) {
@@ -310,12 +341,21 @@
}
}
}
+
executor.shutdown();
try {
executor.awaitTermination(1, TimeUnit.HOURS);
} catch (InterruptedException e1) {
throw new RuntimeException(e1);
}
+
+ if (tool.shouldVerifyFoldableMethods()) {
+ try {
+ foldableMethodsVerifier.finish();
+ } catch (Throwable e) {
+ errors.add(e.getMessage());
+ }
+ }
}
if (!errors.isEmpty()) {
StringBuilder msg = new StringBuilder();
@@ -334,6 +374,10 @@
return className.startsWith("org.graalvm.nativeimage");
}
+ private static boolean isGSON(String className) {
+ return className.contains("com.google.gson");
+ }
+
private static List<Class<?>> initializeClasses(InvariantsTool tool, List<String> classNames) {
List<Class<?>> classes = new ArrayList<>(classNames.size());
for (String className : classNames) {
@@ -382,29 +426,14 @@
/**
* Checks the invariants for a single graph.
*/
- private static void checkGraph(HighTierContext context, StructuredGraph graph) {
- if (shouldVerifyEquals(graph.method())) {
- // If you add a new type to test here, be sure to add appropriate
- // methods to the BadUsageWithEquals class below
- new VerifyUsageWithEquals(Value.class).apply(graph, context);
- new VerifyUsageWithEquals(Register.class).apply(graph, context);
- new VerifyUsageWithEquals(RegisterCategory.class).apply(graph, context);
- new VerifyUsageWithEquals(JavaType.class).apply(graph, context);
- new VerifyUsageWithEquals(JavaMethod.class).apply(graph, context);
- new VerifyUsageWithEquals(JavaField.class).apply(graph, context);
- new VerifyUsageWithEquals(LocationIdentity.class).apply(graph, context);
- new VerifyUsageWithEquals(LIRKind.class).apply(graph, context);
- new VerifyUsageWithEquals(ArithmeticOpTable.class).apply(graph, context);
- new VerifyUsageWithEquals(ArithmeticOpTable.Op.class).apply(graph, context);
+ private static void checkGraph(List<VerifyPhase<PhaseContext>> verifiers, HighTierContext context, StructuredGraph graph) {
+ for (VerifyPhase<PhaseContext> verifier : verifiers) {
+ if (!(verifier instanceof VerifyUsageWithEquals) || shouldVerifyEquals(graph.method())) {
+ verifier.apply(graph, context);
+ } else {
+ verifier.apply(graph, context);
+ }
}
- new VerifyDebugUsage().apply(graph, context);
- new VerifyCallerSensitiveMethods().apply(graph, context);
- new VerifyVirtualizableUsage().apply(graph, context);
- new VerifyUpdateUsages().apply(graph, context);
- new VerifyBailoutUsage().apply(graph, context);
- new VerifyInstanceOfUsage().apply(graph, context);
- new VerifyGraphAddUsage().apply(graph, context);
- new VerifyGetOptionsUsage().apply(graph, context);
if (graph.method().isBridge()) {
BridgeMethodUtils.getBridgedMethod(graph.method());
}