Path: blob/master/test/hotspot/jtreg/gc/shenandoah/compiler/TestLoadPinnedAfterCall.java
41153 views
/*1* Copyright (c) 2020, Red Hat, Inc. 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 825152726* @summary CTW: C2 (Shenandoah) compilation fails with SEGV due to unhandled catchproj == NUL27* @requires vm.flavor == "server"28* @requires vm.gc.Shenandoah29*30* @run main/othervm -XX:+UseShenandoahGC -XX:CompileOnly=TestLoadPinnedAfterCall.test -XX:CompileCommand=dontinline,TestLoadPinnedAfterCall.not_inlined -XX:-TieredCompilation -XX:-BackgroundCompilation TestLoadPinnedAfterCall31*32*/3334public class TestLoadPinnedAfterCall {35private A staticField1;36private static Object staticField2 = new Object();37private static volatile int staticField3;38private static int staticField4;39static TestLoadPinnedAfterCall object = new TestLoadPinnedAfterCall();4041public static void main(String[] args) {42final A a = new A();43try {44throw new Exception();45} catch (Exception ex) {46}47for (int i = 0; i < 20_000; i++) {48inlined(0, 0, 0);49inlined(2, 0, 0);50inlined(2, 2, 2);5152object.staticField1 = new A();53test(true, a, a, false, 2, 2);54test(false, a, a, true, 2, 2);55test(false, a, a, false, 2, 2);56object.staticField1 = a;57test(true, a, a, false, 2, 2);58test(false, a, a, true, 2, 2);59test(false, a, a, false, 2, 2);60}61}6263private static void test(boolean flag, A a, A a2, boolean flag2, int i1, int i2) {6465int ii = 1;66for (; ii < 2; ii *= 2) {6768}69ii = ii / 2;7071i1 = 0;72for (; i1 < 2; i1 += ii) {73for (int i = 0; i < 2; i += ii) {7475}76}7778i2 = 0;79for (; i2 < 2; i2 += ii) {80for (int i = 0; i < 2; i += ii) {81for (int j = 0; j < 2; j += ii) {8283}8485}86}8788TestLoadPinnedAfterCall obj = object;89if (obj == null) {90}91counter = 10;92for (;;) {93synchronized (staticField2) {94}95int i = 0;96for (; i < 2; i += ii) {9798}99100inlined(i, i1, i2);101102if (flag) {103staticField3 = 0x42;104break;105}106try {107not_inlined();108if (flag2) {109break;110}111} catch (Throwable throwable) {112if (a == obj.staticField1) {113staticField4 = 0x42;114}115break;116}117}118if (a2 == obj.staticField1) {119staticField4 = 0x42;120}121}122123private static void inlined(int i, int j, int k) {124if (i == 2) {125if (j == 2) {126staticField3 = 0x42;127}128if (k == 2) {129staticField3 = 0x42;130}131}132}133134static int counter = 0;135private static void not_inlined() {136counter--;137if (counter <= 0) {138throw new RuntimeException();139}140}141142private static class A {143}144}145146147