author | lana |
Thu, 25 Oct 2012 20:04:23 -0700 | |
changeset 14110 | 0e52e8a05d0d |
parent 12956 | 1078d92535e8 |
permissions | -rw-r--r-- |
12956
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
1 |
/* |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
4 |
* |
1078d92535e8
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 |
1078d92535e8
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 |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
8 |
* |
1078d92535e8
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 |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1078d92535e8
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 |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
13 |
* accompanied this code). |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
14 |
* |
1078d92535e8
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 |
1078d92535e8
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, |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
18 |
* |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1078d92535e8
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 |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
21 |
* questions. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
22 |
* |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
23 |
*/ |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
24 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
25 |
/** |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
26 |
* @test |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
27 |
* @bug 6732154 |
1078d92535e8
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 |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
29 |
* |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
30 |
* @run main/othervm -Xcomp -XX:CompileOnly="Test6732154::ascii85Encode" Test6732154 |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
31 |
*/ |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
32 |
public class Test6732154 { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
33 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
34 |
// Exact copy of sun.print.PSPrinterJob.ascii85Encode([b)[b |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
35 |
private byte[] ascii85Encode(byte[] inArr) { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
36 |
byte[] outArr = new byte[((inArr.length+4) * 5 / 4) + 2]; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
37 |
long p1 = 85; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
38 |
long p2 = p1*p1; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
39 |
long p3 = p1*p2; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
40 |
long p4 = p1*p3; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
41 |
byte pling = '!'; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
42 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
43 |
int i = 0; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
44 |
int olen = 0; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
45 |
long val, rem; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
46 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
47 |
while (i+3 < inArr.length) { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
48 |
val = ((long)((inArr[i++]&0xff))<<24) + |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
49 |
((long)((inArr[i++]&0xff))<<16) + |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
50 |
((long)((inArr[i++]&0xff))<< 8) + |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
51 |
((long)(inArr[i++]&0xff)); |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
52 |
if (val == 0) { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
53 |
outArr[olen++] = 'z'; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
54 |
} else { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
55 |
rem = val; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
56 |
outArr[olen++] = (byte)(rem / p4 + pling); rem = rem % p4; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
57 |
outArr[olen++] = (byte)(rem / p3 + pling); rem = rem % p3; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
58 |
outArr[olen++] = (byte)(rem / p2 + pling); rem = rem % p2; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
59 |
outArr[olen++] = (byte)(rem / p1 + pling); rem = rem % p1; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
60 |
outArr[olen++] = (byte)(rem + pling); |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
61 |
} |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
62 |
} |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
63 |
// input not a multiple of 4 bytes, write partial output. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
64 |
if (i < inArr.length) { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
65 |
int n = inArr.length - i; // n bytes remain to be written |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
66 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
67 |
val = 0; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
68 |
while (i < inArr.length) { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
69 |
val = (val << 8) + (inArr[i++]&0xff); |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
70 |
} |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
71 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
72 |
int append = 4 - n; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
73 |
while (append-- > 0) { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
74 |
val = val << 8; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
75 |
} |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
76 |
byte []c = new byte[5]; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
77 |
rem = val; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
78 |
c[0] = (byte)(rem / p4 + pling); rem = rem % p4; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
79 |
c[1] = (byte)(rem / p3 + pling); rem = rem % p3; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
80 |
c[2] = (byte)(rem / p2 + pling); rem = rem % p2; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
81 |
c[3] = (byte)(rem / p1 + pling); rem = rem % p1; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
82 |
c[4] = (byte)(rem + pling); |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
83 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
84 |
for (int b = 0; b < n+1 ; b++) { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
85 |
outArr[olen++] = c[b]; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
86 |
} |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
87 |
} |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
88 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
89 |
// write EOD marker. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
90 |
outArr[olen++]='~'; outArr[olen++]='>'; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
91 |
|
1078d92535e8
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. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
93 |
* This was mainly intended for legibility but I decided against this |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
94 |
* partially because of the (small) amount of extra space, and |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
95 |
* partially because for line breaks either would have to hardwire |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
96 |
* ascii 10 (newline) or calculate space in bytes to allocate for |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
97 |
* the platform's newline byte sequence. Also need to be careful |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
98 |
* about where its inserted: |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
99 |
* Ascii 85 decoder ignores white space except for one special case: |
1078d92535e8
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. |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
101 |
*/ |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
102 |
byte[] retArr = new byte[olen]; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
103 |
System.arraycopy(outArr, 0, retArr, 0, olen); |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
104 |
return retArr; |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
105 |
} |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
106 |
|
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
107 |
public static void main(String[] args) { |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
108 |
new Test6732154().ascii85Encode(new byte[0]); |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
109 |
System.out.println("Test passed."); |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
110 |
} |
1078d92535e8
7169782: C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool)
kvn
parents:
diff
changeset
|
111 |
} |