Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Dec 5, 2024
2 parents 6e68ee1 + 9101cc1 commit f04150d
Show file tree
Hide file tree
Showing 12 changed files with 500 additions and 131 deletions.
6 changes: 5 additions & 1 deletion src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ int LIR_Assembler::emit_unwind_handler() {
LIR_Opr lock = FrameMap::as_opr(Z_R1_scratch);
monitor_address(0, lock);
stub = new MonitorExitStub(lock, true, 0);
__ unlock_object(Rtmp1, Rtmp2, lock->as_register(), *stub->entry());
if (LockingMode == LM_MONITOR) {
__ branch_optimized(Assembler::bcondAlways, *stub->entry());
} else {
__ unlock_object(Rtmp1, Rtmp2, lock->as_register(), *stub->entry());
}
__ bind(*stub->continuation());
}

Expand Down
18 changes: 9 additions & 9 deletions src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox

verify_oop(Roop, FILE_AND_LINE);

// Load object header.
z_lg(Rmark, Address(Roop, hdr_offset));

// Save object being locked into the BasicObjectLock...
z_stg(Roop, Address(Rbox, BasicObjectLock::obj_offset()));

Expand All @@ -85,6 +82,10 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox
lightweight_lock(Roop, Rmark, tmp, slow_case);
} else if (LockingMode == LM_LEGACY) {
NearLabel done;

// Load object header.
z_lg(Rmark, Address(Roop, hdr_offset));

// and mark it as unlocked.
z_oill(Rmark, markWord::unlocked_value);
// Save unlocked object header into the displaced header location on the stack.
Expand Down Expand Up @@ -119,6 +120,8 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox
branch_optimized(Assembler::bcondNotZero, slow_case);
// done
bind(done);
} else {
assert(false, "Unhandled LockingMode:%d", LockingMode);
}
}

Expand All @@ -141,12 +144,7 @@ void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rb
verify_oop(Roop, FILE_AND_LINE);

if (LockingMode == LM_LIGHTWEIGHT) {
const Register tmp = Z_R1_scratch;
z_lg(Rmark, Address(Roop, hdr_offset));
z_lgr(tmp, Rmark);
z_nill(tmp, markWord::monitor_value);
branch_optimized(Assembler::bcondNotZero, slow_case);
lightweight_unlock(Roop, Rmark, tmp, slow_case);
lightweight_unlock(Roop, Rmark, Z_R1_scratch, slow_case);
} else if (LockingMode == LM_LEGACY) {
// Test if object header is pointing to the displaced header, and if so, restore
// the displaced header in the object. If the object header is not pointing to
Expand All @@ -155,6 +153,8 @@ void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rb
// If the object header was not pointing to the displaced header,
// we do unlocking via runtime call.
branch_optimized(Assembler::bcondNotEqual, slow_case);
} else {
assert(false, "Unhandled LockingMode:%d", LockingMode);
}
// done
bind(done);
Expand Down
13 changes: 11 additions & 2 deletions src/hotspot/cpu/s390/c2_MacroAssembler_s390.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022 SAP SE. All rights reserved.
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,6 +33,15 @@
#define BLOCK_COMMENT(str) block_comment(str)
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")

void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Register temp1, Register temp2) {
compiler_fast_lock_lightweight_object(obj, temp1, temp2);
}


void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, Register temp1, Register temp2) {
compiler_fast_unlock_lightweight_object(obj, temp1, temp2);
}

//------------------------------------------------------
// Special String Intrinsics. Implementation
//------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions src/hotspot/cpu/s390/c2_MacroAssembler_s390.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022 SAP SE. All rights reserved.
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,6 +29,10 @@
// C2_MacroAssembler contains high-level macros for C2

public:
// Code used by cmpFastLockLightweight and cmpFastUnlockLightweight mach instructions in s390.ad file.
void fast_lock_lightweight(Register obj, Register box, Register temp1, Register temp2);
void fast_unlock_lightweight(Register obj, Register box, Register temp1, Register temp2);

//-------------------------------------------
// Special String Intrinsics Implementation.
//-------------------------------------------
Expand Down
28 changes: 5 additions & 23 deletions src/hotspot/cpu/s390/interp_masm_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,19 +1005,19 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {

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

// Load markWord from object into header.
z_lg(header, hdr_offset, object);

if (DiagnoseSyncOnValueBasedClasses != 0) {
load_klass(tmp, object);
testbit(Address(tmp, Klass::access_flags_offset()), exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
z_btrue(slow_case);
}

if (LockingMode == LM_LIGHTWEIGHT) {
lightweight_lock(object, /* mark word */ header, tmp, slow_case);
lightweight_lock(object, header, tmp, slow_case);
} else if (LockingMode == LM_LEGACY) {

// Load markWord from object into header.
z_lg(header, hdr_offset, object);

// Set header to be (markWord of object | UNLOCK_VALUE).
// This will not change anything if it was unlocked before.
z_oill(header, markWord::unlocked_value);
Expand Down Expand Up @@ -1153,26 +1153,8 @@ void InterpreterMacroAssembler::unlock_object(Register monitor, Register object)

// If we still have a lightweight lock, unlock the object and be done.
if (LockingMode == LM_LIGHTWEIGHT) {
// Check for non-symmetric locking. This is allowed by the spec and the interpreter
// must handle it.

Register tmp = current_header;

// First check for lock-stack underflow.
z_lgf(tmp, Address(Z_thread, JavaThread::lock_stack_top_offset()));
compareU32_and_branch(tmp, (unsigned)LockStack::start_offset(), Assembler::bcondNotHigh, slow_case);

// Then check if the top of the lock-stack matches the unlocked object.
z_aghi(tmp, -oopSize);
z_lg(tmp, Address(Z_thread, tmp));
compare64_and_branch(tmp, object, Assembler::bcondNotEqual, slow_case);

z_lg(header, Address(object, hdr_offset));
z_lgr(tmp, header);
z_nill(tmp, markWord::monitor_value);
z_brne(slow_case);

lightweight_unlock(object, header, tmp, slow_case);
lightweight_unlock(object, header, current_header, slow_case);

z_bru(done);
} else {
Expand Down
Loading

0 comments on commit f04150d

Please sign in to comment.