Skip to content

Commit d457609

Browse files
committed
8319947: Recursive lightweight locking: s390x implementation
Reviewed-by: aboldtch, lucy
1 parent c47a0e0 commit d457609

File tree

9 files changed

+489
-127
lines changed

9 files changed

+489
-127
lines changed

src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox
6767

6868
verify_oop(Roop, FILE_AND_LINE);
6969

70-
// Load object header.
71-
z_lg(Rmark, Address(Roop, hdr_offset));
72-
7370
// Save object being locked into the BasicObjectLock...
7471
z_stg(Roop, Address(Rbox, BasicObjectLock::obj_offset()));
7572

@@ -85,6 +82,10 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox
8582
lightweight_lock(Roop, Rmark, tmp, slow_case);
8683
} else if (LockingMode == LM_LEGACY) {
8784
NearLabel done;
85+
86+
// Load object header.
87+
z_lg(Rmark, Address(Roop, hdr_offset));
88+
8889
// and mark it as unlocked.
8990
z_oill(Rmark, markWord::unlocked_value);
9091
// Save unlocked object header into the displaced header location on the stack.
@@ -141,12 +142,7 @@ void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rb
141142
verify_oop(Roop, FILE_AND_LINE);
142143

143144
if (LockingMode == LM_LIGHTWEIGHT) {
144-
const Register tmp = Z_R1_scratch;
145-
z_lg(Rmark, Address(Roop, hdr_offset));
146-
z_lgr(tmp, Rmark);
147-
z_nill(tmp, markWord::monitor_value);
148-
branch_optimized(Assembler::bcondNotZero, slow_case);
149-
lightweight_unlock(Roop, Rmark, tmp, slow_case);
145+
lightweight_unlock(Roop, Rmark, Z_R1_scratch, slow_case);
150146
} else if (LockingMode == LM_LEGACY) {
151147
// Test if object header is pointing to the displaced header, and if so, restore
152148
// the displaced header in the object. If the object header is not pointing to

src/hotspot/cpu/s390/c2_MacroAssembler_s390.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2017, 2022 SAP SE. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2017, 2024 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,15 @@
3333
#define BLOCK_COMMENT(str) block_comment(str)
3434
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
3535

36+
void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Register temp1, Register temp2) {
37+
compiler_fast_lock_lightweight_object(obj, temp1, temp2);
38+
}
39+
40+
41+
void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, Register temp1, Register temp2) {
42+
compiler_fast_unlock_lightweight_object(obj, temp1, temp2);
43+
}
44+
3645
//------------------------------------------------------
3746
// Special String Intrinsics. Implementation
3847
//------------------------------------------------------

src/hotspot/cpu/s390/c2_MacroAssembler_s390.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2017, 2022 SAP SE. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2017, 2024 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,10 @@
2929
// C2_MacroAssembler contains high-level macros for C2
3030

3131
public:
32+
// Code used by cmpFastLockLightweight and cmpFastUnlockLightweight mach instructions in s390.ad file.
33+
void fast_lock_lightweight(Register obj, Register box, Register temp1, Register temp2);
34+
void fast_unlock_lightweight(Register obj, Register box, Register temp1, Register temp2);
35+
3236
//-------------------------------------------
3337
// Special String Intrinsics Implementation.
3438
//-------------------------------------------

src/hotspot/cpu/s390/interp_masm_s390.cpp

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,19 +1005,19 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {
10051005

10061006
// markWord header = obj->mark().set_unlocked();
10071007

1008-
// Load markWord from object into header.
1009-
z_lg(header, hdr_offset, object);
1010-
10111008
if (DiagnoseSyncOnValueBasedClasses != 0) {
10121009
load_klass(tmp, object);
10131010
testbit(Address(tmp, Klass::access_flags_offset()), exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
10141011
z_btrue(slow_case);
10151012
}
10161013

10171014
if (LockingMode == LM_LIGHTWEIGHT) {
1018-
lightweight_lock(object, /* mark word */ header, tmp, slow_case);
1015+
lightweight_lock(object, header, tmp, slow_case);
10191016
} else if (LockingMode == LM_LEGACY) {
10201017

1018+
// Load markWord from object into header.
1019+
z_lg(header, hdr_offset, object);
1020+
10211021
// Set header to be (markWord of object | UNLOCK_VALUE).
10221022
// This will not change anything if it was unlocked before.
10231023
z_oill(header, markWord::unlocked_value);
@@ -1153,26 +1153,8 @@ void InterpreterMacroAssembler::unlock_object(Register monitor, Register object)
11531153

11541154
// If we still have a lightweight lock, unlock the object and be done.
11551155
if (LockingMode == LM_LIGHTWEIGHT) {
1156-
// Check for non-symmetric locking. This is allowed by the spec and the interpreter
1157-
// must handle it.
1158-
1159-
Register tmp = current_header;
1160-
1161-
// First check for lock-stack underflow.
1162-
z_lgf(tmp, Address(Z_thread, JavaThread::lock_stack_top_offset()));
1163-
compareU32_and_branch(tmp, (unsigned)LockStack::start_offset(), Assembler::bcondNotHigh, slow_case);
1164-
1165-
// Then check if the top of the lock-stack matches the unlocked object.
1166-
z_aghi(tmp, -oopSize);
1167-
z_lg(tmp, Address(Z_thread, tmp));
1168-
compare64_and_branch(tmp, object, Assembler::bcondNotEqual, slow_case);
1169-
1170-
z_lg(header, Address(object, hdr_offset));
1171-
z_lgr(tmp, header);
1172-
z_nill(tmp, markWord::monitor_value);
1173-
z_brne(slow_case);
11741156

1175-
lightweight_unlock(object, header, tmp, slow_case);
1157+
lightweight_unlock(object, header, current_header, slow_case);
11761158

11771159
z_bru(done);
11781160
} else {

0 commit comments

Comments
 (0)