mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 03:24:38 +02:00
8062904: TEST_BUG: Tests java/lang/invoke/LFCaching fail when run with -Xcomp option
Reviewed-by: vlivanov
This commit is contained in:
parent
b07bdeb8bd
commit
2f5dc153c2
5 changed files with 68 additions and 45 deletions
|
@ -77,7 +77,7 @@ public abstract class LFCachingTestCase extends LambdaFormTestCase {
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException | IllegalArgumentException |
|
} catch (IllegalAccessException | IllegalArgumentException |
|
||||||
SecurityException | InvocationTargetException ex) {
|
SecurityException | InvocationTargetException ex) {
|
||||||
throw new Error("Unexpected exception: ", ex);
|
throw new Error("Unexpected exception", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
/*
|
/*
|
||||||
* @test LFGarbageCollectedTest
|
* @test LFGarbageCollectedTest
|
||||||
* @bug 8046703
|
* @bug 8046703
|
||||||
|
* @key randomness
|
||||||
* @ignore 8078602
|
* @ignore 8078602
|
||||||
* @summary Test verifies that lambda forms are garbage collected
|
* @summary Test verifies that lambda forms are garbage collected
|
||||||
* @author kshefov
|
* @author kshefov
|
||||||
|
@ -73,7 +74,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase {
|
||||||
try {
|
try {
|
||||||
adapter = testCase.getTestCaseMH(data, TestMethods.Kind.ONE);
|
adapter = testCase.getTestCaseMH(data, TestMethods.Kind.ONE);
|
||||||
} catch (NoSuchMethodException ex) {
|
} catch (NoSuchMethodException ex) {
|
||||||
throw new Error("Unexpected exception: ", ex);
|
throw new Error("Unexpected exception", ex);
|
||||||
}
|
}
|
||||||
mtype = adapter.type();
|
mtype = adapter.type();
|
||||||
Object lambdaForm = INTERNAL_FORM.invoke(adapter);
|
Object lambdaForm = INTERNAL_FORM.invoke(adapter);
|
||||||
|
@ -94,7 +95,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase {
|
||||||
collectLambdaForm();
|
collectLambdaForm();
|
||||||
} catch (IllegalAccessException | IllegalArgumentException |
|
} catch (IllegalAccessException | IllegalArgumentException |
|
||||||
InvocationTargetException ex) {
|
InvocationTargetException ex) {
|
||||||
throw new Error("Unexpected exception: ", ex);
|
throw new Error("Unexpected exception", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
/*
|
/*
|
||||||
* @test LFMultiThreadCachingTest
|
* @test LFMultiThreadCachingTest
|
||||||
* @bug 8046703
|
* @bug 8046703
|
||||||
|
* @key randomness
|
||||||
* @summary Test verifies that lambda forms are cached when run with multiple threads
|
* @summary Test verifies that lambda forms are cached when run with multiple threads
|
||||||
* @author kshefov
|
* @author kshefov
|
||||||
* @library /lib/testlibrary/jsr292 /lib/testlibrary
|
* @library /lib/testlibrary/jsr292 /lib/testlibrary
|
||||||
|
@ -35,18 +36,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.BrokenBarrierException;
|
import java.util.concurrent.BrokenBarrierException;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.CyclicBarrier;
|
import java.util.concurrent.CyclicBarrier;
|
||||||
|
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiple threaded lambda forms caching test class.
|
* Multiple threaded lambda forms caching test class.
|
||||||
*/
|
*/
|
||||||
public final class LFMultiThreadCachingTest extends LFCachingTestCase {
|
public final class LFMultiThreadCachingTest extends LFCachingTestCase {
|
||||||
|
|
||||||
private static final TestMethods.Kind[] KINDS;
|
private static final TestMethods.Kind[] KINDS;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
|
EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
|
||||||
KINDS = set.toArray(new TestMethods.Kind[set.size()]);
|
KINDS = set.toArray(new TestMethods.Kind[set.size()]);
|
||||||
|
@ -72,21 +78,55 @@ public final class LFMultiThreadCachingTest extends LFCachingTestCase {
|
||||||
ConcurrentLinkedQueue<MethodHandle> adapters = new ConcurrentLinkedQueue<>();
|
ConcurrentLinkedQueue<MethodHandle> adapters = new ConcurrentLinkedQueue<>();
|
||||||
CyclicBarrier begin = new CyclicBarrier(CORES);
|
CyclicBarrier begin = new CyclicBarrier(CORES);
|
||||||
CountDownLatch end = new CountDownLatch(CORES);
|
CountDownLatch end = new CountDownLatch(CORES);
|
||||||
|
final Map<Thread, Throwable> threadUncaughtExceptions
|
||||||
|
= Collections.synchronizedMap(new HashMap<Thread, Throwable>(CORES));
|
||||||
|
Thread.UncaughtExceptionHandler exHandler = (t, e) -> {
|
||||||
|
threadUncaughtExceptions.put(t, e);
|
||||||
|
};
|
||||||
for (int i = 0; i < CORES; ++i) {
|
for (int i = 0; i < CORES; ++i) {
|
||||||
TestMethods.Kind kind = KINDS[i % KINDS.length];
|
TestMethods.Kind kind = KINDS[i % KINDS.length];
|
||||||
new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
begin.await();
|
begin.await();
|
||||||
adapters.add(getTestMethod().getTestCaseMH(data, kind));
|
adapters.add(getTestMethod().getTestCaseMH(data, kind));
|
||||||
} catch (InterruptedException | BrokenBarrierException | IllegalAccessException | NoSuchMethodException ex) {
|
} catch (InterruptedException | BrokenBarrierException
|
||||||
throw new Error("Unexpected exception: ", ex);
|
| IllegalAccessException | NoSuchMethodException ex) {
|
||||||
|
throw new Error("Unexpected exception", ex);
|
||||||
} finally {
|
} finally {
|
||||||
end.countDown();
|
end.countDown();
|
||||||
}
|
}
|
||||||
}).start();
|
});
|
||||||
|
t.setUncaughtExceptionHandler(exHandler);
|
||||||
|
t.start();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
end.await();
|
end.await();
|
||||||
|
boolean vmeThrown = false;
|
||||||
|
boolean nonVmeThrown = false;
|
||||||
|
Throwable vme = null;
|
||||||
|
for (Map.Entry<Thread,
|
||||||
|
Throwable> entry : threadUncaughtExceptions.entrySet()) {
|
||||||
|
Thread t = entry.getKey();
|
||||||
|
Throwable e = entry.getValue();
|
||||||
|
System.err.printf("%nA thread with name \"%s\" of %d threads"
|
||||||
|
+ " has thrown exception:%n", t.getName(), CORES);
|
||||||
|
e.printStackTrace();
|
||||||
|
if (CodeCacheOverflowProcessor.isThrowableCausedByVME(e)) {
|
||||||
|
vmeThrown = true;
|
||||||
|
vme = e;
|
||||||
|
} else {
|
||||||
|
nonVmeThrown = true;
|
||||||
|
}
|
||||||
|
if (nonVmeThrown) {
|
||||||
|
throw new Error("One ore more threads have"
|
||||||
|
+ " thrown unexpected exceptions. See log.");
|
||||||
|
}
|
||||||
|
if (vmeThrown) {
|
||||||
|
throw new Error("One ore more threads have"
|
||||||
|
+ " thrown VirtualMachineError caused by"
|
||||||
|
+ " code cache overflow. See log.", vme);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
throw new Error("Unexpected exception: ", ex);
|
throw new Error("Unexpected exception: ", ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
/*
|
/*
|
||||||
* @test LFSingleThreadCachingTest
|
* @test LFSingleThreadCachingTest
|
||||||
* @bug 8046703
|
* @bug 8046703
|
||||||
|
* @key randomness
|
||||||
* @summary Test verifies that lambda forms are cached when run with single thread
|
* @summary Test verifies that lambda forms are cached when run with single thread
|
||||||
* @author kshefov
|
* @author kshefov
|
||||||
* @library /lib/testlibrary/jsr292 /lib/testlibrary
|
* @library /lib/testlibrary/jsr292 /lib/testlibrary
|
||||||
|
@ -62,7 +63,7 @@ public final class LFSingleThreadCachingTest extends LFCachingTestCase {
|
||||||
adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE);
|
adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE);
|
||||||
adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO);
|
adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO);
|
||||||
} catch (NoSuchMethodException | IllegalAccessException ex) {
|
} catch (NoSuchMethodException | IllegalAccessException ex) {
|
||||||
throw new Error("Unexpected exception: ", ex);
|
throw new Error("Unexpected exception", ex);
|
||||||
}
|
}
|
||||||
checkLFCaching(adapter1, adapter2);
|
checkLFCaching(adapter1, adapter2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.oracle.testlibrary.jsr292.Helper;
|
import com.oracle.testlibrary.jsr292.Helper;
|
||||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.management.GarbageCollectorMXBean;
|
import java.lang.management.GarbageCollectorMXBean;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
@ -44,8 +44,6 @@ import jdk.testlibrary.TimeLimitedRunner;
|
||||||
*/
|
*/
|
||||||
public abstract class LambdaFormTestCase {
|
public abstract class LambdaFormTestCase {
|
||||||
|
|
||||||
private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO
|
|
||||||
= 45 / (128.0 * 1024 * 1024);
|
|
||||||
private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
|
private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,7 +70,7 @@ public abstract class LambdaFormTestCase {
|
||||||
REF_FIELD = Reference.class.getDeclaredField("referent");
|
REF_FIELD = Reference.class.getDeclaredField("referent");
|
||||||
REF_FIELD.setAccessible(true);
|
REF_FIELD.setAccessible(true);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new Error("Unexpected exception: ", ex);
|
throw new Error("Unexpected exception", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
gcInfo = ManagementFactory.getGarbageCollectorMXBeans();
|
gcInfo = ManagementFactory.getGarbageCollectorMXBeans();
|
||||||
|
@ -101,28 +99,6 @@ public abstract class LambdaFormTestCase {
|
||||||
long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
|
long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
|
||||||
System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
|
System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
|
||||||
iterations, iterations * testCaseNum);
|
iterations, iterations * testCaseNum);
|
||||||
HotSpotDiagnosticMXBean hsDiagBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
|
|
||||||
long codeCacheSize = Long.parseLong(
|
|
||||||
hsDiagBean.getVMOption("ReservedCodeCacheSize").getValue());
|
|
||||||
System.out.printf("Code cache size is %d bytes%n", codeCacheSize);
|
|
||||||
long iterationsByCodeCacheSize = (long) (codeCacheSize
|
|
||||||
* ITERATIONS_TO_CODE_CACHE_SIZE_RATIO);
|
|
||||||
long nonProfiledCodeCacheSize = Long.parseLong(
|
|
||||||
hsDiagBean.getVMOption("NonProfiledCodeHeapSize").getValue());
|
|
||||||
System.out.printf("Non-profiled code cache size is %d bytes%n", nonProfiledCodeCacheSize);
|
|
||||||
long iterationsByNonProfiledCodeCacheSize = (long) (nonProfiledCodeCacheSize
|
|
||||||
* ITERATIONS_TO_CODE_CACHE_SIZE_RATIO);
|
|
||||||
System.out.printf("Number of iterations limited by code cache size is %d (%d cases)%n",
|
|
||||||
iterationsByCodeCacheSize, iterationsByCodeCacheSize * testCaseNum);
|
|
||||||
System.out.printf("Number of iterations limited by non-profiled code cache size is %d (%d cases)%n",
|
|
||||||
iterationsByNonProfiledCodeCacheSize, iterationsByNonProfiledCodeCacheSize * testCaseNum);
|
|
||||||
iterations = Math.min(iterationsByCodeCacheSize,
|
|
||||||
Math.min(iterations, iterationsByNonProfiledCodeCacheSize));
|
|
||||||
if (iterations == 0) {
|
|
||||||
System.out.println("Warning: code cache size is too small to provide at"
|
|
||||||
+ " least one iteration! Test will try to do one iteration.");
|
|
||||||
iterations = 1;
|
|
||||||
}
|
|
||||||
System.out.printf("Number of iterations is set to %d (%d cases)%n",
|
System.out.printf("Number of iterations is set to %d (%d cases)%n",
|
||||||
iterations, iterations * testCaseNum);
|
iterations, iterations * testCaseNum);
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
@ -141,14 +117,19 @@ public abstract class LambdaFormTestCase {
|
||||||
for (TestMethods testMethod : testMethods) {
|
for (TestMethods testMethod : testMethods) {
|
||||||
LambdaFormTestCase testCase = ctor.apply(testMethod);
|
LambdaFormTestCase testCase = ctor.apply(testMethod);
|
||||||
try {
|
try {
|
||||||
System.err.printf("Tested LF caching feature with MethodHandles.%s method.%n",
|
System.err.printf("Tested LF caching feature"
|
||||||
|
+ " with MethodHandles.%s method.%n",
|
||||||
testCase.getTestMethod().name);
|
testCase.getTestMethod().name);
|
||||||
testCase.doTest();
|
Throwable t = CodeCacheOverflowProcessor
|
||||||
|
.runMHTest(testCase::doTest);
|
||||||
|
if (t != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
System.err.println("PASSED");
|
System.err.println("PASSED");
|
||||||
} catch (OutOfMemoryError e) {
|
} catch (OutOfMemoryError oome) {
|
||||||
// Don't swallow OOME so a heap dump can be created.
|
// Don't swallow OOME so a heap dump can be created.
|
||||||
System.err.println("FAILED");
|
System.err.println("FAILED");
|
||||||
throw e;
|
throw oome;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
System.err.printf("FAILED. Caused by %s%n", t.getMessage());
|
System.err.printf("FAILED. Caused by %s%n", t.getMessage());
|
||||||
|
@ -205,8 +186,8 @@ public abstract class LambdaFormTestCase {
|
||||||
* @param testMethods list of test methods
|
* @param testMethods list of test methods
|
||||||
*/
|
*/
|
||||||
public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
|
public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
|
||||||
LambdaFormTestCase.TestRun run =
|
LambdaFormTestCase.TestRun run
|
||||||
new LambdaFormTestCase.TestRun(ctor, testMethods);
|
= new LambdaFormTestCase.TestRun(ctor, testMethods);
|
||||||
TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
|
TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
|
||||||
try {
|
try {
|
||||||
runner.call();
|
runner.call();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue