author | bharadwaj |
Tue, 05 Apr 2016 20:32:54 +0000 | |
changeset 37295 | e00dfcc21fa1 |
parent 36811 | 721b2da25ee1 |
child 38025 | 5ed9ce1e4a2f |
permissions | -rw-r--r-- |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, 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 |
34185 | 27 |
* @library /testlibrary /test/lib / |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
28 |
* @modules java.management |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
29 |
* @build LockCompilationTest |
36811
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
30 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
31 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
36599
8dd1694c0480
8066770: EnqueueMethodForCompilationTest.java fails to compile method
neliasso
parents:
34185
diff
changeset
|
32 |
* @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI LockCompilationTest |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
33 |
* @summary testing of WB::lock/unlockCompilation() |
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 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
36 |
import java.io.OutputStream; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
37 |
import java.io.PrintWriter; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
38 |
import java.util.concurrent.BrokenBarrierException; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
39 |
import java.util.concurrent.CyclicBarrier; |
36599
8dd1694c0480
8066770: EnqueueMethodForCompilationTest.java fails to compile method
neliasso
parents:
34185
diff
changeset
|
40 |
|
34155
8d9e0cbf93a2
8138689: use package for /compiler/whitebox common classes
dpochepk
parents:
30604
diff
changeset
|
41 |
import compiler.whitebox.CompilerWhiteBoxTest; |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
42 |
import jdk.test.lib.Asserts; |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
43 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
44 |
public class LockCompilationTest extends CompilerWhiteBoxTest { |
36811
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
45 |
|
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
46 |
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
|
47 |
// 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
|
48 |
// 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
|
49 |
|
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
50 |
// Only compile SimpleTestCase$Helper.method and exclude all other to ensure no |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
51 |
// contention on the compile queue causes problems. |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
52 |
String directive = |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
53 |
"[{ match:\"*SimpleTestCase$Helper.method\", Exclude:false}, " + |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
54 |
" { match:\"*.*\", Exclude:true}]"; |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
55 |
if (WHITE_BOX.addCompilerDirective(directive) != 2) { |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
56 |
throw new RuntimeException("Could not add directive"); |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
57 |
} |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
58 |
try { |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
59 |
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
|
60 |
} finally { |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
61 |
WHITE_BOX.removeCompilerDirective(2); |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
62 |
} |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
63 |
|
27642
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 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
66 |
private LockCompilationTest(TestCase testCase) { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
67 |
super(testCase); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
68 |
// to prevent inlining of #method |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
69 |
WHITE_BOX.testSetDontInlineMethod(method, true); |
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 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
72 |
protected void test() throws Exception { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
73 |
checkNotCompiled(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
74 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
75 |
System.out.println("locking compilation"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
76 |
WHITE_BOX.lockCompilation(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
77 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
78 |
try { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
79 |
System.out.println("trying to compile"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
80 |
compile(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
81 |
// to check if it works correctly w/ safepoints |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
82 |
System.out.println("going to safepoint"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
83 |
WHITE_BOX.fullGC(); |
36811
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
84 |
// 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
|
85 |
Thread.sleep(5000); |
721b2da25ee1
8152169: LockCompilationTest.java fails due method present in the compiler queue
neliasso
parents:
36599
diff
changeset
|
86 |
|
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
87 |
Asserts.assertTrue( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
88 |
WHITE_BOX.isMethodQueuedForCompilation(method), |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
89 |
method + " must be in queue"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
90 |
Asserts.assertFalse( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
91 |
WHITE_BOX.isMethodCompiled(method, false), |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
92 |
method + " must be not compiled"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
93 |
Asserts.assertEQ( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
94 |
WHITE_BOX.getMethodCompilationLevel(method, false), 0, |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
95 |
method + " comp_level must be == 0"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
96 |
Asserts.assertFalse( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
97 |
WHITE_BOX.isMethodCompiled(method, true), |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
98 |
method + " must be not osr_compiled"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
99 |
Asserts.assertEQ( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
100 |
WHITE_BOX.getMethodCompilationLevel(method, true), 0, |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
101 |
method + " osr_comp_level must be == 0"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
102 |
} finally { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
103 |
System.out.println("unlocking compilation"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
104 |
WHITE_BOX.unlockCompilation(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
105 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
106 |
waitBackgroundCompilation(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
107 |
Asserts.assertFalse( |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
108 |
WHITE_BOX.isMethodQueuedForCompilation(method), |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
109 |
method + " must not be in queue"); |
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 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
112 |