Skip to content

Commit 2e925f2

Browse files
committed
8329726: Use non-short forward jumps in lightweight locking
Reviewed-by: shade, kvn, aboldtch
1 parent e75e1cb commit 2e925f2

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,15 +1022,18 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Regist
10221022
#ifdef ASSERT
10231023
// Check that locked label is reached with ZF set.
10241024
Label zf_correct;
1025-
jccb(Assembler::zero, zf_correct);
1026-
stop("Fast Lock ZF != 1");
1025+
Label zf_bad_zero;
1026+
jcc(Assembler::zero, zf_correct);
1027+
jmp(zf_bad_zero);
10271028
#endif
10281029

10291030
bind(slow_path);
10301031
#ifdef ASSERT
10311032
// Check that slow_path label is reached with ZF not set.
1032-
jccb(Assembler::notZero, zf_correct);
1033+
jcc(Assembler::notZero, zf_correct);
10331034
stop("Fast Lock ZF != 0");
1035+
bind(zf_bad_zero);
1036+
stop("Fast Lock ZF != 1");
10341037
bind(zf_correct);
10351038
#endif
10361039
// C2 uses the value of ZF to determine the continuation.
@@ -1161,7 +1164,7 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax,
11611164
#ifdef ASSERT
11621165
// Check that unlocked label is reached with ZF set.
11631166
Label zf_correct;
1164-
jccb(Assembler::zero, zf_correct);
1167+
jcc(Assembler::zero, zf_correct);
11651168
stop("Fast Unlock ZF != 1");
11661169
#endif
11671170

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright Amazon.com Inc. 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+
* @summary Tests correct code generation of lightweight locking when using -XX:+ShowMessageBoxOnError; times-out on failure
27+
* @bug 8329726
28+
* @run main/othervm -XX:+ShowMessageBoxOnError -Xcomp -XX:-TieredCompilation -XX:CompileOnly=TestLWLockingCodeGen::sync TestLWLockingCodeGen
29+
*/
30+
public class TestLWLockingCodeGen {
31+
private static int val = 0;
32+
public static void main(String[] args) {
33+
sync();
34+
}
35+
private static synchronized void sync() {
36+
val = val + (int)(Math.random() * 42);
37+
}
38+
}

0 commit comments

Comments
 (0)