test/compiler/tiered/Level2RecompilationTest.java

Wed, 05 Jun 2019 03:07:31 +0100

author
xliu
date
Wed, 05 Jun 2019 03:07:31 +0100
changeset 9690
61d955db2a5b
permissions
-rw-r--r--

8222670: pathological case of JIT recompilation and code cache bloat
Summary: Prevent downgraded compilation tasks from recompiling.
Reviewed-by: sgehwolf, thartmann, andrew

xliu@9690 1 /*
xliu@9690 2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
xliu@9690 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
xliu@9690 4 *
xliu@9690 5 * This code is free software; you can redistribute it and/or modify it
xliu@9690 6 * under the terms of the GNU General Public License version 2 only, as
xliu@9690 7 * published by the Free Software Foundation.
xliu@9690 8 *
xliu@9690 9 * This code is distributed in the hope that it will be useful, but WITHOUT
xliu@9690 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
xliu@9690 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
xliu@9690 12 * version 2 for more details (a copy is included in the LICENSE file that
xliu@9690 13 * accompanied this code).
xliu@9690 14 *
xliu@9690 15 * You should have received a copy of the GNU General Public License version
xliu@9690 16 * 2 along with this work; if not, write to the Free Software Foundation,
xliu@9690 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
xliu@9690 18 *
xliu@9690 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
xliu@9690 20 * or visit www.oracle.com if you need additional information or have any
xliu@9690 21 * questions.
xliu@9690 22 */
xliu@9690 23
xliu@9690 24 /**
xliu@9690 25 * @test Level2RecompilationTest
xliu@9690 26 * @summary Test downgrading mechanism from level 3 to level 2 for those profiled methods.
xliu@9690 27 * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
xliu@9690 28 * @build Level2RecompilationTest
xliu@9690 29 * @run main ClassFileInstaller sun.hotspot.WhiteBox
xliu@9690 30 * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation
xliu@9690 31 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay
xliu@9690 32 * -XX:CompileCommand=compileonly,SimpleTestCase$Helper::*
xliu@9690 33 * -XX:CompileCommand=print,SimpleTestCase$Helper::*
xliu@9690 34 * Level2RecompilationTest
xliu@9690 35 */
xliu@9690 36 public class Level2RecompilationTest extends CompLevelsTest {
xliu@9690 37 public static void main(String[] args) throws Throwable {
xliu@9690 38 if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
xliu@9690 39 throw new RuntimeException("Test isn't applicable for non-tiered mode");
xliu@9690 40 }
xliu@9690 41 String[] testcases = {"METHOD_TEST", "OSR_STATIC_TEST"};
xliu@9690 42 CompilerWhiteBoxTest.main(Level2RecompilationTest::new, testcases);
xliu@9690 43 }
xliu@9690 44
xliu@9690 45 protected Level2RecompilationTest(TestCase testCase) {
xliu@9690 46 super(testCase);
xliu@9690 47 // to prevent inlining of #method
xliu@9690 48 WHITE_BOX.testSetDontInlineMethod(method, true);
xliu@9690 49 }
xliu@9690 50
xliu@9690 51 @Override
xliu@9690 52 protected void test() throws Exception {
xliu@9690 53 if (skipXcompOSR()) {
xliu@9690 54 return;
xliu@9690 55 }
xliu@9690 56
xliu@9690 57 checkNotCompiled();
xliu@9690 58 int bci = WHITE_BOX.getMethodEntryBci(method);
xliu@9690 59 WHITE_BOX.markMethodProfiled(method);
xliu@9690 60 if (testCase.isOsr()) {
xliu@9690 61 // for OSR compilation, it must be the begin of a BB.
xliu@9690 62 // c1_GraphBulider.cpp:153 assert(method()->bci_block_start().at(cur_bci), ...
xliu@9690 63 bci = 0;
xliu@9690 64 }
xliu@9690 65
xliu@9690 66 WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_PROFILE, bci);
xliu@9690 67 checkCompiled();
xliu@9690 68 checkLevel(COMP_LEVEL_LIMITED_PROFILE, getCompLevel());
xliu@9690 69
xliu@9690 70 for (int i=0; i<100; ++i) {
xliu@9690 71 WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_PROFILE, bci);
xliu@9690 72 waitBackgroundCompilation();
xliu@9690 73 checkLevel(COMP_LEVEL_LIMITED_PROFILE, getCompLevel());
xliu@9690 74 }
xliu@9690 75 }
xliu@9690 76
xliu@9690 77 @Override
xliu@9690 78 protected void checkLevel(int expected, int actual) {
xliu@9690 79 if (expected == COMP_LEVEL_FULL_PROFILE
xliu@9690 80 && actual == COMP_LEVEL_LIMITED_PROFILE) {
xliu@9690 81 // for simple method full_profile may be replaced by limited_profile
xliu@9690 82 if (IS_VERBOSE) {
xliu@9690 83 System.out.printf("Level check: full profiling was replaced "
xliu@9690 84 + "by limited profiling. Expected: %d, actual:%d\n",
xliu@9690 85 expected, actual);
xliu@9690 86 }
xliu@9690 87 return;
xliu@9690 88 }
xliu@9690 89 super.checkLevel(expected, actual);
xliu@9690 90 }
xliu@9690 91 }
xliu@9690 92

mercurial