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 Jan 18, 2025
2 parents e10ec75 + e1cf351 commit f8b066c
Show file tree
Hide file tree
Showing 142 changed files with 1,627 additions and 884 deletions.
3 changes: 1 addition & 2 deletions make/test/BuildTestLib.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, 2025, Oracle and/or its affiliates. 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 @@ -64,7 +64,6 @@ $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \
BIN := $(TEST_LIB_SUPPORT)/test-lib_classes, \
HEADERS := $(TEST_LIB_SUPPORT)/test-lib_headers, \
JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \
DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast removal preview restricted dangling-doc-comments, \
JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \
--add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \
--add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \
Expand Down
8 changes: 7 additions & 1 deletion src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,13 @@ OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) {
__ ld(x10, Address(sp, (sup_k_off) * VMRegImpl::stack_slot_size)); // super klass

Label miss;
__ check_klass_subtype_slow_path(x14, x10, x12, x15, nullptr, &miss);
__ check_klass_subtype_slow_path(x14, /*sub_klass*/
x10, /*super_klass*/
x12, /*tmp1_reg*/
x15, /*tmp2_reg*/
nullptr, /*L_success*/
&miss /*L_failure*/);
// Need extras for table lookup: x7, x11, x13

// fallthrough on success:
__ mv(t0, 1);
Expand Down
275 changes: 242 additions & 33 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

Large diffs are not rendered by default.

58 changes: 47 additions & 11 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,55 @@ class MacroAssembler: public Assembler {
Register tmp1_reg,
Register tmp2_reg,
Label* L_success,
Label* L_failure);
Label* L_failure,
bool set_cond_codes = false);

void check_klass_subtype_slow_path_linear(Register sub_klass,
Register super_klass,
Register tmp1_reg,
Register tmp2_reg,
Label* L_success,
Label* L_failure,
bool set_cond_codes = false);

void check_klass_subtype_slow_path_table(Register sub_klass,
Register super_klass,
Register tmp1_reg,
Register tmp2_reg,
Label* L_success,
Label* L_failure,
bool set_cond_codes = false);

// If r is valid, return r.
// If r is invalid, remove a register r2 from available_regs, add r2
// to regs_to_push, then return r2.
Register allocate_if_noreg(const Register r,
RegSetIterator<Register> &available_regs,
RegSet &regs_to_push);

// Secondary subtype checking
void lookup_secondary_supers_table_var(Register sub_klass,
Register r_super_klass,
Register result,
Register tmp1,
Register tmp2,
Register tmp3,
Register tmp4,
Label *L_success);

void population_count(Register dst, Register src, Register tmp1, Register tmp2);

// As above, but with a constant super_klass.
// The result is in Register result, not the condition codes.
bool lookup_secondary_supers_table(Register r_sub_klass,
Register r_super_klass,
Register result,
Register tmp1,
Register tmp2,
Register tmp3,
Register tmp4,
u1 super_klass_slot,
bool stub_is_near = false);
bool lookup_secondary_supers_table_const(Register r_sub_klass,
Register r_super_klass,
Register result,
Register tmp1,
Register tmp2,
Register tmp3,
Register tmp4,
u1 super_klass_slot,
bool stub_is_near = false);

void verify_secondary_supers_table(Register r_sub_klass,
Register r_super_klass,
Expand All @@ -351,7 +385,8 @@ class MacroAssembler: public Assembler {
Register r_array_index,
Register r_bitmap,
Register result,
Register tmp1);
Register tmp,
bool is_stub = true);

void check_klass_subtype(Register sub_klass,
Register super_klass,
Expand Down Expand Up @@ -926,6 +961,7 @@ class MacroAssembler: public Assembler {
void revbw(Register Rd, Register Rs, Register tmp1 = t0, Register tmp2= t1); // reverse bytes in lower word, sign-extend
void revb(Register Rd, Register Rs, Register tmp1 = t0, Register tmp2 = t1); // reverse bytes in doubleword

void ror(Register dst, Register src, Register shift, Register tmp = t0);
void ror(Register dst, Register src, uint32_t shift, Register tmp = t0);
void rolw(Register dst, Register src, uint32_t shift, Register tmp = t0);

Expand Down
56 changes: 34 additions & 22 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -2364,7 +2364,7 @@ encode %{
Label miss;
Label done;
__ check_klass_subtype_slow_path(sub_reg, super_reg, temp_reg, result_reg,
nullptr, &miss);
nullptr, &miss, /*set_cond_codes*/ true);
if ($primary) {
__ mv(result_reg, zr);
} else {
Expand Down Expand Up @@ -10019,10 +10019,11 @@ instruct CallLeafNoFPDirect(method meth)

instruct partialSubtypeCheck(iRegP_R15 result, iRegP_R14 sub, iRegP_R10 super, iRegP_R12 tmp, rFlagsReg cr)
%{
predicate(!UseSecondarySupersTable);
match(Set result (PartialSubtypeCheck sub super));
effect(KILL tmp, KILL cr);

ins_cost(11 * DEFAULT_COST);
ins_cost(20 * DEFAULT_COST);
format %{ "partialSubtypeCheck $result, $sub, $super\t#@partialSubtypeCheck" %}

ins_encode(riscv_enc_partial_subtype_check(sub, super, tmp, result));
Expand All @@ -10032,23 +10033,50 @@ instruct partialSubtypeCheck(iRegP_R15 result, iRegP_R14 sub, iRegP_R10 super, i
ins_pipe(pipe_class_memory);
%}

// Two versions of partialSubtypeCheck, both used when we need to
// search for a super class in the secondary supers array. The first
// is used when we don't know _a priori_ the class being searched
// for. The second, far more common, is used when we do know: this is
// used for instanceof, checkcast, and any case where C2 can determine
// it by constant propagation.

instruct partialSubtypeCheckVarSuper(iRegP_R14 sub, iRegP_R10 super, iRegP_R15 result,
iRegP_R11 tmpR11, iRegP_R12 tmpR12, iRegP_R13 tmpR13,
iRegP_R16 tmpR16, rFlagsReg cr)
%{
predicate(UseSecondarySupersTable);
match(Set result (PartialSubtypeCheck sub super));
effect(TEMP tmpR11, TEMP tmpR12, TEMP tmpR13, TEMP tmpR16, KILL cr);

ins_cost(10 * DEFAULT_COST); // slightly larger than the next version
format %{ "partialSubtypeCheck $result, $sub, $super" %}

ins_encode %{
__ lookup_secondary_supers_table_var($sub$$Register, $super$$Register, $result$$Register,
$tmpR11$$Register, $tmpR12$$Register, $tmpR13$$Register,
$tmpR16$$Register, nullptr /*L_success*/);
%}

ins_pipe(pipe_class_memory);
%}

instruct partialSubtypeCheckConstSuper(iRegP_R14 sub, iRegP_R10 super_reg, immP super_con, iRegP_R15 result,
iRegP_R11 tmpR11, iRegP_R12 tmpR12, iRegP_R13 tmpR13, iRegP_R16 tmpR16, rFlagsReg cr)
%{
predicate(UseSecondarySupersTable);
match(Set result (PartialSubtypeCheck sub (Binary super_reg super_con)));
effect(TEMP tmpR11, TEMP tmpR12, TEMP tmpR13, TEMP tmpR16, KILL cr);

ins_cost(7 * DEFAULT_COST); // needs to be less than competing nodes
ins_cost(5 * DEFAULT_COST); // needs to be less than competing nodes
format %{ "partialSubtypeCheck $result, $sub, $super_reg, $super_con" %}

ins_encode %{
bool success = false;
u1 super_klass_slot = ((Klass*)$super_con$$constant)->hash_slot();
if (InlineSecondarySupersTest) {
success = __ lookup_secondary_supers_table($sub$$Register, $super_reg$$Register, $result$$Register,
$tmpR11$$Register, $tmpR12$$Register, $tmpR13$$Register,
$tmpR16$$Register, super_klass_slot);
success = __ lookup_secondary_supers_table_const($sub$$Register, $super_reg$$Register, $result$$Register,
$tmpR11$$Register, $tmpR12$$Register, $tmpR13$$Register,
$tmpR16$$Register, super_klass_slot);
} else {
address call = __ reloc_call(RuntimeAddress(StubRoutines::lookup_secondary_supers_table_stub(super_klass_slot)));
success = (call != nullptr);
Expand All @@ -10062,22 +10090,6 @@ instruct partialSubtypeCheckConstSuper(iRegP_R14 sub, iRegP_R10 super_reg, immP
ins_pipe(pipe_class_memory);
%}

instruct partialSubtypeCheckVsZero(iRegP_R15 result, iRegP_R14 sub, iRegP_R10 super, iRegP_R12 tmp,
immP0 zero, rFlagsReg cr)
%{
match(Set cr (CmpP (PartialSubtypeCheck sub super) zero));
effect(KILL tmp, KILL result);

ins_cost(11 * DEFAULT_COST);
format %{ "partialSubtypeCheck $result, $sub, $super == 0\t#@partialSubtypeCheckVsZero" %}

ins_encode(riscv_enc_partial_subtype_check(sub, super, tmp, result));

opcode(0x0); // Don't zero result reg on hit

ins_pipe(pipe_class_memory);
%}

instruct string_compareU(iRegP_R11 str1, iRegI_R12 cnt1, iRegP_R13 str2, iRegI_R14 cnt2,
iRegI_R10 result, iRegP_R28 tmp1, iRegL_R29 tmp2, iRegL_R30 tmp3, rFlagsReg cr)
%{
Expand Down
28 changes: 21 additions & 7 deletions src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,9 @@ class StubGenerator: public StubCodeGenerator {
void generate_type_check(Register sub_klass,
Register super_check_offset,
Register super_klass,
Register result,
Register tmp1,
Register tmp2,
Label& L_success) {
assert_different_registers(sub_klass, super_check_offset, super_klass);

Expand All @@ -1462,7 +1465,7 @@ class StubGenerator: public StubCodeGenerator {
Label L_miss;

__ check_klass_subtype_fast_path(sub_klass, super_klass, noreg, &L_success, &L_miss, nullptr, super_check_offset);
__ check_klass_subtype_slow_path(sub_klass, super_klass, noreg, noreg, &L_success, nullptr);
__ check_klass_subtype_slow_path(sub_klass, super_klass, tmp1, tmp2, &L_success, nullptr);

// Fall through on failure!
__ BIND(L_miss);
Expand Down Expand Up @@ -1591,7 +1594,18 @@ class StubGenerator: public StubCodeGenerator {
__ beqz(copied_oop, L_store_element);

__ load_klass(r9_klass, copied_oop);// query the object klass
generate_type_check(r9_klass, ckoff, ckval, L_store_element);

BLOCK_COMMENT("type_check:");
generate_type_check(r9_klass, /*sub_klass*/
ckoff, /*super_check_offset*/
ckval, /*super_klass*/
x10, /*result*/
gct1, /*tmp1*/
gct2, /*tmp2*/
L_store_element);

// Fall through on failure!

// ======== end loop ========

// It was a real error; we must depend on the caller to finish the job.
Expand All @@ -1600,7 +1614,7 @@ class StubGenerator: public StubCodeGenerator {
// their number to the caller.

__ sub(count, count_save, count); // K = partially copied oop count
__ xori(count, count, -1); // report (-1^K) to caller
__ xori(count, count, -1); // report (-1^K) to caller
__ beqz(count, L_done_pop);

__ BIND(L_do_card_marks);
Expand Down Expand Up @@ -1965,7 +1979,7 @@ class StubGenerator: public StubCodeGenerator {
__ lwu(sco_temp, Address(dst_klass, sco_offset));

// Smashes t0, t1
generate_type_check(scratch_src_klass, sco_temp, dst_klass, L_plain_copy);
generate_type_check(scratch_src_klass, sco_temp, dst_klass, noreg, noreg, noreg, L_plain_copy);

// Fetch destination element klass from the ObjArrayKlass header.
int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
Expand Down Expand Up @@ -3006,9 +3020,9 @@ class StubGenerator: public StubCodeGenerator {

Label L_success;
__ enter();
__ lookup_secondary_supers_table(r_sub_klass, r_super_klass, result,
r_array_base, r_array_length, r_array_index,
r_bitmap, super_klass_index, /*stub_is_near*/true);
__ lookup_secondary_supers_table_const(r_sub_klass, r_super_klass, result,
r_array_base, r_array_length, r_array_index,
r_bitmap, super_klass_index, /*stub_is_near*/ true);
__ leave();
__ ret();

Expand Down
32 changes: 26 additions & 6 deletions src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address cal

// Allocate space for the code. Setup code generation tools.
const char* name = SharedRuntime::stub_name(id);
CodeBuffer buffer(name, 2348, 1024);
CodeBuffer buffer(name, 2548, 1024);
MacroAssembler* masm = new MacroAssembler(&buffer);

address start = __ pc();
Expand Down Expand Up @@ -3086,11 +3086,11 @@ SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address cal
Label bail;
#endif
if (!cause_return) {
Label no_prefix, not_special;
Label no_prefix, not_special, check_rex_prefix;

// If our stashed return pc was modified by the runtime we avoid touching it
__ cmpptr(rbx, Address(rbp, wordSize));
__ jccb(Assembler::notEqual, no_adjust);
__ jcc(Assembler::notEqual, no_adjust);

// Skip over the poll instruction.
// See NativeInstruction::is_safepoint_poll()
Expand All @@ -3113,9 +3113,29 @@ SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address cal
// 41 85 04 24 test %eax,(%r12)
// 85 45 00 test %eax,0x0(%rbp)
// 41 85 45 00 test %eax,0x0(%r13)

//
// Notes:
// Format of legacy MAP0 test instruction:-
// [REX/REX2] [OPCODE] [ModRM] [SIB] [DISP] [IMM32]
// o For safepoint polling instruction "test %eax,(%rax)", encoding of first register
// operand and base register of memory operand is b/w [0-8), hence we do not require
// additional REX prefix where REX.B bit stores MSB bit of register encoding, which
// is why two bytes encoding is sufficient here.
// o For safepoint polling instruction like "test %eax,(%r8)", register encoding of BASE
// register of memory operand is 1000, thus we need additional REX prefix in this case,
// there by adding additional byte to instruction encoding.
// o In case BASE register is one of the 32 extended GPR registers available only on targets
// supporting Intel APX extension, then we need to emit two bytes REX2 prefix to hold
// most significant two bits of 5 bit register encoding.

if (VM_Version::supports_apx_f()) {
__ cmpb(Address(rbx, 0), Assembler::REX2);
__ jccb(Assembler::notEqual, check_rex_prefix);
__ addptr(rbx, 2);
__ bind(check_rex_prefix);
}
__ cmpb(Address(rbx, 0), NativeTstRegMem::instruction_rex_b_prefix);
__ jcc(Assembler::notEqual, no_prefix);
__ jccb(Assembler::notEqual, no_prefix);
__ addptr(rbx, 1);
__ bind(no_prefix);
#ifdef ASSERT
Expand All @@ -3128,7 +3148,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address cal
__ andptr(rcx, 0x07); // looking for 0x04 .. 0x05
__ subptr(rcx, 4); // looking for 0x00 .. 0x01
__ cmpptr(rcx, 1);
__ jcc(Assembler::above, not_special);
__ jccb(Assembler::above, not_special);
__ addptr(rbx, 1);
__ bind(not_special);
#ifdef ASSERT
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. 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 @@ -89,7 +89,7 @@ void AOTLinkedClassBulkLoader::exit_on_exception(JavaThread* current) {
ResourceMark rm(current);
if (current->pending_exception()->is_a(vmClasses::OutOfMemoryError_klass())) {
log_error(cds)("Out of memory. Please run with a larger Java heap, current MaxHeapSize = "
SIZE_FORMAT "M", MaxHeapSize/M);
"%zuM", MaxHeapSize/M);
} else {
log_error(cds)("%s: %s", current->pending_exception()->klass()->external_name(),
java_lang_String::as_utf8_string(java_lang_Throwable::message(current->pending_exception())));
Expand Down
Loading

0 comments on commit f8b066c

Please sign in to comment.