Mercurial > hg > truffle
annotate test/compiler/6732154/Test6732154.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 | 121e5708ae96 |
children |
rev | line source |
---|---|
6142
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
1 /* |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
4 * |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
8 * |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
13 * accompanied this code). |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
14 * |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
18 * |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
21 * questions. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
22 * |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
23 */ |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
24 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
25 /** |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
26 * @test |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
27 * @bug 6732154 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
28 * @summary REG: Printing an Image using image/gif doc flavor crashes the VM, Solsparc |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
29 * |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
30 * @run main/othervm -Xcomp -XX:CompileOnly="Test6732154::ascii85Encode" Test6732154 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
31 */ |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
32 public class Test6732154 { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
33 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
34 // Exact copy of sun.print.PSPrinterJob.ascii85Encode([b)[b |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
35 private byte[] ascii85Encode(byte[] inArr) { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
36 byte[] outArr = new byte[((inArr.length+4) * 5 / 4) + 2]; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
37 long p1 = 85; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
38 long p2 = p1*p1; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
39 long p3 = p1*p2; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
40 long p4 = p1*p3; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
41 byte pling = '!'; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
42 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
43 int i = 0; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
44 int olen = 0; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
45 long val, rem; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
46 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
47 while (i+3 < inArr.length) { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
48 val = ((long)((inArr[i++]&0xff))<<24) + |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
49 ((long)((inArr[i++]&0xff))<<16) + |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
50 ((long)((inArr[i++]&0xff))<< 8) + |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
51 ((long)(inArr[i++]&0xff)); |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
52 if (val == 0) { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
53 outArr[olen++] = 'z'; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
54 } else { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
55 rem = val; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
56 outArr[olen++] = (byte)(rem / p4 + pling); rem = rem % p4; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
57 outArr[olen++] = (byte)(rem / p3 + pling); rem = rem % p3; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
58 outArr[olen++] = (byte)(rem / p2 + pling); rem = rem % p2; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
59 outArr[olen++] = (byte)(rem / p1 + pling); rem = rem % p1; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
60 outArr[olen++] = (byte)(rem + pling); |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
61 } |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
62 } |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
63 // input not a multiple of 4 bytes, write partial output. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
64 if (i < inArr.length) { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
65 int n = inArr.length - i; // n bytes remain to be written |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
66 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
67 val = 0; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
68 while (i < inArr.length) { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
69 val = (val << 8) + (inArr[i++]&0xff); |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
70 } |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
71 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
72 int append = 4 - n; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
73 while (append-- > 0) { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
74 val = val << 8; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
75 } |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
76 byte []c = new byte[5]; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
77 rem = val; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
78 c[0] = (byte)(rem / p4 + pling); rem = rem % p4; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
79 c[1] = (byte)(rem / p3 + pling); rem = rem % p3; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
80 c[2] = (byte)(rem / p2 + pling); rem = rem % p2; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
81 c[3] = (byte)(rem / p1 + pling); rem = rem % p1; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
82 c[4] = (byte)(rem + pling); |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
83 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
84 for (int b = 0; b < n+1 ; b++) { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
85 outArr[olen++] = c[b]; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
86 } |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
87 } |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
88 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
89 // write EOD marker. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
90 outArr[olen++]='~'; outArr[olen++]='>'; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
91 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
92 /* The original intention was to insert a newline after every 78 bytes. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
93 * This was mainly intended for legibility but I decided against this |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
94 * partially because of the (small) amount of extra space, and |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
95 * partially because for line breaks either would have to hardwire |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
96 * ascii 10 (newline) or calculate space in bytes to allocate for |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
97 * the platform's newline byte sequence. Also need to be careful |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
98 * about where its inserted: |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
99 * Ascii 85 decoder ignores white space except for one special case: |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
100 * you must ensure you do not split the EOD marker across lines. |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
101 */ |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
102 byte[] retArr = new byte[olen]; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
103 System.arraycopy(outArr, 0, retArr, 0, olen); |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
104 return retArr; |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
105 } |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
106 |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
107 public static void main(String[] args) { |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
108 new Test6732154().ascii85Encode(new byte[0]); |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
109 System.out.println("Test passed."); |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
110 } |
121e5708ae96
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
111 } |