1 /*
 2  * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 8329757
27  * @summary Deoptimization with nested eliminated and not eliminated locks
28  *          caused reordered lock stacks. This can be handled by the interpreter
29  *          but when a frame is migrated back to compiled code via OSR the C2
30  *          assumption about balanced monitorenter-monitorexit is broken.
31  *
32  * @requires vm.compMode != "Xint"
33  *
34  * @run main/othervm compiler.escapeAnalysis.Test8329757
35  */
36 
37 package compiler.escapeAnalysis;
38 
39 public class Test8329757 {
40 
41     int a = 400;
42     Double ddd;
43 
44     void q() {
45         int e;
46         synchronized (new Double(1.1f)) {
47         int[] f = new int[a];
48         synchronized (Test8329757.class) {
49             for (int d = 4; d < 127; d++) {
50             e = 13;
51             do switch (d * 5) {
52                 case 0:
53                 case 42:
54                 case 29:
55                 e = d;
56                 default:
57                 f[1] = e;
58             } while (--e > 0);
59             }
60         }
61         }
62     }
63 
64     void n() {
65         for (int j = 6; j < 274; ++j) q();
66     }
67 
68     public static void main(String[] args) {
69         Test8329757 r = new Test8329757();
70         for (int i = 0; i < 1000; i++) r.n();
71     }
72 }