Mercurial > hg > truffle
annotate test/compiler/8005419/Test8005419.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 | 55fb97c4c58d |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
7477
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
1 /* |
17467
55fb97c4c58d
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
7477
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
7477
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
4 * |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
8 * |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
13 * accompanied this code). |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
14 * |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
18 * |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
21 * questions. |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
22 */ |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
23 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
24 /* |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
25 * @test |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
26 * @bug 8005419 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
27 * @summary Improve intrinsics code performance on x86 by using AVX2 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
28 * @run main/othervm -Xbatch -Xmx64m Test8005419 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
29 * |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
30 */ |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
31 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
32 public class Test8005419 { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
33 public static int SIZE = 64; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
34 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
35 public static void main(String[] args) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
36 char[] a = new char[SIZE]; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
37 char[] b = new char[SIZE]; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
38 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
39 for (int i = 16; i < SIZE; i++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
40 a[i] = (char)i; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
41 b[i] = (char)i; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
42 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
43 String s1 = new String(a); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
44 String s2 = new String(b); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
45 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
46 // Warm up |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
47 boolean failed = false; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
48 int result = 0; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
49 for (int i = 0; i < 10000; i++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
50 result += test(s1, s2); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
51 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
52 for (int i = 0; i < 10000; i++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
53 result += test(s1, s2); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
54 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
55 for (int i = 0; i < 10000; i++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
56 result += test(s1, s2); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
57 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
58 if (result != 0) failed = true; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
59 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
60 System.out.println("Start testing"); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
61 // Compare same string |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
62 result = test(s1, s1); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
63 if (result != 0) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
64 failed = true; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
65 System.out.println("Failed same: result = " + result + ", expected 0"); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
66 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
67 // Compare equal strings |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
68 for (int i = 1; i <= SIZE; i++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
69 s1 = new String(a, 0, i); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
70 s2 = new String(b, 0, i); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
71 result = test(s1, s2); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
72 if (result != 0) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
73 failed = true; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
74 System.out.println("Failed equals s1[" + i + "], s2[" + i + "]: result = " + result + ", expected 0"); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
75 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
76 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
77 // Compare equal strings but different sizes |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
78 for (int i = 1; i <= SIZE; i++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
79 s1 = new String(a, 0, i); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
80 for (int j = 1; j <= SIZE; j++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
81 s2 = new String(b, 0, j); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
82 result = test(s1, s2); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
83 if (result != (i-j)) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
84 failed = true; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
85 System.out.println("Failed diff size s1[" + i + "], s2[" + j + "]: result = " + result + ", expected " + (i-j)); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
86 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
87 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
88 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
89 // Compare strings with one char different and different sizes |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
90 for (int i = 1; i <= SIZE; i++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
91 s1 = new String(a, 0, i); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
92 for (int j = 0; j < i; j++) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
93 b[j] -= 3; // change char |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
94 s2 = new String(b, 0, i); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
95 result = test(s1, s2); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
96 int chdiff = a[j] - b[j]; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
97 if (result != chdiff) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
98 failed = true; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
99 System.out.println("Failed diff char s1[" + i + "], s2[" + i + "]: result = " + result + ", expected " + chdiff); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
100 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
101 result = test(s2, s1); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
102 chdiff = b[j] - a[j]; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
103 if (result != chdiff) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
104 failed = true; |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
105 System.out.println("Failed diff char s2[" + i + "], s1[" + i + "]: result = " + result + ", expected " + chdiff); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
106 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
107 b[j] += 3; // restore |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
108 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
109 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
110 if (failed) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
111 System.out.println("FAILED"); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
112 System.exit(97); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
113 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
114 System.out.println("PASSED"); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
115 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
116 |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
117 private static int test(String str1, String str2) { |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
118 return str1.compareTo(str2); |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
119 } |
038dd2875b94
8005419: Improve intrinsics code performance on x86 by using AVX2
kvn
parents:
diff
changeset
|
120 } |