1 /*
2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3  * Copyright (c) 2019 SAP SE. All rights reserved.
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 only, as
8  * published by the Free Software Foundation.
9  *
10  * This code is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * version 2 for more details (a copy is included in the LICENSE file that
14  * accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License version
17  * 2 along with this work; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21  * or visit www.oracle.com if you need additional information or have any
22  * questions.
23  */
24 
25 /**
26  * @test
27  * @bug 8217990
28  * @summary With -XX:+UseOptoBiasInlining loading the markword is replaced by 0L if EliminateLocks is disabled. assert(dmw->is_neutral()) failed: invariant fails.
29  * @author Richard Reingruber richard DOT reingruber AT sap DOT com
30  *
31  * @library /test/lib /test/hotspot/jtreg
32  *
33  * @build sun.hotspot.WhiteBox
34  * @build ClassFileInstaller
35  *
36  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
37  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
38  *
39  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
40  *                   -XX:CompileCommand=compileonly,*.TestUseOptoBiasInliningWithoutEliminateLocks::dontinline_testMethod
41  *                   -XX:CompileCommand=dontinline,*::dontinline_*
42  *                   -XX:-EliminateLocks
43  *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
44  *                   -Xbatch
45  *                   -XX:-TieredCompilation
46  *                   compiler.c2.TestUseOptoBiasInliningWithoutEliminateLocks
47  */
48 
49 package compiler.c2;
50 
51 import sun.hotspot.WhiteBox;
52 
53 public class TestUseOptoBiasInliningWithoutEliminateLocks {
54 
55     public static final WhiteBox WB = WhiteBox.getWhiteBox();
56 
main(String[] args)57     public static void main(String[] args) {
58         new TestUseOptoBiasInliningWithoutEliminateLocks().run();
59     }
60 
61     public boolean warmupDone;
62 
run()63     public void run() {
64         for(int i = 0; i < 30000; i++) {
65             dontinline_testMethod();
66         }
67         warmupDone = true;
68         dontinline_testMethod();
69     }
70 
dontinline_testMethod()71     public void dontinline_testMethod() {
72         PointXY l1 = new PointXY(4.0f, 2.0f);
73         synchronized (l1) {
74             dontinline_deopt();
75         }
76     }
77 
dontinline_deopt()78     public void dontinline_deopt() {
79         if (warmupDone) {
80             WB.deoptimizeFrames(false);
81         }
82     }
83 
84     static class PointXY {
85 
86         public float fritz;
87         public float felix;
88 
PointXY(float fritz_param, float felix_param)89         public PointXY(float fritz_param, float felix_param) {
90             this.fritz = fritz_param;
91 //            this.felix = felix_param;
92         }
93     }
94 }
95