Path: blob/master/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java
41153 views
/*1* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test TestOverloadCompileQueues25* @bug 8163511 823040226* @summary Test overloading the C1 and C2 compile queues with tasks.27* @requires !vm.graal.enabled28* @run main/othervm/timeout=300 -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=129* compiler.classUnloading.methodUnloading.TestOverloadCompileQueues30* @run main/othervm/timeout=300 -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=231* compiler.classUnloading.methodUnloading.TestOverloadCompileQueues32*/3334package compiler.classUnloading.methodUnloading;3536import java.lang.reflect.Method;37import java.net.URL;38import java.net.URLClassLoader;39import java.util.Arrays;4041public class TestOverloadCompileQueues {42public static final int ITERS = 500; // Increase for longer stress testing43public static final int ITERS_A = 1000; // Increase for longer stress testing4445public static int iArr[] = new int[100];4647// Some methods to fill up the compile queue48public static void test0() { }49public static void test1() { }50public static void test2() { }51public static void test3() { }52public static void test4() { }53public static void test5() { }54public static void test6() { }55public static void test7() { }56public static void test8() { }57public static void test9() { }58public static void test10() { }59public static void test11() { }60public static void test12() { }61public static void test13() { }62public static void test14() { }63public static void test15() { }64public static void test16() { }65public static void test17() { }66public static void test18() { }67public static void test19() { }6869// More methods that do some more complex things. Therefore, the compiler needs to spend some more time compiling them.70// With 50 methods, a queue size of 10000 is also reached in the second run with TieredCompilation enabled.71public static void testA0() { Arrays.sort(iArr); }72public static void testA1() { Arrays.sort(iArr); }73public static void testA2() { Arrays.sort(iArr); }74public static void testA3() { Arrays.sort(iArr); }75public static void testA4() { Arrays.sort(iArr); }76public static void testA5() { Arrays.sort(iArr); }77public static void testA6() { Arrays.sort(iArr); }78public static void testA7() { Arrays.sort(iArr); }79public static void testA8() { Arrays.sort(iArr); }80public static void testA9() { Arrays.sort(iArr); }81public static void testA10() { Arrays.sort(iArr); }82public static void testA11() { Arrays.sort(iArr); }83public static void testA12() { Arrays.sort(iArr); }84public static void testA13() { Arrays.sort(iArr); }85public static void testA14() { Arrays.sort(iArr); }86public static void testA15() { Arrays.sort(iArr); }87public static void testA16() { Arrays.sort(iArr); }88public static void testA17() { Arrays.sort(iArr); }89public static void testA18() { Arrays.sort(iArr); }90public static void testA19() { Arrays.sort(iArr); }91public static void testA20() { Arrays.sort(iArr); }92public static void testA21() { Arrays.sort(iArr); }93public static void testA22() { Arrays.sort(iArr); }94public static void testA23() { Arrays.sort(iArr); }95public static void testA24() { Arrays.sort(iArr); }96public static void testA25() { Arrays.sort(iArr); }97public static void testA26() { Arrays.sort(iArr); }98public static void testA27() { Arrays.sort(iArr); }99public static void testA28() { Arrays.sort(iArr); }100public static void testA29() { Arrays.sort(iArr); }101public static void testA30() { Arrays.sort(iArr); }102public static void testA31() { Arrays.sort(iArr); }103public static void testA32() { Arrays.sort(iArr); }104public static void testA33() { Arrays.sort(iArr); }105public static void testA34() { Arrays.sort(iArr); }106public static void testA35() { Arrays.sort(iArr); }107public static void testA36() { Arrays.sort(iArr); }108public static void testA37() { Arrays.sort(iArr); }109public static void testA38() { Arrays.sort(iArr); }110public static void testA39() { Arrays.sort(iArr); }111public static void testA40() { Arrays.sort(iArr); }112public static void testA41() { Arrays.sort(iArr); }113public static void testA42() { Arrays.sort(iArr); }114public static void testA43() { Arrays.sort(iArr); }115public static void testA44() { Arrays.sort(iArr); }116public static void testA45() { Arrays.sort(iArr); }117public static void testA46() { Arrays.sort(iArr); }118public static void testA47() { Arrays.sort(iArr); }119public static void testA48() { Arrays.sort(iArr); }120public static void testA49() { Arrays.sort(iArr); }121122public static void main(String[] args) throws Throwable {123run();124runA();125}126127public static void run() throws Throwable {128Class<?> thisClass = TestOverloadCompileQueues.class;129ClassLoader defaultLoader = thisClass.getClassLoader();130URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation();131132for (int i = 0; i < ITERS; ++i) {133// Load test class with own class loader134URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent());135Class<?> testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader);136137// Execute all test methods to trigger compilation and fill up compile queue138for (int j = 1; j < 20; ++j) {139Method method = testClass.getDeclaredMethod("test" + j);140method.invoke(null);141method.invoke(null);142}143144// Unload dead classes from ealier iterations145System.gc();146}147}148149public static void runA() throws Throwable {150Class<?> thisClass = TestOverloadCompileQueues.class;151ClassLoader defaultLoader = thisClass.getClassLoader();152URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation();153154for (int i = 0; i < ITERS_A; ++i) {155// Load test class with own class loader156URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent());157Class<?> testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader);158159// Execute all test methods to trigger compilation and fill up compile queue160for (int j = 0; j < 50; ++j) {161Method method = testClass.getDeclaredMethod("testA" + j);162method.invoke(null);163method.invoke(null);164}165}166}167}168169170