author | pchistyakov |
Mon, 26 Jan 2015 18:59:09 +0300 | |
changeset 28727 | 3e314e9c40f1 |
parent 28487 | 34406bbb4f3a |
child 29678 | dd2f3932c21e |
permissions | -rw-r--r-- |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
1 |
/* |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
4 |
* |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
8 |
* |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
14 |
* |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
18 |
* |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
22 |
* |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
23 |
*/ |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
24 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
25 |
import java.lang.reflect.Method; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
26 |
import java.util.EnumSet; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
27 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
28 |
import sun.hotspot.WhiteBox; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
29 |
import sun.hotspot.code.BlobType; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
30 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
31 |
import com.oracle.java.testlibrary.Asserts; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
32 |
import com.oracle.java.testlibrary.InfiniteLoop; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
33 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
34 |
/* |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
35 |
* @test |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
36 |
* @bug 8059624 8064669 |
28190
5a6b07edeb21
8066433: Move Whitebox test library to top level repository
thartmann
parents:
27917
diff
changeset
|
37 |
* @library /testlibrary /../../test/lib |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
38 |
* @build ForceNMethodSweepTest |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
39 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
40 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
41 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
42 |
* -XX:-TieredCompilation -XX:+WhiteBoxAPI |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
43 |
* -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* |
28727
3e314e9c40f1
8066998: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest.java : sweep shouldn't increase usage
pchistyakov
parents:
28487
diff
changeset
|
44 |
* -XX:-BackgroundCompilation ForceNMethodSweepTest |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
45 |
* @summary testing of WB::forceNMethodSweep |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
46 |
*/ |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
47 |
public class ForceNMethodSweepTest extends CompilerWhiteBoxTest { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
48 |
public static void main(String[] args) throws Exception { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
49 |
CompilerWhiteBoxTest.main(ForceNMethodSweepTest::new, args); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
50 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
51 |
private final EnumSet<BlobType> blobTypes; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
52 |
private ForceNMethodSweepTest(TestCase testCase) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
53 |
super(testCase); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
54 |
// to prevent inlining of #method |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
55 |
WHITE_BOX.testSetDontInlineMethod(method, true); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
56 |
blobTypes = BlobType.getAvailable(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
57 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
58 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
59 |
@Override |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
60 |
protected void test() throws Exception { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
61 |
checkNotCompiled(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
62 |
guaranteedSweep(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
63 |
int usage = getTotalUsage(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
64 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
65 |
compile(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
66 |
checkCompiled(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
67 |
int afterCompilation = getTotalUsage(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
68 |
Asserts.assertGT(afterCompilation, usage, |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
69 |
"compilation should increase usage"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
70 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
71 |
guaranteedSweep(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
72 |
int afterSweep = getTotalUsage(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
73 |
Asserts.assertLTE(afterSweep, afterCompilation, |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
74 |
"sweep shouldn't increase usage"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
75 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
76 |
deoptimize(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
77 |
guaranteedSweep(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
78 |
int afterDeoptAndSweep = getTotalUsage(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
79 |
Asserts.assertLT(afterDeoptAndSweep, afterSweep, |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
80 |
"sweep after deoptimization should decrease usage"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
81 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
82 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
83 |
private int getTotalUsage() { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
84 |
int usage = 0; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
85 |
for (BlobType type : blobTypes) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
86 |
usage += type.getMemoryPool().getUsage().getUsed(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
87 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
88 |
return usage; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
89 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
90 |
private void guaranteedSweep() { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
91 |
// not entrant -> ++stack_traversal_mark -> zombie -> reclamation -> flushed |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
92 |
for (int i = 0; i < 5; ++i) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
93 |
WHITE_BOX.fullGC(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
94 |
WHITE_BOX.forceNMethodSweep(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
95 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
96 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
97 |
} |