Skip to content

Commit

Permalink
Merge jdk-24+5 into rivos/main (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
luhenry authored Jul 8, 2024
2 parents d7ea3b2 + c5df300 commit 5a279bd
Show file tree
Hide file tree
Showing 308 changed files with 6,573 additions and 2,408 deletions.
16 changes: 13 additions & 3 deletions make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
# three different page sizes: 4K, 64K, and if run on Mac m1 hardware, 16K.
COMPATIBLE_CDS_ALIGNMENT_DEFAULT=false
if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
COMPATIBLE_CDS_ALIGNMENT_DEFAULT=true
COMPATIBLE_CDS_ALIGNMENT_DEFAULT=auto
fi
AC_SUBST(COMPATIBLE_CDS_ALIGNMENT_DEFAULT)
# Compress jars
COMPRESS_JARS=false
Expand Down Expand Up @@ -438,12 +437,23 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
# It's harmless to be suppressed in clang as well.
ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
ASAN_LDFLAGS="-fsanitize=address"
# detect_stack_use_after_return causes ASAN to offload stack-local
# variables to c-heap and therefore breaks assumptions in hotspot
# that rely on data (e.g. Marks) living in thread stacks.
if test "x$TOOLCHAIN_TYPE" = "xgcc"; then
ASAN_CFLAGS="$ASAN_CFLAGS --param asan-use-after-return=0"
fi
if test "x$TOOLCHAIN_TYPE" = "xclang"; then
ASAN_CFLAGS="$ASAN_CFLAGS -fsanitize-address-use-after-return=never"
fi
elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
# -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang.
ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER"
# MSVC produces a warning if you pass -fsanitize=address to the linker. It also complains
$ if -DEBUG is not passed to the linker when building with ASan.
ASAN_LDFLAGS="-debug"
# -fsanitize-address-use-after-return is off by default in MS Visual Studio 22 (19.37.32824).
# cl : Command line warning D9002 : ignoring unknown option '-fno-sanitize-address-use-after-return'
fi
JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
Expand Down Expand Up @@ -672,7 +682,7 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT],
UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: $COMPATIBLE_CDS_ALIGNMENT_DEFAULT,
RESULT: ENABLE_COMPATIBLE_CDS_ALIGNMENT,
DESC: [enable use alternative compatible cds core region alignment],
DEFAULT_DESC: [disabled],
DEFAULT_DESC: [disabled except on linux-aarch64],
CHECKING_MSG: [if compatible cds region alignment enabled],
CHECK_AVAILABLE: [
AC_MSG_CHECKING([if CDS archive is available])
Expand Down
7 changes: 5 additions & 2 deletions src/hotspot/cpu/ppc/assembler_ppc.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023 SAP SE. All rights reserved.
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -350,6 +350,7 @@ class Assembler : public AbstractAssembler {

SETBC_OPCODE = (31u << OPCODE_SHIFT | 384u << 1),
SETNBC_OPCODE = (31u << OPCODE_SHIFT | 448u << 1),
SETBCR_OPCODE = (31u << OPCODE_SHIFT | 416u << 1),

// condition register logic instructions
CRAND_OPCODE = (19u << OPCODE_SHIFT | 257u << 1),
Expand Down Expand Up @@ -1780,6 +1781,8 @@ class Assembler : public AbstractAssembler {
inline void setbc( Register d, ConditionRegister cr, Condition cc);
inline void setnbc(Register d, int biint);
inline void setnbc(Register d, ConditionRegister cr, Condition cc);
inline void setbcr(Register d, int biint);
inline void setbcr(Register d, ConditionRegister cr, Condition cc);

// Special purpose registers
// Exception Register
Expand Down
9 changes: 7 additions & 2 deletions src/hotspot/cpu/ppc/assembler_ppc.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020 SAP SE. All rights reserved.
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -419,6 +419,11 @@ inline void Assembler::setnbc(Register d, int biint)
inline void Assembler::setnbc(Register d, ConditionRegister cr, Condition cc) {
setnbc(d, bi0(cr, cc));
}
inline void Assembler::setbcr(Register d, int biint)
{ emit_int32(SETBCR_OPCODE | rt(d) | bi(biint)); }
inline void Assembler::setbcr(Register d, ConditionRegister cr, Condition cc) {
setbcr(d, bi0(cr, cc));
}

// Special purpose registers
// Exception Register
Expand Down
9 changes: 2 additions & 7 deletions src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2383,10 +2383,7 @@ void MacroAssembler::verify_secondary_supers_table(Register r_sub_klass,
addi(r_array_base, r_array_base, Array<Klass*>::base_offset_in_bytes());

// convert !=0 to 1
neg(R0, result);
orr(result, result, R0);
srdi(result, result, 63);

normalize_bool(result, R0, true);
const Register linear_result = r_array_index; // reuse
li(linear_result, 1);
cmpdi(CCR0, r_array_length, 0);
Expand All @@ -2395,9 +2392,7 @@ void MacroAssembler::verify_secondary_supers_table(Register r_sub_klass,
bind(failure);

// convert !=0 to 1
neg(R0, linear_result);
orr(linear_result, linear_result, R0);
srdi(linear_result, linear_result, 63);
normalize_bool(linear_result, R0, true);

cmpd(CCR0, result, linear_result);
beq(CCR0, passed);
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/cpu/ppc/macroAssembler_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class MacroAssembler: public Assembler {
void inline set_cmp3(Register dst);
// set dst to (treat_unordered_like_less ? -1 : +1)
void inline set_cmpu3(Register dst, bool treat_unordered_like_less);
// Branch-free implementation to convert !=0 to 1.
void inline normalize_bool(Register dst, Register temp = R0, bool is_64bit = false);

inline void pd_patch_instruction(address branch, address target, const char* file, int line);
NOT_PRODUCT(static void pd_print_patched_instruction(address branch);)
Expand Down
27 changes: 25 additions & 2 deletions src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021 SAP SE. All rights reserved.
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -264,6 +264,29 @@ inline void MacroAssembler::set_cmpu3(Register dst, bool treat_unordered_like_le
set_cmp3(dst);
}

// Branch-free implementation to convert !=0 to 1
// Set register dst to 1 if dst is non-zero. Uses setbcr instruction on Power10.
inline void MacroAssembler::normalize_bool(Register dst, Register temp, bool is_64bit) {

if (VM_Version::has_brw()) {
if (is_64bit) {
cmpdi(CCR0, dst, 0);
} else {
cmpwi(CCR0, dst, 0);
}
setbcr(dst, CCR0, Assembler::equal);
} else {
assert_different_registers(temp, dst);
neg(temp, dst);
orr(temp, dst, temp);
if (is_64bit) {
srdi(dst, temp, 63);
} else {
srwi(dst, temp, 31);
}
}
}

// Convenience bc_far versions
inline void MacroAssembler::blt_far(ConditionRegister crx, Label& L, int optimize) { MacroAssembler::bc_far(bcondCRbiIs1, bi0(crx, less), L, optimize); }
inline void MacroAssembler::bgt_far(ConditionRegister crx, Label& L, int optimize) { MacroAssembler::bc_far(bcondCRbiIs1, bi0(crx, greater), L, optimize); }
Expand Down
6 changes: 1 addition & 5 deletions src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2472,11 +2472,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
case T_ARRAY: break;

case T_BOOLEAN: { // 0 -> false(0); !0 -> true(1)
Label skip_modify;
__ cmpwi(CCR0, R3_RET, 0);
__ beq(CCR0, skip_modify);
__ li(R3_RET, 1);
__ bind(skip_modify);
__ normalize_bool(R3_RET);
break;
}
case T_BYTE: { // sign extension
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type
switch (type) {
case T_BOOLEAN:
// convert !=0 to 1
__ neg(R0, R3_RET);
__ orr(R0, R3_RET, R0);
__ srwi(R3_RET, R0, 31);
__ normalize_bool(R3_RET);
break;
case T_BYTE:
// sign extend 8 bits
Expand Down
17 changes: 16 additions & 1 deletion src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,22 @@ void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) {
__ la(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
}

void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) { Unimplemented(); }
void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
assert(op->crc()->is_single_cpu(), "crc must be register");
assert(op->val()->is_single_cpu(), "byte value must be register");
assert(op->result_opr()->is_single_cpu(), "result must be register");
Register crc = op->crc()->as_register();
Register val = op->val()->as_register();
Register res = op->result_opr()->as_register();

assert_different_registers(val, crc, res);
__ la(res, ExternalAddress(StubRoutines::crc_table_addr()));

__ notr(crc, crc); // ~crc
__ zero_extend(crc, crc, 32);
__ update_byte_crc32(crc, val, res);
__ notr(res, crc); // ~crc
}

void LIR_Assembler::check_conflict(ciKlass* exact_klass, intptr_t current_klass,
Register tmp, Label &next, Label &none,
Expand Down
74 changes: 73 additions & 1 deletion src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,79 @@ void LIRGenerator::do_ArrayCopy(Intrinsic* x) {
}

void LIRGenerator::do_update_CRC32(Intrinsic* x) {
ShouldNotReachHere();
assert(UseCRC32Intrinsics, "why are we here?");
// Make all state_for calls early since they can emit code
LIR_Opr result = rlock_result(x);
switch (x->id()) {
case vmIntrinsics::_updateCRC32: {
LIRItem crc(x->argument_at(0), this);
LIRItem val(x->argument_at(1), this);
// val is destroyed by update_crc32
val.set_destroys_register();
crc.load_item();
val.load_item();
__ update_crc32(crc.result(), val.result(), result);
break;
}
case vmIntrinsics::_updateBytesCRC32:
case vmIntrinsics::_updateByteBufferCRC32: {
bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32);

LIRItem crc(x->argument_at(0), this);
LIRItem buf(x->argument_at(1), this);
LIRItem off(x->argument_at(2), this);
LIRItem len(x->argument_at(3), this);
buf.load_item();
off.load_nonconstant();

LIR_Opr index = off.result();
int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0;
if (off.result()->is_constant()) {
index = LIR_OprFact::illegalOpr;
offset += off.result()->as_jint();
}
LIR_Opr base_op = buf.result();

if (index->is_valid()) {
LIR_Opr tmp = new_register(T_LONG);
__ convert(Bytecodes::_i2l, index, tmp);
index = tmp;
}

if (offset) {
LIR_Opr tmp = new_pointer_register();
__ add(base_op, LIR_OprFact::intConst(offset), tmp);
base_op = tmp;
offset = 0;
}

LIR_Address* a = new LIR_Address(base_op,
index,
offset,
T_BYTE);
BasicTypeList signature(3);
signature.append(T_INT);
signature.append(T_ADDRESS);
signature.append(T_INT);
CallingConvention* cc = frame_map()->c_calling_convention(&signature);
const LIR_Opr result_reg = result_register_for(x->type());

LIR_Opr addr = new_pointer_register();
__ leal(LIR_OprFact::address(a), addr);

crc.load_item_force(cc->at(0));
__ move(addr, cc->at(1));
len.load_item_force(cc->at(2));

__ call_runtime_leaf(StubRoutines::updateBytesCRC32(), getThreadTemp(), result_reg, cc->args());
__ move(result_reg, result);

break;
}
default: {
ShouldNotReachHere();
}
}
}

void LIRGenerator::do_update_CRC32C(Intrinsic* x) {
Expand Down
21 changes: 16 additions & 5 deletions src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2326,12 +2326,13 @@ void C2_MacroAssembler::expand_bits_l_v(Register dst, Register src, Register mas
}

void C2_MacroAssembler::element_compare(Register a1, Register a2, Register result, Register cnt, Register tmp1, Register tmp2,
VectorRegister vr1, VectorRegister vr2, VectorRegister vrs, bool islatin, Label &DONE) {
VectorRegister vr1, VectorRegister vr2, VectorRegister vrs, bool islatin, Label &DONE,
Assembler::LMUL lmul) {
Label loop;
Assembler::SEW sew = islatin ? Assembler::e8 : Assembler::e16;

bind(loop);
vsetvli(tmp1, cnt, sew, Assembler::m2);
vsetvli(tmp1, cnt, sew, lmul);
vlex_v(vr1, a1, sew);
vlex_v(vr2, a2, sew);
vmsne_vv(vrs, vr1, vr2);
Expand All @@ -2357,7 +2358,7 @@ void C2_MacroAssembler::string_equals_v(Register a1, Register a2, Register resul

mv(result, false);

element_compare(a1, a2, result, cnt, tmp1, tmp2, v2, v4, v2, true, DONE);
element_compare(a1, a2, result, cnt, tmp1, tmp2, v2, v4, v2, true, DONE, Assembler::m2);

bind(DONE);
BLOCK_COMMENT("} string_equals_v");
Expand Down Expand Up @@ -2410,7 +2411,7 @@ void C2_MacroAssembler::arrays_equals_v(Register a1, Register a2, Register resul
la(a1, Address(a1, base_offset));
la(a2, Address(a2, base_offset));

element_compare(a1, a2, result, cnt1, tmp1, tmp2, v2, v4, v2, elem_size == 1, DONE);
element_compare(a1, a2, result, cnt1, tmp1, tmp2, v2, v4, v2, elem_size == 1, DONE, Assembler::m2);

bind(DONE);

Expand Down Expand Up @@ -2445,8 +2446,18 @@ void C2_MacroAssembler::string_compare_v(Register str1, Register str2, Register
mv(cnt2, cnt1);
bind(L);

// We focus on the optimization of small sized string.
// Please check below document for string size distribution statistics.
// https://cr.openjdk.org/~shade/density/string-density-report.pdf
if (str1_isL == str2_isL) { // LL or UU
element_compare(str1, str2, zr, cnt2, tmp1, tmp2, v2, v4, v2, encLL, DIFFERENCE);
// Below construction of v regs and lmul is based on test on 2 different boards,
// vlen == 128 and vlen == 256 respectively.
if (!encLL && MaxVectorSize == 16) { // UU
element_compare(str1, str2, zr, cnt2, tmp1, tmp2, v4, v8, v4, encLL, DIFFERENCE, Assembler::m4);
} else { // UU + MaxVectorSize or LL
element_compare(str1, str2, zr, cnt2, tmp1, tmp2, v2, v4, v2, encLL, DIFFERENCE, Assembler::m2);
}

j(DONE);
} else { // LU or UL
Register strL = encLU ? str1 : str2;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Register tmp1, Register tmp2,
VectorRegister vr1, VectorRegister vr2,
VectorRegister vrs,
bool is_latin, Label& DONE);
bool is_latin, Label& DONE, Assembler::LMUL lmul);

void compress_bits_v(Register dst, Register src, Register mask, bool is_long);
void expand_bits_v(Register dst, Register src, Register mask, bool is_long);
Expand Down
Loading

0 comments on commit 5a279bd

Please sign in to comment.