--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/ExplicitExceptionTest.java 2017-11-03 23:56:32.513823637 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/ExplicitExceptionTest.java 2017-11-03 23:56:32.187809048 -0700 @@ -22,23 +22,44 @@ */ package org.graalvm.compiler.hotspot.test; -import org.junit.Test; - import org.graalvm.compiler.core.test.GraalCompilerTest; import org.graalvm.compiler.nodes.StructuredGraph; import org.graalvm.compiler.nodes.extended.ForeignCallNode; import org.graalvm.compiler.options.OptionValues; +import org.junit.Assume; +import org.junit.Test; import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.meta.ProfilingInfo; import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.TriState; public class ExplicitExceptionTest extends GraalCompilerTest { private int expectedForeignCallCount; + /** + * Determines if profiling info for {@code method} indicates an exception was thrown somewhere + * in the method. In the case of the {@code -Xcomp} VM option, interpreter execution can be + * skipped altogether and other execution engines (e.g., C1) may not record seen exceptions in a + * method profile. + */ + private static boolean exceptionWasSeen(ResolvedJavaMethod method) { + ProfilingInfo profilingInfo = method.getProfilingInfo(); + if (profilingInfo != null) { + for (int i = 0; i < profilingInfo.getCodeSize(); i++) { + if (profilingInfo.getExceptionSeen(i) == TriState.TRUE) { + return true; + } + } + } + return false; + } + @Override protected InstalledCode getCode(ResolvedJavaMethod method, StructuredGraph graph, boolean forceCompile, boolean installAsDefault, OptionValues options) { InstalledCode installedCode = super.getCode(method, graph, forceCompile, installAsDefault, options); + Assume.assumeTrue(exceptionWasSeen(method)); assertDeepEquals(expectedForeignCallCount, lastCompiledGraph.getNodes().filter(ForeignCallNode.class).count()); return installedCode; }