diff --git a/src/share/vm/opto/divnode.cpp b/src/share/vm/opto/divnode.cpp index 5539410070d45cc61b63e19ffdc47ed15b86c622..14fa0790bb63365205a334a7a94fa4dca98384f7 100644 --- a/src/share/vm/opto/divnode.cpp +++ b/src/share/vm/opto/divnode.cpp @@ -284,9 +284,14 @@ static Node* long_by_long_mulhi(PhaseGVN* phase, Node* dividend, jlong magic_con const int N = 64; + // Dummy node to keep intermediate nodes alive during construction + Node* hook = new (phase->C, 4) Node(4); + // u0 = u & 0xFFFFFFFF; u1 = u >> 32; Node* u0 = phase->transform(new (phase->C, 3) AndLNode(dividend, phase->longcon(0xFFFFFFFF))); Node* u1 = phase->transform(new (phase->C, 3) RShiftLNode(dividend, phase->intcon(N / 2))); + hook->init_req(0, u0); + hook->init_req(1, u1); // v0 = v & 0xFFFFFFFF; v1 = v >> 32; Node* v0 = phase->longcon(magic_const & 0xFFFFFFFF); @@ -299,19 +304,14 @@ static Node* long_by_long_mulhi(PhaseGVN* phase, Node* dividend, jlong magic_con Node* u1v0 = phase->transform(new (phase->C, 3) MulLNode(u1, v0)); Node* temp = phase->transform(new (phase->C, 3) URShiftLNode(w0, phase->intcon(N / 2))); Node* t = phase->transform(new (phase->C, 3) AddLNode(u1v0, temp)); + hook->init_req(2, t); // w1 = t & 0xFFFFFFFF; - Node* w1 = new (phase->C, 3) AndLNode(t, phase->longcon(0xFFFFFFFF)); + Node* w1 = phase->transform(new (phase->C, 3) AndLNode(t, phase->longcon(0xFFFFFFFF))); + hook->init_req(3, w1); // w2 = t >> 32; - Node* w2 = new (phase->C, 3) RShiftLNode(t, phase->intcon(N / 2)); - - // 6732154: Construct both w1 and w2 before transforming, so t - // doesn't go dead prematurely. - // 6837011: We need to transform w2 before w1 because the - // transformation of w1 could return t. - w2 = phase->transform(w2); - w1 = phase->transform(w1); + Node* w2 = phase->transform(new (phase->C, 3) RShiftLNode(t, phase->intcon(N / 2))); // w1 = u0*v1 + w1; Node* u0v1 = phase->transform(new (phase->C, 3) MulLNode(u0, v1)); @@ -322,6 +322,16 @@ static Node* long_by_long_mulhi(PhaseGVN* phase, Node* dividend, jlong magic_con Node* temp1 = phase->transform(new (phase->C, 3) AddLNode(u1v1, w2)); Node* temp2 = phase->transform(new (phase->C, 3) RShiftLNode(w1, phase->intcon(N / 2))); + // Remove the bogus extra edges used to keep things alive + PhaseIterGVN* igvn = phase->is_IterGVN(); + if (igvn != NULL) { + igvn->remove_dead_node(hook); + } else { + for (int i = 0; i < 4; i++) { + hook->set_req(i, NULL); + } + } + return new (phase->C, 3) AddLNode(temp1, temp2); } diff --git a/test/compiler/6732154/Test6732154.java b/test/compiler/6732154/Test6732154.java new file mode 100644 index 0000000000000000000000000000000000000000..3618f678455d067cd1841f592edae34d95ae6b8d --- /dev/null +++ b/test/compiler/6732154/Test6732154.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 6732154 + * @summary REG: Printing an Image using image/gif doc flavor crashes the VM, Solsparc + * + * @run main/othervm -Xcomp -XX:CompileOnly="Test6732154::ascii85Encode" Test6732154 + */ +public class Test6732154 { + + // Exact copy of sun.print.PSPrinterJob.ascii85Encode([b)[b + private byte[] ascii85Encode(byte[] inArr) { + byte[] outArr = new byte[((inArr.length+4) * 5 / 4) + 2]; + long p1 = 85; + long p2 = p1*p1; + long p3 = p1*p2; + long p4 = p1*p3; + byte pling = '!'; + + int i = 0; + int olen = 0; + long val, rem; + + while (i+3 < inArr.length) { + val = ((long)((inArr[i++]&0xff))<<24) + + ((long)((inArr[i++]&0xff))<<16) + + ((long)((inArr[i++]&0xff))<< 8) + + ((long)(inArr[i++]&0xff)); + if (val == 0) { + outArr[olen++] = 'z'; + } else { + rem = val; + outArr[olen++] = (byte)(rem / p4 + pling); rem = rem % p4; + outArr[olen++] = (byte)(rem / p3 + pling); rem = rem % p3; + outArr[olen++] = (byte)(rem / p2 + pling); rem = rem % p2; + outArr[olen++] = (byte)(rem / p1 + pling); rem = rem % p1; + outArr[olen++] = (byte)(rem + pling); + } + } + // input not a multiple of 4 bytes, write partial output. + if (i < inArr.length) { + int n = inArr.length - i; // n bytes remain to be written + + val = 0; + while (i < inArr.length) { + val = (val << 8) + (inArr[i++]&0xff); + } + + int append = 4 - n; + while (append-- > 0) { + val = val << 8; + } + byte []c = new byte[5]; + rem = val; + c[0] = (byte)(rem / p4 + pling); rem = rem % p4; + c[1] = (byte)(rem / p3 + pling); rem = rem % p3; + c[2] = (byte)(rem / p2 + pling); rem = rem % p2; + c[3] = (byte)(rem / p1 + pling); rem = rem % p1; + c[4] = (byte)(rem + pling); + + for (int b = 0; b < n+1 ; b++) { + outArr[olen++] = c[b]; + } + } + + // write EOD marker. + outArr[olen++]='~'; outArr[olen++]='>'; + + /* The original intention was to insert a newline after every 78 bytes. + * This was mainly intended for legibility but I decided against this + * partially because of the (small) amount of extra space, and + * partially because for line breaks either would have to hardwire + * ascii 10 (newline) or calculate space in bytes to allocate for + * the platform's newline byte sequence. Also need to be careful + * about where its inserted: + * Ascii 85 decoder ignores white space except for one special case: + * you must ensure you do not split the EOD marker across lines. + */ + byte[] retArr = new byte[olen]; + System.arraycopy(outArr, 0, retArr, 0, olen); + return retArr; + } + + public static void main(String[] args) { + new Test6732154().ascii85Encode(new byte[0]); + System.out.println("Test passed."); + } +} diff --git a/test/compiler/7169782/Test7169782.java b/test/compiler/7169782/Test7169782.java new file mode 100644 index 0000000000000000000000000000000000000000..381c4c903fb2814eac7e04560cd995fdd19d76c3 --- /dev/null +++ b/test/compiler/7169782/Test7169782.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 7169782 + * @summary C2: SIGSEGV in LShiftLNode::Ideal(PhaseGVN*, bool) + * + * @run main/othervm -Xcomp -XX:CompileOnly="Test7169782::" Test7169782 + */ + +public class Test7169782 { + static long var_8; + + static { + var_8 /= (long)(1E100 + ("".startsWith("a", 0) ? 1 : 2)); + } + + public static void main(String[] args) { + System.out.println("Test passed."); + } +}