author | iignatyev |
Mon, 10 Nov 2014 19:04:38 +0300 | |
changeset 27642 | 8c9eff693145 |
child 28190 | 5a6b07edeb21 |
permissions | -rw-r--r-- |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
1 |
/* |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
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 |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
26 |
* @bug 8059624 |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
27 |
* @library /testlibrary /testlibrary/whitebox |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
28 |
* @build LockCompilationTest |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
29 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
30 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
31 |
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* LockCompilationTest |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
32 |
* @summary testing of WB::lock/unlockCompilation() |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
33 |
*/ |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
34 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
35 |
import java.io.OutputStream; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
36 |
import java.io.PrintWriter; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
37 |
import java.util.concurrent.BrokenBarrierException; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
38 |
import java.util.concurrent.CyclicBarrier; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
39 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
40 |
import com.oracle.java.testlibrary.Asserts; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
41 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
42 |
public class LockCompilationTest extends CompilerWhiteBoxTest { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
43 |
public static void main(String[] args) throws Exception { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
44 |
CompilerWhiteBoxTest.main(LockCompilationTest::new, args); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
45 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
46 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
47 |
private LockCompilationTest(TestCase testCase) { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
48 |
super(testCase); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
49 |
// to prevent inlining of #method |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
50 |
WHITE_BOX.testSetDontInlineMethod(method, true); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
51 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
52 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
53 |
protected void test() throws Exception { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
54 |
checkNotCompiled(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
55 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
56 |
System.out.println("locking compilation"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
57 |
WHITE_BOX.lockCompilation(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
58 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
59 |
try { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
60 |
System.out.println("trying to compile"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
61 |
compile(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
62 |
// to check if it works correctly w/ safepoints |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
63 |
System.out.println("going to safepoint"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
64 |
WHITE_BOX.fullGC(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
65 |
waitBackgroundCompilation(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
66 |
Asserts.assertTrue( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
67 |
WHITE_BOX.isMethodQueuedForCompilation(method), |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
68 |
method + " must be in queue"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
69 |
Asserts.assertFalse( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
70 |
WHITE_BOX.isMethodCompiled(method, false), |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
71 |
method + " must be not compiled"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
72 |
Asserts.assertEQ( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
73 |
WHITE_BOX.getMethodCompilationLevel(method, false), 0, |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
74 |
method + " comp_level must be == 0"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
75 |
Asserts.assertFalse( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
76 |
WHITE_BOX.isMethodCompiled(method, true), |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
77 |
method + " must be not osr_compiled"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
78 |
Asserts.assertEQ( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
79 |
WHITE_BOX.getMethodCompilationLevel(method, true), 0, |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
80 |
method + " osr_comp_level must be == 0"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
81 |
} finally { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
82 |
System.out.println("unlocking compilation"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
83 |
WHITE_BOX.unlockCompilation(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
84 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
85 |
waitBackgroundCompilation(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
86 |
Asserts.assertFalse( |
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 not be in queue"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
89 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
90 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
91 |