Path: blob/master/test/hotspot/jtreg/compiler/controldependency/TestAntiDependentMembar.java
41149 views
/*1* Copyright (c) 2019, 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 822877226* @summary Test correct insertion of anti-dependencies if load is already control dependent on membar.27* @run main/othervm -Xbatch -XX:-TieredCompilation28* -XX:CompileCommand=inline,compiler.controldependency.TestAntiDependentMembar::hitSearchLimit29* compiler.controldependency.TestAntiDependentMembar30* @run main/othervm -Xbatch -XX:-TieredCompilation31* -XX:CompileCommand=inline,compiler.controldependency.TestAntiDependentMembar::hitSearchLimit32* -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:DominatorSearchLimit=033* compiler.controldependency.TestAntiDependentMembar34*/3536package compiler.controldependency;3738public class TestAntiDependentMembar {3940static volatile int step1 = 0;41static volatile int step2 = 0;4243public static int test1(int count, int b1, int b2) {44int[] result = {0};4546// Complex control flow to generate Region with 4 paths and therefore bail out of Node::dominates47if (b1 == 0) {48count += 1;49} else if (b1 == 1) {50if (b2 == 1) {51count += 2;52}53}5455for (int i = 0; i < count; ++i) {56// Volatile field write adds a membar57step1 = i;58// Load that is dependent on the membar59result[0] += count;60}61return result[0];62}6364// Same as test1 but bailing out of Node::dominates due to hitting DominatorSearchLimit65public static int test2(int count) {66int[] result = {0};6768// Large method with regions to hit the DominatorSearchLimit69hitSearchLimit();7071for (int i = 0; i < count; ++i) {72step1 = i;73result[0] += count;74}75return result[0];76}7778// Same as test2 but with multiple membars before the load79public static int test3(int count) {80int[] result = {0};8182hitSearchLimit();8384for (int i = 0; i < count; ++i) {85step1 = i;86step2 = i;87step1 = i;88step2 = i;89result[0] += count;90}91return result[0];92}9394public static void main(String[] args) {95for (int i = 0; i < 50_000; ++i) {96test1(10, 0, 0);97test1(10, 1, 1);98test1(10, 1, 0);99test1(10, 0, 1);100test2(10);101test3(10);102}103}104105public static void hitSearchLimit() {106step1++;107step2++;108step1++;109step2++;110step1++;111step2++;112step1++;113step2++;114step1++;115step2++;116step1++;117step2++;118step1++;119step2++;120step1++;121step2++;122step1++;123step2++;124step1++;125step2++;126step1++;127step2++;128step1++;129step2++;130step1++;131step2++;132step1++;133step2++;134step1++;135step2++;136step1++;137step2++;138step1++;139step2++;140step1++;141step2++;142step1++;143step2++;144step1++;145step2++;146step1++;147step2++;148step1++;149step2++;150step1++;151step2++;152step1++;153step2++;154step1++;155step2++;156step1++;157step2++;158step1++;159step2++;160step1++;161step2++;162step1++;163step2++;164step1++;165step2++;166step1++;167step2++;168step1++;169step2++;170step1++;171step2++;172step1++;173step2++;174step1++;175step2++;176step1++;177step2++;178step1++;179step2++;180step1++;181step2++;182step1++;183step2++;184step1++;185step2++;186step1++;187step2++;188step1++;189step2++;190step1++;191step2++;192step1++;193step2++;194step1++;195step2++;196step1++;197step2++;198step1++;199step2++;200step1++;201step2++;202step1++;203step2++;204step1++;205step2++;206step1++;207step2++;208step1++;209step2++;210step1++;211step2++;212step1++;213step2++;214step1++;215step2++;216step1++;217step2++;218step1++;219step2++;220step1++;221step2++;222step1++;223step2++;224step1++;225step2++;226step1++;227step2++;228step1++;229step2++;230step1++;231step2++;232step1++;233step2++;234step1++;235step2++;236step1++;237step2++;238step1++;239step2++;240step1++;241step2++;242step1++;243step2++;244step1++;245step2++;246step1++;247step2++;248step1++;249step2++;250step1++;251step2++;252step1++;253step2++;254step1++;255step2++;256step1++;257step2++;258step1++;259step2++;260step1++;261step2++;262step1++;263step2++;264step1++;265step2++;266step1++;267step2++;268step1++;269step2++;270step1++;271step2++;272step1++;273step2++;274step1++;275step2++;276step1++;277step2++;278step1++;279step2++;280step1++;281step2++;282step1++;283step2++;284step1++;285step2++;286step1++;287step2++;288step1++;289step2++;290step1++;291step2++;292step1++;293step2++;294step1++;295step2++;296step1++;297step2++;298step1++;299step2++;300step1++;301step2++;302step1++;303step2++;304step1++;305step2++;306step1++;307step2++;308step1++;309step2++;310step1++;311step2++;312step1++;313step2++;314step1++;315step2++;316step1++;317step2++;318step1++;319step2++;320step1++;321step2++;322step1++;323step2++;324step1++;325step2++;326step1++;327step2++;328step1++;329step2++;330step1++;331step2++;332step1++;333step2++;334step1++;335step2++;336step1++;337step2++;338step1++;339step2++;340step1++;341step2++;342step1++;343step2++;344step1++;345step2++;346step1++;347step2++;348step1++;349step2++;350step1++;351step2++;352step1++;353step2++;354step1++;355step2++;356step1++;357step2++;358step1++;359step2++;360step1++;361step2++;362step1++;363step2++;364step1++;365step2++;366step1++;367step2++;368step1++;369step2++;370step1++;371step2++;372step1++;373step2++;374step1++;375step2++;376step1++;377step2++;378step1++;379step2++;380step1++;381step2++;382step1++;383step2++;384step1++;385step2++;386step1++;387step2++;388step1++;389step2++;390step1++;391step2++;392step1++;393step2++;394step1++;395step2++;396step1++;397step2++;398step1++;399step2++;400step1++;401step2++;402step1++;403step2++;404step1++;405step2++;406step1++;407step2++;408step1++;409step2++;410step1++;411step2++;412step1++;413step2++;414step1++;415step2++;416step1++;417step2++;418step1++;419step2++;420step1++;421step2++;422step1++;423step2++;424step1++;425step2++;426step1++;427step2++;428step1++;429step2++;430step1++;431step2++;432step1++;433step2++;434step1++;435step2++;436step1++;437step2++;438step1++;439step2++;440step1++;441step2++;442step1++;443step2++;444step1++;445step2++;446step1++;447step2++;448}449}450451452