8060724: ant test262parallel in Nashorn spends a significant amount of time after almost all the tests are run
Reviewed-by: lagergren, attila, sundar
This commit is contained in:
parent
7bb8d39499
commit
de498625b3
@ -150,6 +150,13 @@ public final class Context {
|
||||
private final Context context;
|
||||
private final ScriptLoader loader;
|
||||
private final CodeSource codeSource;
|
||||
private int usageCount = 0;
|
||||
private int bytesDefined = 0;
|
||||
|
||||
// We reuse this installer for 10 compilations or 200000 defined bytes. Usually the first condition
|
||||
// will occur much earlier, the second is a safety measure for very large scripts/functions.
|
||||
private final static int MAX_USAGES = 10;
|
||||
private final static int MAX_BYTES_DEFINED = 200_000;
|
||||
|
||||
private ContextCodeInstaller(final Context context, final ScriptLoader loader, final CodeSource codeSource) {
|
||||
this.context = context;
|
||||
@ -168,6 +175,8 @@ public final class Context {
|
||||
|
||||
@Override
|
||||
public Class<?> install(final String className, final byte[] bytecode) {
|
||||
usageCount++;
|
||||
bytesDefined += bytecode.length;
|
||||
final String binaryName = Compiler.binaryName(className);
|
||||
return loader.installClass(binaryName, bytecode, codeSource);
|
||||
}
|
||||
@ -225,6 +234,10 @@ public final class Context {
|
||||
|
||||
@Override
|
||||
public CodeInstaller<ScriptEnvironment> withNewLoader() {
|
||||
// Reuse this installer if we're within our limits.
|
||||
if (usageCount < MAX_USAGES && bytesDefined < MAX_BYTES_DEFINED) {
|
||||
return this;
|
||||
}
|
||||
return new ContextCodeInstaller(context, context.createNewLoader(), codeSource);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,8 @@ public class ParallelTestRunner {
|
||||
// ParallelTestRunner-specific
|
||||
private static final String TEST_JS_THREADS = "test.js.threads";
|
||||
private static final String TEST_JS_REPORT_FILE = "test.js.report.file";
|
||||
private static final int THREADS = Integer.getInteger(TEST_JS_THREADS, Runtime.getRuntime().availableProcessors());
|
||||
// test262 does a lot of eval's and the JVM hates multithreaded class definition, so lower thread count is usually faster.
|
||||
private static final int THREADS = Integer.getInteger(TEST_JS_THREADS, Runtime.getRuntime().availableProcessors() > 4 ? 4 : 2);
|
||||
|
||||
private final List<ScriptRunnable> tests = new ArrayList<>();
|
||||
private final Set<String> orphans = new TreeSet<>();
|
||||
|
Loading…
Reference in New Issue
Block a user