test/hotspot/jtreg/compiler/whitebox/LockCompilationTest.java
author jiangli
Wed, 27 Sep 2017 17:55:20 -0400
changeset 47548 664b9d44db74
parent 47216 71c04702a3d5
child 48321 e9e3edac1768
permissions -rw-r--r--
8068314: "Java fields that are currently set during shared space dumping" comment is incorrect Summary: CDS dump time should also initialize preallocated out_of_memory error messages. Reviewed-by: iklam, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     4
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     8
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    14
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    18
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    21
 * questions.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    22
 */
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    23
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    24
/*
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    25
 * @test LockCompilationTest
36811
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    26
 * @bug 8059624 8152169
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    27
 * @summary testing of WB::lock/unlockCompilation()
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    28
 * @library /test/lib /
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 38032
diff changeset
    29
 * @modules java.base/jdk.internal.misc
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    30
 *          java.management
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    31
 * @build sun.hotspot.WhiteBox
36811
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    32
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    33
 *                                sun.hotspot.WhiteBox$WhiteBoxPermission
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    34
 * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    35
 *                   -XX:+WhiteBoxAPI -XX:-UseCounterDecay
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    36
 *                   compiler.whitebox.LockCompilationTest
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    37
 */
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    38
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    39
package compiler.whitebox;
36599
8dd1694c0480 8066770: EnqueueMethodForCompilationTest.java fails to compile method
neliasso
parents: 34185
diff changeset
    40
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    41
import jdk.test.lib.Asserts;
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    42
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    43
public class LockCompilationTest extends CompilerWhiteBoxTest {
36811
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    44
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    45
    public static void main(String[] args) throws Exception {
36811
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    46
        // This case waits for 5 seconds and verifies that the method hasn't been
36599
8dd1694c0480 8066770: EnqueueMethodForCompilationTest.java fails to compile method
neliasso
parents: 34185
diff changeset
    47
        // compiled during that time. Only do that for one of the test cases.
36811
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    48
38032
bedc2fbb9454 8153885: [TESTBUG] few regression tests failed after 8151880 changes
neliasso
parents: 38025
diff changeset
    49
        // Only compile SimpleTestCaseHelper.method and exclude all other to ensure no
36811
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    50
        // contention on the compile queue causes problems.
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    51
        String directive =
38025
5ed9ce1e4a2f 8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents: 36811
diff changeset
    52
                "[{ match:\"*SimpleTestCaseHelper.method\", Exclude:false}, " +
36811
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    53
                " { match:\"*.*\", Exclude:true}]";
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    54
        if (WHITE_BOX.addCompilerDirective(directive) != 2) {
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    55
            throw new RuntimeException("Could not add directive");
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    56
        }
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    57
        try {
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    58
            CompilerWhiteBoxTest.main(LockCompilationTest::new, new String[] {"METHOD_TEST"});
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    59
        } finally {
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    60
            WHITE_BOX.removeCompilerDirective(2);
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    61
        }
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    62
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    63
    }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    64
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    65
    private LockCompilationTest(TestCase testCase) {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    66
        super(testCase);
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    67
        // to prevent inlining of #method
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    68
        WHITE_BOX.testSetDontInlineMethod(method, true);
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    69
    }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    70
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    71
    protected void test() throws Exception {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    72
        checkNotCompiled();
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    73
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    74
        System.out.println("locking compilation");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    75
        WHITE_BOX.lockCompilation();
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    76
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    77
        try {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    78
            System.out.println("trying to compile");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    79
            compile();
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    80
            // to check if it works correctly w/ safepoints
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    81
            System.out.println("going to safepoint");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    82
            WHITE_BOX.fullGC();
36811
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    83
            // Sleep a while and then make sure the compile is still waiting
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    84
            Thread.sleep(5000);
721b2da25ee1 8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents: 36599
diff changeset
    85
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    86
            Asserts.assertTrue(
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    87
                    WHITE_BOX.isMethodQueuedForCompilation(method),
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    88
                    method + " must be in queue");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    89
            Asserts.assertFalse(
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    90
                    WHITE_BOX.isMethodCompiled(method, false),
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    91
                    method + " must be not compiled");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    92
            Asserts.assertEQ(
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    93
                    WHITE_BOX.getMethodCompilationLevel(method, false), 0,
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    94
                    method + " comp_level must be == 0");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    95
            Asserts.assertFalse(
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    96
                    WHITE_BOX.isMethodCompiled(method, true),
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    97
                    method + " must be not osr_compiled");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    98
            Asserts.assertEQ(
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    99
                    WHITE_BOX.getMethodCompilationLevel(method, true), 0,
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   100
                    method + " osr_comp_level must be == 0");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   101
        } finally {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   102
            System.out.println("unlocking compilation");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   103
            WHITE_BOX.unlockCompilation();
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   104
        }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   105
        waitBackgroundCompilation();
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   106
        Asserts.assertFalse(
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   107
                WHITE_BOX.isMethodQueuedForCompilation(method),
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   108
                method + " must not be in queue");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   109
    }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   110
}
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
   111