Skip to content

Commit

Permalink
Merge branch 'jbs8334106' of github.com:sendaoYan/jdk-ysd into jbs833…
Browse files Browse the repository at this point in the history
…4106
  • Loading branch information
sendaoYan committed Jun 13, 2024
2 parents 84224bc + 0ae0d31 commit a60819e
Show file tree
Hide file tree
Showing 49 changed files with 2,043 additions and 355 deletions.
2 changes: 1 addition & 1 deletion make/modules/jdk.jpackage/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ DISABLED_WARNINGS_java += dangling-doc-comments

COPY += .gif .png .txt .spec .script .prerm .preinst \
.postrm .postinst .list .sh .desktop .copyright .control .plist .template \
.icns .scpt .wxs .wxl .wxi .ico .bmp .tiff .service
.icns .scpt .wxs .wxl .wxi .ico .bmp .tiff .service .xsl

CLEAN += .properties
34 changes: 19 additions & 15 deletions src/hotspot/cpu/aarch64/aarch64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -5628,24 +5628,24 @@ operand cmpOpLtGe()
// used for certain unsigned integral comparisons which can be
// converted to cbxx or tbxx instructions

operand cmpOpUEqNeLtGe()
operand cmpOpUEqNeLeGt()
%{
match(Bool);
op_cost(0);

predicate(n->as_Bool()->_test._test == BoolTest::eq
|| n->as_Bool()->_test._test == BoolTest::ne
|| n->as_Bool()->_test._test == BoolTest::lt
|| n->as_Bool()->_test._test == BoolTest::ge);
predicate(n->as_Bool()->_test._test == BoolTest::eq ||
n->as_Bool()->_test._test == BoolTest::ne ||
n->as_Bool()->_test._test == BoolTest::le ||
n->as_Bool()->_test._test == BoolTest::gt);

format %{ "" %}
interface(COND_INTER) %{
equal(0x0, "eq");
not_equal(0x1, "ne");
less(0xb, "lt");
greater_equal(0xa, "ge");
less_equal(0xd, "le");
greater(0xc, "gt");
less(0x3, "lo");
greater_equal(0x2, "hs");
less_equal(0x9, "ls");
greater(0x8, "hi");
overflow(0x6, "vs");
no_overflow(0x7, "vc");
%}
Expand Down Expand Up @@ -15687,7 +15687,7 @@ instruct cmpP_narrowOop_imm0_branch(cmpOpEqNe cmp, iRegN oop, immP0 zero, label
ins_pipe(pipe_cmp_branch);
%}

instruct cmpUI_imm0_branch(cmpOpUEqNeLtGe cmp, iRegIorL2I op1, immI0 op2, label labl, rFlagsRegU cr) %{
instruct cmpUI_imm0_branch(cmpOpUEqNeLeGt cmp, iRegIorL2I op1, immI0 op2, label labl) %{
match(If cmp (CmpU op1 op2));
effect(USE labl);

Expand All @@ -15696,15 +15696,17 @@ instruct cmpUI_imm0_branch(cmpOpUEqNeLtGe cmp, iRegIorL2I op1, immI0 op2, label
ins_encode %{
Label* L = $labl$$label;
Assembler::Condition cond = (Assembler::Condition)$cmp$$cmpcode;
if (cond == Assembler::EQ || cond == Assembler::LS)
if (cond == Assembler::EQ || cond == Assembler::LS) {
__ cbzw($op1$$Register, *L);
else
} else {
assert(cond == Assembler::NE || cond == Assembler::HI, "unexpected condition");
__ cbnzw($op1$$Register, *L);
}
%}
ins_pipe(pipe_cmp_branch);
%}

instruct cmpUL_imm0_branch(cmpOpUEqNeLtGe cmp, iRegL op1, immL0 op2, label labl, rFlagsRegU cr) %{
instruct cmpUL_imm0_branch(cmpOpUEqNeLeGt cmp, iRegL op1, immL0 op2, label labl) %{
match(If cmp (CmpUL op1 op2));
effect(USE labl);

Expand All @@ -15713,10 +15715,12 @@ instruct cmpUL_imm0_branch(cmpOpUEqNeLtGe cmp, iRegL op1, immL0 op2, label labl,
ins_encode %{
Label* L = $labl$$label;
Assembler::Condition cond = (Assembler::Condition)$cmp$$cmpcode;
if (cond == Assembler::EQ || cond == Assembler::LS)
if (cond == Assembler::EQ || cond == Assembler::LS) {
__ cbz($op1$$Register, *L);
else
} else {
assert(cond == Assembler::NE || cond == Assembler::HI, "unexpected condition");
__ cbnz($op1$$Register, *L);
}
%}
ins_pipe(pipe_cmp_branch);
%}
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/s390/assembler_s390.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,9 @@ class Assembler : public AbstractAssembler {
static int inv_simm32(long x) { return (inv_s_field(x, 31, 0)); } // 6-byte instructions only
static int inv_uimm12(long x) { return (inv_u_field(x, 11, 0)); } // 4-byte instructions only

// NOTE: PLEASE DON'T USE IT NAKED UNTIL WE DROP SUPPORT FOR MACHINES OLDER THAN Z15!!!!
inline void z_popcnt(Register r1, Register r2, int64_t m3); // population count

private:

// Encode u_field from long value.
Expand Down Expand Up @@ -3106,7 +3109,6 @@ class Assembler : public AbstractAssembler {

// Ppopulation count intrinsics.
inline void z_flogr(Register r1, Register r2); // find leftmost one
inline void z_popcnt(Register r1, Register r2); // population count
inline void z_ahhhr(Register r1, Register r2, Register r3); // ADD halfword high high
inline void z_ahhlr(Register r1, Register r2, Register r3); // ADD halfword high low

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/s390/assembler_s390.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ inline void Assembler::z_brxhg(Register r1, Register r3, Label& L) {z_brxhg(r1,
inline void Assembler::z_brxlg(Register r1, Register r3, Label& L) {z_brxlg(r1, r3, target(L)); }

inline void Assembler::z_flogr( Register r1, Register r2) { emit_32( FLOGR_ZOPC | reg(r1, 24, 32) | reg(r2, 28, 32)); }
inline void Assembler::z_popcnt(Register r1, Register r2) { emit_32( POPCNT_ZOPC | reg(r1, 24, 32) | reg(r2, 28, 32)); }
inline void Assembler::z_popcnt(Register r1, Register r2, int64_t m3) { emit_32( POPCNT_ZOPC | reg(r1, 24, 32) | reg(r2, 28, 32) | uimm4(m3, 16, 32)); }
inline void Assembler::z_ahhhr( Register r1, Register r2, Register r3) { emit_32( AHHHR_ZOPC | reg(r3, 16, 32) | reg(r1, 24, 32) | reg(r2, 28, 32)); }
inline void Assembler::z_ahhlr( Register r1, Register r2, Register r3) { emit_32( AHHLR_ZOPC | reg(r3, 16, 32) | reg(r1, 24, 32) | reg(r2, 28, 32)); }

Expand Down
84 changes: 84 additions & 0 deletions src/hotspot/cpu/s390/macroAssembler_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5803,3 +5803,87 @@ void MacroAssembler::lightweight_unlock(Register obj, Register hdr, Register tmp
z_alsi(in_bytes(JavaThread::lock_stack_top_offset()), Z_thread, -oopSize); // pop object
z_cr(tmp, tmp); // set CC to EQ
}

void MacroAssembler::pop_count_int(Register r_dst, Register r_src, Register r_tmp) {
BLOCK_COMMENT("pop_count_int {");

assert(r_tmp != noreg, "temp register required for pop_count_int, as code may run on machine older than z15");
assert_different_registers(r_dst, r_tmp); // if r_src is same as r_tmp, it should be fine

if (VM_Version::has_MiscInstrExt3()) {
pop_count_int_with_ext3(r_dst, r_src);
} else {
pop_count_int_without_ext3(r_dst, r_src, r_tmp);
}

BLOCK_COMMENT("} pop_count_int");
}

void MacroAssembler::pop_count_long(Register r_dst, Register r_src, Register r_tmp) {
BLOCK_COMMENT("pop_count_long {");

assert(r_tmp != noreg, "temp register required for pop_count_long, as code may run on machine older than z15");
assert_different_registers(r_dst, r_tmp); // if r_src is same as r_tmp, it should be fine

if (VM_Version::has_MiscInstrExt3()) {
pop_count_long_with_ext3(r_dst, r_src);
} else {
pop_count_long_without_ext3(r_dst, r_src, r_tmp);
}

BLOCK_COMMENT("} pop_count_long");
}

void MacroAssembler::pop_count_int_without_ext3(Register r_dst, Register r_src, Register r_tmp) {
BLOCK_COMMENT("pop_count_int_without_ext3 {");

assert(r_tmp != noreg, "temp register required for popcnt, for machines < z15");
assert_different_registers(r_dst, r_tmp); // if r_src is same as r_tmp, it should be fine

z_popcnt(r_dst, r_src, 0);
z_srlg(r_tmp, r_dst, 16);
z_alr(r_dst, r_tmp);
z_srlg(r_tmp, r_dst, 8);
z_alr(r_dst, r_tmp);
z_llgcr(r_dst, r_dst);

BLOCK_COMMENT("} pop_count_int_without_ext3");
}

void MacroAssembler::pop_count_long_without_ext3(Register r_dst, Register r_src, Register r_tmp) {
BLOCK_COMMENT("pop_count_long_without_ext3 {");

assert(r_tmp != noreg, "temp register required for popcnt, for machines < z15");
assert_different_registers(r_dst, r_tmp); // if r_src is same as r_tmp, it should be fine

z_popcnt(r_dst, r_src, 0);
z_ahhlr(r_dst, r_dst, r_dst);
z_sllg(r_tmp, r_dst, 16);
z_algr(r_dst, r_tmp);
z_sllg(r_tmp, r_dst, 8);
z_algr(r_dst, r_tmp);
z_srlg(r_dst, r_dst, 56);

BLOCK_COMMENT("} pop_count_long_without_ext3");
}

void MacroAssembler::pop_count_long_with_ext3(Register r_dst, Register r_src) {
BLOCK_COMMENT("pop_count_long_with_ext3 {");

guarantee(VM_Version::has_MiscInstrExt3(),
"this hardware doesn't support miscellaneous-instruction-extensions facility 3, still pop_count_long_with_ext3 is used");
z_popcnt(r_dst, r_src, 8);

BLOCK_COMMENT("} pop_count_long_with_ext3");
}

void MacroAssembler::pop_count_int_with_ext3(Register r_dst, Register r_src) {
BLOCK_COMMENT("pop_count_int_with_ext3 {");

guarantee(VM_Version::has_MiscInstrExt3(),
"this hardware doesn't support miscellaneous-instruction-extensions facility 3, still pop_count_long_with_ext3 is used");
z_llgfr(r_dst, r_src);
z_popcnt(r_dst, r_dst, 8);

BLOCK_COMMENT("} pop_count_int_with_ext3");
}
18 changes: 16 additions & 2 deletions src/hotspot/cpu/s390/macroAssembler_s390.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023 SAP SE. All rights reserved.
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024 SAP SE. All rights reserved.
* Copyright (c) 2024 IBM Corporation. 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 @@ -1021,6 +1022,19 @@ class MacroAssembler: public Assembler {
Register z,
Register tmp1, Register tmp2,
Register tmp3, Register tmp4, Register tmp5);

// These generate optimized code for all supported s390 implementations, and are preferred for most uses.
void pop_count_int(Register dst, Register src, Register tmp);
void pop_count_long(Register dst, Register src, Register tmp);

// For legacy (pre-z15) use, but will work on all supported s390 implementations.
void pop_count_int_without_ext3(Register dst, Register src, Register tmp);
void pop_count_long_without_ext3(Register dst, Register src, Register tmp);

// Only for use on z15 or later s390 implementations.
void pop_count_int_with_ext3(Register dst, Register src);
void pop_count_long_with_ext3(Register dst, Register src);

};

/**
Expand Down
71 changes: 46 additions & 25 deletions src/hotspot/cpu/s390/s390.ad
Original file line number Diff line number Diff line change
Expand Up @@ -10675,10 +10675,49 @@ instruct countTrailingZerosL(revenRegI dst, iRegL src, roddRegL tmp, flagsReg cr

// bit count

instruct popCountI_Ext3(iRegI dst, iRegI src, flagsReg cr) %{
match(Set dst (PopCountI src));
effect(TEMP_DEF dst, KILL cr);
predicate(UsePopCountInstruction &&
VM_Version::has_PopCount() &&
VM_Version::has_MiscInstrExt3());
ins_cost(DEFAULT_COST);
size(8); // popcnt + llgfr
format %{ "POPCNT $dst,$src\t # pop count int" %}
ins_encode %{
Register Rdst = $dst$$Register;
Register Rsrc = $src$$Register;

__ pop_count_int_with_ext3(Rdst, Rsrc);

%}
ins_pipe(pipe_class_dummy);
%}

instruct popCountL_Ext3(iRegI dst, iRegL src, flagsReg cr) %{
match(Set dst (PopCountL src));
effect(TEMP_DEF dst, KILL cr);
predicate(UsePopCountInstruction &&
VM_Version::has_PopCount() &&
VM_Version::has_MiscInstrExt3());
ins_cost(DEFAULT_COST);
size(4); // popcnt
format %{ "POPCNT $dst,$src\t # pop count long" %}
ins_encode %{
Register Rdst = $dst$$Register;
Register Rsrc = $src$$Register;

__ pop_count_long_with_ext3(Rdst, Rsrc);
%}
ins_pipe(pipe_class_dummy);
%}

instruct popCountI(iRegI dst, iRegI src, iRegI tmp, flagsReg cr) %{
match(Set dst (PopCountI src));
effect(TEMP_DEF dst, TEMP tmp, KILL cr);
predicate(UsePopCountInstruction && VM_Version::has_PopCount());
predicate(UsePopCountInstruction &&
VM_Version::has_PopCount() &&
(!VM_Version::has_MiscInstrExt3()));
ins_cost(DEFAULT_COST);
size(24);
format %{ "POPCNT $dst,$src\t # pop count int" %}
Expand All @@ -10687,45 +10726,27 @@ instruct popCountI(iRegI dst, iRegI src, iRegI tmp, flagsReg cr) %{
Register Rsrc = $src$$Register;
Register Rtmp = $tmp$$Register;

// Prefer compile-time assertion over run-time SIGILL.
assert(VM_Version::has_PopCount(), "bad predicate for countLeadingZerosI");
assert_different_registers(Rdst, Rtmp);
__ pop_count_int_without_ext3(Rdst, Rsrc, Rtmp);

// Version 2: shows 10%(z196) improvement over original.
__ z_popcnt(Rdst, Rsrc);
__ z_srlg(Rtmp, Rdst, 16); // calc byte4+byte6 and byte5+byte7
__ z_alr(Rdst, Rtmp); // into byte6 and byte7
__ z_srlg(Rtmp, Rdst, 8); // calc (byte4+byte6) + (byte5+byte7)
__ z_alr(Rdst, Rtmp); // into byte7
__ z_llgcr(Rdst, Rdst); // zero-extend sum
%}
ins_pipe(pipe_class_dummy);
%}

instruct popCountL(iRegI dst, iRegL src, iRegL tmp, flagsReg cr) %{
match(Set dst (PopCountL src));
effect(TEMP_DEF dst, TEMP tmp, KILL cr);
predicate(UsePopCountInstruction && VM_Version::has_PopCount());
predicate(UsePopCountInstruction &&
VM_Version::has_PopCount() &&
(!VM_Version::has_MiscInstrExt3()));
ins_cost(DEFAULT_COST);
// TODO: s390 port size(FIXED_SIZE);
size(34);
format %{ "POPCNT $dst,$src\t # pop count long" %}
ins_encode %{
Register Rdst = $dst$$Register;
Register Rsrc = $src$$Register;
Register Rtmp = $tmp$$Register;

// Prefer compile-time assertion over run-time SIGILL.
assert(VM_Version::has_PopCount(), "bad predicate for countLeadingZerosI");
assert_different_registers(Rdst, Rtmp);

// Original version. Using LA instead of algr seems to be a really bad idea (-35%).
__ z_popcnt(Rdst, Rsrc);
__ z_ahhlr(Rdst, Rdst, Rdst);
__ z_sllg(Rtmp, Rdst, 16);
__ z_algr(Rdst, Rtmp);
__ z_sllg(Rtmp, Rdst, 8);
__ z_algr(Rdst, Rtmp);
__ z_srlg(Rdst, Rdst, 56);
__ pop_count_long_without_ext3(Rdst, Rsrc, Rtmp);
%}
ins_pipe(pipe_class_dummy);
%}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/symbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class SymbolTableConfig : public AllStatic {
// Deleting permanent symbol should not occur very often (insert race condition),
// so log it.
log_trace_symboltable_helper(&value, "Freeing permanent symbol");
size_t alloc_size = _local_table->get_node_size() + value.byte_size() + value.effective_length();
size_t alloc_size = SymbolTableHash::get_dynamic_node_size(value.byte_size());
if (!SymbolTable::arena()->Afree(memory, alloc_size)) {
log_trace_symboltable_helper(&value, "Leaked permanent symbol");
}
Expand All @@ -182,7 +182,7 @@ class SymbolTableConfig : public AllStatic {

private:
static void* allocate_node_impl(size_t size, Value const& value) {
size_t alloc_size = size + value.byte_size() + value.effective_length();
size_t alloc_size = SymbolTableHash::get_dynamic_node_size(value.byte_size());
#if INCLUDE_CDS
if (CDSConfig::is_dumping_static_archive()) {
MutexLocker ml(DumpRegion_lock, Mutex::_no_safepoint_check_flag);
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/share/oops/symbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Symbol : public MetaspaceObj {
};

static int byte_size(int length) {
// minimum number of natural words needed to hold these bits (no non-heap version)
// minimum number of bytes needed to hold these bits (no non-heap version)
return (int)(sizeof(Symbol) + (length > 2 ? length - 2 : 0));
}
static int size(int length) {
Expand All @@ -146,8 +146,6 @@ class Symbol : public MetaspaceObj {

int size() const { return size(utf8_length()); }
int byte_size() const { return byte_size(utf8_length()); };
// length without the _body
size_t effective_length() const { return (size_t)byte_size() - sizeof(Symbol); }

// Symbols should be stored in the read-only region of CDS archive.
static bool is_read_only_by_default() { return true; }
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/runtime/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,15 @@ void Threads::print_on(outputStream* st, bool print_stacks,
p->trace_stack();
} else {
p->print_stack_on(st);
const oop thread_oop = p->threadObj();
if (thread_oop != nullptr) {
if (p->is_vthread_mounted()) {
const oop vt = p->vthread();
assert(vt != nullptr, "vthread should not be null when vthread is mounted");
st->print_cr(" Mounted virtual thread \"%s\" #" INT64_FORMAT, JavaThread::name_for(vt), (int64_t)java_lang_Thread::thread_id(vt));
p->print_vthread_stack_on(st);
}
}
}
}
st->cr();
Expand Down
Loading

0 comments on commit a60819e

Please sign in to comment.