Mercurial > hg > truffle
annotate test/runtime/CompressedOops/CompressedClassPointers.java @ 20218:828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
Summary: A few locations in the code use sizeof(this) which returns the size of the pointer instead of sizeof(classname) which returns the size of the sum of its members. This change fixes these errors and adds a few tests.
Reviewed-by: mgerdin, brutisso
author | tschatzl |
---|---|
date | Mon, 21 Jul 2014 09:40:19 +0200 |
parents | 209aa13ab8c0 |
children | de7f1b016d55 |
rev | line source |
---|---|
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
1 /* |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
4 * |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
8 * |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
13 * accompanied this code). |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
14 * |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
18 * |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
21 * questions. |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
22 */ |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
23 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
24 /* |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
25 * @test |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
26 * @bug 8024927 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
27 * @summary Testing address of compressed class pointer space as best as possible. |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
28 * @library /testlibrary |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
29 */ |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
30 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
31 import com.oracle.java.testlibrary.*; |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
32 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
33 public class CompressedClassPointers { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
34 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
35 public static void smallHeapTest() throws Exception { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
36 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
37 "-XX:+UnlockDiagnosticVMOptions", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
38 "-XX:SharedBaseAddress=8g", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
39 "-Xmx128m", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
40 "-XX:+PrintCompressedOopsMode", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
41 "-XX:+VerifyBeforeGC", "-version"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
42 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
43 output.shouldContain("Narrow klass base: 0x0000000000000000"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
44 output.shouldHaveExitValue(0); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
45 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
46 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
47 public static void smallHeapTestWith3G() throws Exception { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
48 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
49 "-XX:+UnlockDiagnosticVMOptions", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
50 "-XX:CompressedClassSpaceSize=3g", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
51 "-Xmx128m", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
52 "-XX:+PrintCompressedOopsMode", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
53 "-XX:+VerifyBeforeGC", "-version"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
54 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
55 output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
56 output.shouldHaveExitValue(0); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
57 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
58 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
59 public static void largeHeapTest() throws Exception { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
60 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
61 "-XX:+UnlockDiagnosticVMOptions", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
62 "-Xmx30g", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
63 "-XX:+PrintCompressedOopsMode", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
64 "-XX:+VerifyBeforeGC", "-version"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
65 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
66 output.shouldNotContain("Narrow klass base: 0x0000000000000000"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
67 output.shouldContain("Narrow klass shift: 0"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
68 output.shouldHaveExitValue(0); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
69 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
70 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
71 public static void largePagesTest() throws Exception { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
72 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
73 "-XX:+UnlockDiagnosticVMOptions", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
74 "-Xmx128m", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
75 "-XX:+UseLargePages", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
76 "-XX:+PrintCompressedOopsMode", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
77 "-XX:+VerifyBeforeGC", "-version"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
78 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
79 output.shouldContain("Narrow klass base:"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
80 output.shouldHaveExitValue(0); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
81 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
82 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
83 public static void sharingTest() throws Exception { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
84 // Test small heaps |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
85 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
86 "-XX:+UnlockDiagnosticVMOptions", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
87 "-XX:SharedArchiveFile=./sample.jsa", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
88 "-Xmx128m", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
89 "-XX:SharedBaseAddress=8g", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
90 "-XX:+PrintCompressedOopsMode", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
91 "-XX:+VerifyBeforeGC", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
92 "-Xshare:dump"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
93 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
94 try { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
95 output.shouldContain("Loading classes to share"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
96 output.shouldHaveExitValue(0); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
97 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
98 pb = ProcessTools.createJavaProcessBuilder( |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
99 "-XX:+UnlockDiagnosticVMOptions", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
100 "-XX:SharedArchiveFile=./sample.jsa", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
101 "-Xmx128m", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
102 "-XX:SharedBaseAddress=8g", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
103 "-XX:+PrintCompressedOopsMode", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
104 "-Xshare:on", |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
105 "-version"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
106 output = new OutputAnalyzer(pb.start()); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
107 output.shouldContain("sharing"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
108 output.shouldHaveExitValue(0); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
109 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
110 } catch (RuntimeException e) { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
111 output.shouldContain("Unable to use shared archive"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
112 output.shouldHaveExitValue(1); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
113 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
114 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
115 |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
116 public static void main(String[] args) throws Exception { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
117 if (!Platform.is64bit()) { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
118 // Can't test this on 32 bit, just pass |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
119 System.out.println("Skipping test on 32bit"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
120 return; |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
121 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
122 // Solaris 10 can't mmap compressed oops space without a base |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
123 if (Platform.isSolaris()) { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
124 String name = System.getProperty("os.version"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
125 if (name.equals("5.10")) { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
126 System.out.println("Skipping test on Solaris 10"); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
127 return; |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
128 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
129 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
130 smallHeapTest(); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
131 smallHeapTestWith3G(); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
132 largeHeapTest(); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
133 largePagesTest(); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
134 sharingTest(); |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
135 } |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
diff
changeset
|
136 } |