comparing with ssh://hg.openjdk.java.net/jdk8u/jdk8u-dev/hotspot searching for changes changeset: 9032:35a073d1b61b tag: JDK-8160360.patch tag: qbase user: vlivanov date: Wed Jul 06 15:05:28 2016 +0300 summary: 8160360: Mismatched field loads are folded in LoadNode::Value diff -r 921c5ee7965f -r 35a073d1b61b src/share/vm/opto/library_call.cpp --- a/src/share/vm/opto/library_call.cpp Mon Aug 12 05:04:36 2019 +0100 +++ b/src/share/vm/opto/library_call.cpp Wed Jul 06 15:05:28 2016 +0300 @@ -2664,6 +2664,8 @@ return false; } mismatched = (bt != type); + } else if (alias_type->adr_type() == TypeOopPtr::BOTTOM) { + mismatched = true; // conservatively mark all "wide" on-heap accesses as mismatched } assert(!mismatched || alias_type->adr_type()->is_oopptr(), "off-heap access can't be mismatched"); changeset: 9033:eb4fd8c55b61 tag: JDK-8216549.patch user: roland date: Fri Jan 11 10:03:00 2019 +0100 summary: 8216549: Mismatched unsafe access to non escaping object fails diff -r 35a073d1b61b -r eb4fd8c55b61 src/share/vm/opto/escape.cpp --- a/src/share/vm/opto/escape.cpp Wed Jul 06 15:05:28 2016 +0300 +++ b/src/share/vm/opto/escape.cpp Fri Jan 11 10:03:00 2019 +0100 @@ -1671,7 +1671,8 @@ // Node* n = field->ideal_node(); for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { - if (n->fast_out(i)->is_LoadStore()) { + Node* u = n->fast_out(i); + if (u->is_LoadStore() || (u->is_Mem() && u->as_Mem()->is_mismatched_access())) { jobj->set_scalar_replaceable(false); return; } diff -r 35a073d1b61b -r eb4fd8c55b61 test/compiler/unsafe/MismatchedUnsafeLoadFromNewObject.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/unsafe/MismatchedUnsafeLoadFromNewObject.java Fri Jan 11 10:03:00 2019 +0100 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2019, Red Hat, Inc. 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 8216549 + * @summary Mismatched unsafe access to non escaping object fails + * + * @library /testlibrary + * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation MismatchedUnsafeLoadFromNewObject + */ + +import java.lang.reflect.Field; +import sun.misc.Unsafe; + +import com.oracle.java.testlibrary.Utils; + +public class MismatchedUnsafeLoadFromNewObject { + public volatile int f_int = -1; + public volatile int f_int2 = -1; + + public static Unsafe unsafe = Utils.getUnsafe(); + public static final long f_int_off; + public static final long f_int2_off; + + static { + Field f_int_field = null; + Field f_int2_field = null; + try { + f_int_field = MismatchedUnsafeLoadFromNewObject.class.getField("f_int"); + f_int2_field = MismatchedUnsafeLoadFromNewObject.class.getField("f_int2"); + } catch (Exception e) { + System.out.println("reflection failed " + e); + e.printStackTrace(); + } + f_int_off = unsafe.objectFieldOffset(f_int_field); + f_int2_off = unsafe.objectFieldOffset(f_int2_field); + } + + static public void main(String[] args) { + for (int i = 0; i < 20_000; i++) { + byte res = test1(); + if (res != -1) { + throw new RuntimeException("Incorrect result: " + res); + } + res = test2(); + if (res != -1) { + throw new RuntimeException("Incorrect result: " + res); + } + int res2 = test3(); + if (res2 != -1) { + throw new RuntimeException("Incorrect result: " + res2); + } + } + } + + static byte test1() { + MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject(); + return unsafe.getByte(t, f_int_off); + } + + static byte test2() { + MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject(); + return unsafe.getByte(t, f_int_off+1); + } + + static int test3() { + MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject(); + if (f_int_off < f_int2_off) { + return unsafe.getInt(t, f_int_off+1); + } else { + return unsafe.getInt(t, f_int2_off+1); + } + } +} changeset: 9034:29501febee4f tag: fluff tag: qtip tag: tip user: rkennke date: Thu Aug 22 16:47:21 2019 +0200 summary: imported patch fluff diff -r eb4fd8c55b61 -r 29501febee4f test/TEST.groups --- a/test/TEST.groups Fri Jan 11 10:03:00 2019 +0100 +++ b/test/TEST.groups Thu Aug 22 16:47:21 2019 +0200 @@ -128,6 +128,9 @@ hotspot_wbapitest = \ sanity/ +hotspot_mytest = \ + compiler/unsafe/MismatchedUnsafeLoadFromNewObject.java + hotspot_compiler = \ sanity/ExecuteInternalVMTests.java