Skip to content

Commit

Permalink
Merge branch 'openjdk:master' into goetz_backport_8319104
Browse files Browse the repository at this point in the history
  • Loading branch information
GoeLin authored Nov 14, 2023
2 parents 8a02676 + 81eaed2 commit 94a3d70
Show file tree
Hide file tree
Showing 42 changed files with 648 additions and 212 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ void InterpreterMacroAssembler::remove_activation(
// Check that all monitors are unlocked
{
Label loop, exception, entry, restart;
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();
const Address monitor_block_top(
rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
const Address monitor_block_bot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ void TemplateInterpreterGenerator::generate_stack_overflow_check(void) {

// monitor entry size: see picture of stack set
// (generate_method_entry) and frame_amd64.hpp
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

// total overhead size: entry_size + (saved rbp through expr stack
// bottom). be sure to change this if you add/subtract anything
Expand Down Expand Up @@ -769,7 +769,7 @@ void TemplateInterpreterGenerator::lock_method() {
const Address monitor_block_top(
rfp,
frame::interpreter_frame_monitor_block_top_offset * wordSize);
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

#ifdef ASSERT
{
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3813,7 +3813,7 @@ void TemplateTable::monitorenter()
rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
const Address monitor_block_bot(
rfp, frame::interpreter_frame_initial_sp_offset * wordSize);
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

Label allocated;

Expand Down Expand Up @@ -3916,7 +3916,7 @@ void TemplateTable::monitorexit()
rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
const Address monitor_block_bot(
rfp, frame::interpreter_frame_initial_sp_offset * wordSize);
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

Label found;

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/arm/interp_masm_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ void InterpreterMacroAssembler::remove_activation(TosState state, Register ret_a
{
Label loop;

const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();
const Register Rbottom = R3;
const Register Rcur_obj = Rtemp;

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ void TemplateInterpreterGenerator::generate_stack_overflow_check(void) {
const Register RmaxStack = R2;

// monitor entry size
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

// total overhead size: entry_size + (saved registers, thru expr stack bottom).
// be sure to change this if you add/subtract anything to/from the overhead area
Expand Down Expand Up @@ -569,7 +569,7 @@ void TemplateInterpreterGenerator::generate_stack_overflow_check(void) {
void TemplateInterpreterGenerator::lock_method() {
// synchronize method

const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();
assert ((entry_size % StackAlignmentInBytes) == 0, "should keep stack alignment");

#ifdef ASSERT
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/arm/templateTable_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4270,7 +4270,7 @@ void TemplateTable::monitorenter() {
// check for null object
__ null_check(Robj, Rtemp);

const int entry_size = (frame::interpreter_frame_monitor_size() * wordSize);
const int entry_size = (frame::interpreter_frame_monitor_size_in_bytes());
assert (entry_size % StackAlignmentInBytes == 0, "keep stack alignment");
Label allocate_monitor, allocated;

Expand Down Expand Up @@ -4381,7 +4381,7 @@ void TemplateTable::monitorexit() {
// check for null object
__ null_check(Robj, Rtemp);

const int entry_size = (frame::interpreter_frame_monitor_size() * wordSize);
const int entry_size = (frame::interpreter_frame_monitor_size_in_bytes());
Label found, throw_exception;

// find matching slot
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/cpu/ppc/frame_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@
template <typename RegisterMapT>
static void update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr);

// Size of a monitor in bytes.
static int interpreter_frame_monitor_size_in_bytes();

// The size of a cInterpreter object.
static inline int interpreter_frame_cinterpreterstate_size_in_bytes();

Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/cpu/ppc/frame_ppc.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ inline int frame::interpreter_frame_monitor_size() {
WordsPerLong); // number of stack slots for a Java long
}

inline int frame::interpreter_frame_monitor_size_in_bytes() {
return frame::interpreter_frame_monitor_size() * wordSize;
}

// entry frames

inline intptr_t* frame::entry_frame_argument_at(int offset) const {
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/cpu/ppc/templateTable_ppc_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4146,7 +4146,7 @@ void TemplateTable::monitorenter() {

// Pre-load topmost slot.
__ ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize);
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size_in_bytes());
// The search loop.
__ bind(Lloop);
// Found free slot?
Expand All @@ -4160,7 +4160,7 @@ void TemplateTable::monitorenter() {
__ bgt(reached_limit, Lallocate_new);
// Check if last allocated BasicLockObj reached.
__ ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize);
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size_in_bytes());
// Next iteration if unchecked BasicObjectLocks exist on the stack.
__ b(Lloop);
}
Expand All @@ -4169,8 +4169,8 @@ void TemplateTable::monitorenter() {
// Check if we found a free slot.
__ bind(Lexit);

__ addi(Rcurrent_monitor, Rcurrent_obj_addr, -(frame::interpreter_frame_monitor_size() * wordSize) - in_bytes(BasicObjectLock::obj_offset()));
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, - frame::interpreter_frame_monitor_size() * wordSize);
__ addi(Rcurrent_monitor, Rcurrent_obj_addr, -(frame::interpreter_frame_monitor_size_in_bytes()) - in_bytes(BasicObjectLock::obj_offset()));
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, - frame::interpreter_frame_monitor_size_in_bytes());
__ b(Lfound);

// We didn't find a free BasicObjLock => allocate one.
Expand Down Expand Up @@ -4228,7 +4228,7 @@ void TemplateTable::monitorexit() {
__ addi(Rcurrent_obj_addr, R26_monitor, in_bytes(BasicObjectLock::obj_offset()));
__ addi(Rlimit, Rlimit, in_bytes(BasicObjectLock::obj_offset()));
__ ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize);
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size_in_bytes());

__ bind(Lloop);
// Is this entry for same obj?
Expand All @@ -4239,7 +4239,7 @@ void TemplateTable::monitorexit() {

__ ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
__ cmpld(CCR0, Rcurrent_obj_addr, Rlimit);
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize);
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size_in_bytes());

// Next iteration if unchecked BasicObjectLocks exist on the stack.
__ ble(CCR0, Lloop);
Expand All @@ -4253,7 +4253,7 @@ void TemplateTable::monitorexit() {
__ align(32, 12);
__ bind(Lfound);
__ addi(Rcurrent_monitor, Rcurrent_obj_addr,
-(frame::interpreter_frame_monitor_size() * wordSize) - in_bytes(BasicObjectLock::obj_offset()));
-(frame::interpreter_frame_monitor_size_in_bytes()) - in_bytes(BasicObjectLock::obj_offset()));
__ unlock_object(Rcurrent_monitor);
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/interp_masm_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ void InterpreterMacroAssembler::remove_activation(
// Check that all monitors are unlocked
{
Label loop, exception, entry, restart;
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();
const Address monitor_block_top(
fp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
const Address monitor_block_bot(
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ void TemplateInterpreterGenerator::generate_stack_overflow_check(void) {

// monitor entry size: see picture of stack set
// (generate_method_entry) and frame_amd64.hpp
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

// total overhead size: entry_size + (saved fp through expr stack
// bottom). be sure to change this if you add/subtract anything
Expand Down Expand Up @@ -673,7 +673,7 @@ void TemplateInterpreterGenerator::lock_method() {
// synchronize method
const Address access_flags(xmethod, Method::access_flags_offset());
const Address monitor_block_top(fp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

#ifdef ASSERT
__ lwu(x10, access_flags);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/riscv/templateTable_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3739,7 +3739,7 @@ void TemplateTable::monitorenter() {
fp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
const Address monitor_block_bot(
fp, frame::interpreter_frame_initial_sp_offset * wordSize);
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

Label allocated;

Expand Down Expand Up @@ -3837,7 +3837,7 @@ void TemplateTable::monitorexit() {
fp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
const Address monitor_block_bot(
fp, frame::interpreter_frame_initial_sp_offset * wordSize);
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();

Label found;

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox
assert(LockingMode != LM_MONITOR, "LM_MONITOR is already handled, by emit_lock()");

if (LockingMode == LM_LIGHTWEIGHT) {
fast_lock(Roop, Rmark, tmp, slow_case);
lightweight_lock(Roop, Rmark, tmp, slow_case);
} else if (LockingMode == LM_LEGACY) {
NearLabel done;
// and mark it as unlocked.
Expand Down Expand Up @@ -171,7 +171,7 @@ void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rb
z_lgr(tmp, Rmark);
z_nill(tmp, markWord::monitor_value);
z_brnz(slow_case);
fast_unlock(Roop, Rmark, tmp, slow_case);
lightweight_unlock(Roop, Rmark, tmp, 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 Down
5 changes: 0 additions & 5 deletions src/hotspot/cpu/s390/frame_s390.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,6 @@
template <typename RegisterMapT>
static void update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr);

// Additional interface for interpreter frames:
static int interpreter_frame_interpreterstate_size_in_bytes();
static int interpreter_frame_monitor_size_in_bytes();


// template interpreter state
inline z_ijava_state* ijava_state_unchecked() const;

Expand Down
9 changes: 0 additions & 9 deletions src/hotspot/cpu/s390/frame_s390.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,6 @@ inline int frame::interpreter_frame_monitor_size() {
WordsPerLong /* Number of stack slots for a Java long. */);
}

inline int frame::interpreter_frame_monitor_size_in_bytes() {
// Number of bytes for a monitor.
return frame::interpreter_frame_monitor_size() * wordSize;
}

inline int frame::interpreter_frame_interpreterstate_size_in_bytes() {
return z_ijava_state_size;
}

inline Method** frame::interpreter_frame_method_addr() const {
return (Method**)&(ijava_state()->method);
}
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/cpu/s390/interp_masm_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ void InterpreterMacroAssembler::unlock_if_synchronized_method(TosState state,
// Check that all monitors are unlocked.
{
NearLabel loop, exception, entry, restart;
const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
const int entry_size = frame::interpreter_frame_monitor_size_in_bytes();
// We use Z_ARG2 so that if we go slow path it will be the correct
// register for unlock_object to pass to VM directly.
Register R_current_monitor = Z_ARG2;
Expand Down Expand Up @@ -1028,7 +1028,7 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {
}

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

// Set header to be (markWord of object | UNLOCK_VALUE).
Expand Down Expand Up @@ -1086,7 +1086,7 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {
// slow case of monitor enter.
bind(slow_case);
if (LockingMode == LM_LIGHTWEIGHT) {
// for fast locking we need to use monitorenter_obj, see interpreterRuntime.cpp
// for lightweight locking we need to use monitorenter_obj, see interpreterRuntime.cpp
call_VM(noreg,
CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter_obj),
object);
Expand Down Expand Up @@ -1185,7 +1185,7 @@ void InterpreterMacroAssembler::unlock_object(Register monitor, Register object)
z_nill(tmp, markWord::monitor_value);
z_brne(slow_case);

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

z_bru(done);
} else {
Expand Down Expand Up @@ -2087,7 +2087,7 @@ void InterpreterMacroAssembler::add_monitor_to_stack(bool stack_is_empty,

const Register Rcurr_slot = Rtemp1;
const Register Rlimit = Rtemp2;
const jint delta = -frame::interpreter_frame_monitor_size() * wordSize;
const jint delta = -frame::interpreter_frame_monitor_size_in_bytes();

assert((delta & LongAlignmentMask) == 0,
"sizeof BasicObjectLock must be even number of doublewords");
Expand Down
18 changes: 9 additions & 9 deletions src/hotspot/cpu/s390/macroAssembler_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3204,7 +3204,7 @@ void MacroAssembler::compiler_fast_lock_object(Register oop, Register box, Regis
z_bru(done);
} else {
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
fast_lock(oop, displacedHeader, temp, done);
lightweight_lock(oop, displacedHeader, temp, done);
z_bru(done);
}

Expand Down Expand Up @@ -3284,7 +3284,7 @@ void MacroAssembler::compiler_fast_unlock_object(Register oop, Register box, Reg
// don't load currentHead again from stack-top after monitor check, as it is possible
// some other thread modified it.
// currentHeader is altered, but it's contents are copied in temp as well
fast_unlock(oop, temp, currentHeader, done);
lightweight_unlock(oop, temp, currentHeader, done);
z_bru(done);
}

Expand Down Expand Up @@ -5644,14 +5644,14 @@ SkipIfEqual::~SkipIfEqual() {
_masm->bind(_label);
}

// Implements fast-locking.
// Implements lightweight-locking.
// Branches to slow upon failure to lock the object.
// Falls through upon success.
//
// - obj: the object to be locked, contents preserved.
// - hdr: the header, already loaded from obj, contents destroyed.
// Note: make sure Z_R1 is not manipulated here when C2 compiler is in play
void MacroAssembler::fast_lock(Register obj, Register hdr, Register temp, Label& slow_case) {
void MacroAssembler::lightweight_lock(Register obj, Register hdr, Register temp, Label& slow_case) {

assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking");
assert_different_registers(obj, hdr, temp);
Expand All @@ -5661,7 +5661,7 @@ void MacroAssembler::fast_lock(Register obj, Register hdr, Register temp, Label&

compareU32_and_branch(temp, (unsigned)LockStack::end_offset()-1, bcondHigh, slow_case);

// attempting a fast_lock
// attempting a lightweight_lock
// Load (object->mark() | 1) into hdr
z_oill(hdr, markWord::unlocked_value);

Expand All @@ -5683,26 +5683,26 @@ void MacroAssembler::fast_lock(Register obj, Register hdr, Register temp, Label&
z_cr(temp, temp);
}

// Implements fast-unlocking.
// Implements lightweight-unlocking.
// Branches to slow upon failure.
// Falls through upon success.
//
// - obj: the object to be unlocked
// - hdr: the (pre-loaded) header of the object, will be destroyed
// - Z_R1_scratch: will be killed in case of Interpreter & C1 Compiler
void MacroAssembler::fast_unlock(Register obj, Register hdr, Register tmp, Label& slow) {
void MacroAssembler::lightweight_unlock(Register obj, Register hdr, Register tmp, Label& slow) {

assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking");
assert_different_registers(obj, hdr, tmp);

#ifdef ASSERT
{
// Check that hdr is fast-locked.
// Check that hdr is lightweight-locked.
Label hdr_ok;
z_lgr(tmp, hdr);
z_nill(tmp, markWord::lock_mask_in_place);
z_bre(hdr_ok);
stop("Header is not fast-locked");
stop("Header is not lightweight-locked");
bind(hdr_ok);
}
{
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/s390/macroAssembler_s390.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,8 @@ class MacroAssembler: public Assembler {

void compiler_fast_lock_object(Register oop, Register box, Register temp1, Register temp2);
void compiler_fast_unlock_object(Register oop, Register box, Register temp1, Register temp2);
void fast_lock(Register obj, Register hdr, Register tmp, Label& slow);
void fast_unlock(Register obj, Register hdr, Register tmp, Label& slow);
void lightweight_lock(Register obj, Register hdr, Register tmp, Label& slow);
void lightweight_unlock(Register obj, Register hdr, Register tmp, Label& slow);

void resolve_jobject(Register value, Register tmp1, Register tmp2);

Expand Down
Loading

0 comments on commit 94a3d70

Please sign in to comment.