Path: blob/master/test/hotspot/jtreg/compiler/c1/TestValueNumberingNullObject.java
41152 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 823789426* @summary CTW: C1 compilation fails with assert(x->type()->tag() == f->type()->tag()) failed: should have same type27*28* @run main/othervm29* -Xcomp -Xbatch -XX:CompileCommand=compileonly,compiler.c1.T*::*30* -XX:CompileCommand=exclude,compiler.c1.TestValueNumberingNullObject::main31* -XX:CompileCommand=inline,*.*32* -XX:TieredStopAtLevel=333* compiler.c1.TestValueNumberingNullObject34*/3536package compiler.c1;3738class T1 {3940public T2 f1;4142public int za() {43return 0;44}4546public int zb() {47return 0;48}4950public int zc() {51return 0;52}5354public int zd() {55return 0;56}5758public int ze() {59return 0;60}6162public int zf() {63return 0;64}6566public int zg() {67return 0;68}6970public int zh() {71return 0;72}73}7475class T2 {7677public T1 f1;7879public int zh() {80return 0;81}82}8384public class TestValueNumberingNullObject {8586public static void main(String args[]) {87new T1(); // Load88new T2(); // Load89try {90// case 191// Null based field access.92// Value Numbering null based field access causes instructions to be eliminated across type/subtypes.93// declared type of these instructions are field type, so it being receiver causes problems to Type System.94// to mitigate this issue, we hash declared type in addition to existing hashing.95testFieldAccess();96} catch (Exception e) {97}98try {99// case 2100// Null based indexed access.101// Value Numbering null based indexed access causes instructions to be eliminated across type/subtypes.102// element basic type in encoded in the access instruction, this causes problems to Type system.103// declared type of these instructions are null, so it being receiver doesn't cause any problem to Type System.104// to mitigate this issue, we hash basic type in addition to existing hashing105basicTypeAccess();106} catch (Exception e) {107}108}109110static long testFieldAccess() {111T1 t1 = null;112T2 t2 = null;113T1[] t3 = null;114T2[] t4 = null;115116long value = t1.f1.zh() + t2.f1.zh();117// null array object based field access.118value += t3[2].f1.zh() + t4[2].f1.zh();119return value;120}121122static long basicTypeAccess() {123long[] f1 = null;124int[] f2 = null;125T2[] t2 = null;126T1[] t1 = null;127return f1[5] + f2[5] + t2[5].zh() + t1[5].zh();128}129}130131132133