author | jiangli |
Wed, 27 Sep 2017 17:55:20 -0400 | |
changeset 47548 | 664b9d44db74 |
parent 47216 | 71c04702a3d5 |
child 49191 | 13378aa8527e |
permissions | -rw-r--r-- |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
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. |
27917
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 |
* @test |
38020
4fa831d0f4bf
8153265: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest should not assume asserts are benign
shade
parents:
36818
diff
changeset
|
26 |
* @bug 8059624 8064669 8153265 |
40059 | 27 |
* @summary testing of WB::forceNMethodSweep |
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:
38025
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
40059 | 30 |
* java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
31 |
* @build sun.hotspot.WhiteBox |
38025
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
38020
diff
changeset
|
32 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
38020
diff
changeset
|
33 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
34 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
35 |
* -XX:-TieredCompilation -XX:+WhiteBoxAPI |
38025
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
38020
diff
changeset
|
36 |
* -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* |
40059 | 37 |
* -XX:-BackgroundCompilation -XX:-UseCounterDecay |
38 |
* compiler.whitebox.ForceNMethodSweepTest |
|
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
39 |
*/ |
40059 | 40 |
|
41 |
package compiler.whitebox; |
|
42 |
||
43 |
import jdk.test.lib.Asserts; |
|
44 |
import sun.hotspot.code.BlobType; |
|
45 |
||
46 |
import java.util.EnumSet; |
|
47 |
||
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
48 |
public class ForceNMethodSweepTest extends CompilerWhiteBoxTest { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
49 |
public static void main(String[] args) throws Exception { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
50 |
CompilerWhiteBoxTest.main(ForceNMethodSweepTest::new, args); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
51 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
52 |
private final EnumSet<BlobType> blobTypes; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
53 |
private ForceNMethodSweepTest(TestCase testCase) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
54 |
super(testCase); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
55 |
// to prevent inlining of #method |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
56 |
WHITE_BOX.testSetDontInlineMethod(method, true); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
57 |
blobTypes = BlobType.getAvailable(); |
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 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
60 |
@Override |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
61 |
protected void test() throws Exception { |
38020
4fa831d0f4bf
8153265: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest should not assume asserts are benign
shade
parents:
36818
diff
changeset
|
62 |
// prime the asserts: get their bytecodes loaded, any lazy computation |
4fa831d0f4bf
8153265: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest should not assume asserts are benign
shade
parents:
36818
diff
changeset
|
63 |
// resolved, and executed once |
4fa831d0f4bf
8153265: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest should not assume asserts are benign
shade
parents:
36818
diff
changeset
|
64 |
Asserts.assertGT(1, 0, "message"); |
4fa831d0f4bf
8153265: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest should not assume asserts are benign
shade
parents:
36818
diff
changeset
|
65 |
Asserts.assertLTE(0, 0, "message"); |
4fa831d0f4bf
8153265: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest should not assume asserts are benign
shade
parents:
36818
diff
changeset
|
66 |
Asserts.assertLT(-1, 0, "message"); |
4fa831d0f4bf
8153265: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest should not assume asserts are benign
shade
parents:
36818
diff
changeset
|
67 |
|
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
68 |
checkNotCompiled(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
69 |
guaranteedSweep(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
70 |
int usage = getTotalUsage(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
71 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
72 |
compile(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
73 |
checkCompiled(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
74 |
int afterCompilation = getTotalUsage(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
75 |
Asserts.assertGT(afterCompilation, usage, |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
76 |
"compilation should increase usage"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
77 |
|
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
78 |
guaranteedSweep(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
79 |
int afterSweep = getTotalUsage(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
80 |
Asserts.assertLTE(afterSweep, afterCompilation, |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
81 |
"sweep shouldn't increase usage"); |
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 |
deoptimize(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
84 |
guaranteedSweep(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
85 |
int afterDeoptAndSweep = getTotalUsage(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
86 |
Asserts.assertLT(afterDeoptAndSweep, afterSweep, |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
87 |
"sweep after deoptimization should decrease usage"); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
88 |
} |
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 int getTotalUsage() { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
91 |
int usage = 0; |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
92 |
for (BlobType type : blobTypes) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
93 |
usage += type.getMemoryPool().getUsage().getUsed(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
94 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
95 |
return usage; |
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 |
private void guaranteedSweep() { |
36818
b40330c06dea
8136458: Remove "marked for reclamation" nmethod state
thartmann
parents:
34185
diff
changeset
|
98 |
// not entrant -> ++stack_traversal_mark -> zombie -> flushed |
27917
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
99 |
for (int i = 0; i < 5; ++i) { |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
100 |
WHITE_BOX.fullGC(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
101 |
WHITE_BOX.forceNMethodSweep(); |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
102 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
103 |
} |
c5937f7b4e8b
8064669: compiler/whitebox/AllocationCodeBlobTest.java crashes / asserts
iignatyev
parents:
diff
changeset
|
104 |
} |