Skip to content

Commit afca07b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into 8330954
2 parents 91df97f + c798316 commit afca07b

File tree

130 files changed

+3773
-1244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+3773
-1244
lines changed

make/autoconf/jdk-options.m4

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
197197
# three different page sizes: 4K, 64K, and if run on Mac m1 hardware, 16K.
198198
COMPATIBLE_CDS_ALIGNMENT_DEFAULT=false
199199
if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
200-
COMPATIBLE_CDS_ALIGNMENT_DEFAULT=true
200+
COMPATIBLE_CDS_ALIGNMENT_DEFAULT=auto
201201
fi
202-
AC_SUBST(COMPATIBLE_CDS_ALIGNMENT_DEFAULT)
203202
204203
# Compress jars
205204
COMPRESS_JARS=false
@@ -438,12 +437,23 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
438437
# It's harmless to be suppressed in clang as well.
439438
ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
440439
ASAN_LDFLAGS="-fsanitize=address"
440+
# detect_stack_use_after_return causes ASAN to offload stack-local
441+
# variables to c-heap and therefore breaks assumptions in hotspot
442+
# that rely on data (e.g. Marks) living in thread stacks.
443+
if test "x$TOOLCHAIN_TYPE" = "xgcc"; then
444+
ASAN_CFLAGS="$ASAN_CFLAGS --param asan-use-after-return=0"
445+
fi
446+
if test "x$TOOLCHAIN_TYPE" = "xclang"; then
447+
ASAN_CFLAGS="$ASAN_CFLAGS -fsanitize-address-use-after-return=never"
448+
fi
441449
elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
442450
# -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang.
443451
ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER"
444452
# MSVC produces a warning if you pass -fsanitize=address to the linker. It also complains
445453
$ if -DEBUG is not passed to the linker when building with ASan.
446454
ASAN_LDFLAGS="-debug"
455+
# -fsanitize-address-use-after-return is off by default in MS Visual Studio 22 (19.37.32824).
456+
# cl : Command line warning D9002 : ignoring unknown option '-fno-sanitize-address-use-after-return'
447457
fi
448458
JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
449459
JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
@@ -496,9 +506,15 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER],
496506
#
497507
AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER],
498508
[
509+
UTIL_ARG_WITH(NAME: additional-ubsan-checks, TYPE: string,
510+
DEFAULT: [],
511+
DESC: [Customizes the ubsan checks],
512+
OPTIONAL: true)
513+
499514
# GCC reports lots of likely false positives for stringop-truncation and format-overflow.
500515
# Silence them for now.
501-
UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment"
516+
UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment \
517+
$ADDITIONAL_UBSAN_CHECKS"
502518
UBSAN_CFLAGS="$UBSAN_CHECKS -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER"
503519
UBSAN_LDFLAGS="$UBSAN_CHECKS"
504520
UTIL_ARG_ENABLE(NAME: ubsan, DEFAULT: false, RESULT: UBSAN_ENABLED,
@@ -666,7 +682,7 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT],
666682
UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: $COMPATIBLE_CDS_ALIGNMENT_DEFAULT,
667683
RESULT: ENABLE_COMPATIBLE_CDS_ALIGNMENT,
668684
DESC: [enable use alternative compatible cds core region alignment],
669-
DEFAULT_DESC: [disabled],
685+
DEFAULT_DESC: [disabled except on linux-aarch64],
670686
CHECKING_MSG: [if compatible cds region alignment enabled],
671687
CHECK_AVAILABLE: [
672688
AC_MSG_CHECKING([if CDS archive is available])

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3799,7 +3799,7 @@ void MacroAssembler::lookup_secondary_supers_table_slow_path(Register r_super_kl
37993799

38003800
// Check for wraparound.
38013801
Label skip;
3802-
bge(r_array_length, r_array_index, skip);
3802+
blt(r_array_index, r_array_length, skip);
38033803
mv(r_array_index, zr);
38043804
bind(skip);
38053805

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)