This commit is contained in:
Jesper Wilhelmsson 2022-06-28 22:11:23 +00:00
commit 86dc760f9e
29 changed files with 750 additions and 209 deletions

View File

@ -4454,6 +4454,16 @@ operand immI_65535()
interface(CONST_INTER);
%}
operand immI_positive()
%{
predicate(n->get_int() > 0);
match(ConI);
op_cost(0);
format %{ %}
interface(CONST_INTER);
%}
operand immL_255()
%{
predicate(n->get_long() == 255L);

View File

@ -4721,7 +4721,7 @@ instruct vsll16B_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsra8B_imm(vecD dst, vecD src, immI shift) %{
instruct vsra8B_imm(vecD dst, vecD src, immI_positive shift) %{
predicate((n->as_Vector()->length() == 4 || n->as_Vector()->length() == 8) &&
assert_not_var_shift(n));
match(Set dst (RShiftVB src (RShiftCntV shift)));
@ -4736,7 +4736,7 @@ instruct vsra8B_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsra16B_imm(vecX dst, vecX src, immI shift) %{
instruct vsra16B_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 16 && assert_not_var_shift(n));
match(Set dst (RShiftVB src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -4750,7 +4750,7 @@ instruct vsra16B_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsrl8B_imm(vecD dst, vecD src, immI shift) %{
instruct vsrl8B_imm(vecD dst, vecD src, immI_positive shift) %{
predicate((n->as_Vector()->length() == 4 || n->as_Vector()->length() == 8) &&
assert_not_var_shift(n));
match(Set dst (URShiftVB src (RShiftCntV shift)));
@ -4770,7 +4770,7 @@ instruct vsrl8B_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsrl16B_imm(vecX dst, vecX src, immI shift) %{
instruct vsrl16B_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 16 && assert_not_var_shift(n));
match(Set dst (URShiftVB src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -4978,7 +4978,7 @@ instruct vsll8S_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsra4S_imm(vecD dst, vecD src, immI shift) %{
instruct vsra4S_imm(vecD dst, vecD src, immI_positive shift) %{
predicate((n->as_Vector()->length() == 2 || n->as_Vector()->length() == 4) &&
assert_not_var_shift(n));
match(Set dst (RShiftVS src (RShiftCntV shift)));
@ -4993,7 +4993,7 @@ instruct vsra4S_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsra8S_imm(vecX dst, vecX src, immI shift) %{
instruct vsra8S_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 8 && assert_not_var_shift(n));
match(Set dst (RShiftVS src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -5007,7 +5007,7 @@ instruct vsra8S_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsrl4S_imm(vecD dst, vecD src, immI shift) %{
instruct vsrl4S_imm(vecD dst, vecD src, immI_positive shift) %{
predicate((n->as_Vector()->length() == 2 || n->as_Vector()->length() == 4) &&
assert_not_var_shift(n));
match(Set dst (URShiftVS src (RShiftCntV shift)));
@ -5027,7 +5027,7 @@ instruct vsrl4S_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsrl8S_imm(vecX dst, vecX src, immI shift) %{
instruct vsrl8S_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 8 && assert_not_var_shift(n));
match(Set dst (URShiftVS src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -5218,7 +5218,7 @@ instruct vsll4I_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsra2I_imm(vecD dst, vecD src, immI shift) %{
instruct vsra2I_imm(vecD dst, vecD src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 2 && assert_not_var_shift(n));
match(Set dst (RShiftVI src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -5231,7 +5231,7 @@ instruct vsra2I_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsra4I_imm(vecX dst, vecX src, immI shift) %{
instruct vsra4I_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 4 && assert_not_var_shift(n));
match(Set dst (RShiftVI src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -5244,7 +5244,7 @@ instruct vsra4I_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsrl2I_imm(vecD dst, vecD src, immI shift) %{
instruct vsrl2I_imm(vecD dst, vecD src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 2 && assert_not_var_shift(n));
match(Set dst (URShiftVI src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -5257,7 +5257,7 @@ instruct vsrl2I_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsrl4I_imm(vecX dst, vecX src, immI shift) %{
instruct vsrl4I_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 4 && assert_not_var_shift(n));
match(Set dst (URShiftVI src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -5356,7 +5356,7 @@ instruct vsll2L_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsra2L_imm(vecX dst, vecX src, immI shift) %{
instruct vsra2L_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 2 && assert_not_var_shift(n));
match(Set dst (RShiftVL src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -5369,7 +5369,7 @@ instruct vsra2L_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsrl2L_imm(vecX dst, vecX src, immI shift) %{
instruct vsrl2L_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 2 && assert_not_var_shift(n));
match(Set dst (URShiftVL src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -5382,7 +5382,7 @@ instruct vsrl2L_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsraa8B_imm(vecD dst, vecD src, immI shift) %{
instruct vsraa8B_imm(vecD dst, vecD src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 8);
match(Set dst (AddVB dst (RShiftVB src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5396,7 +5396,7 @@ instruct vsraa8B_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsraa16B_imm(vecX dst, vecX src, immI shift) %{
instruct vsraa16B_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 16);
match(Set dst (AddVB dst (RShiftVB src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5410,7 +5410,7 @@ instruct vsraa16B_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsraa4S_imm(vecD dst, vecD src, immI shift) %{
instruct vsraa4S_imm(vecD dst, vecD src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 4);
match(Set dst (AddVS dst (RShiftVS src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5424,7 +5424,7 @@ instruct vsraa4S_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsraa8S_imm(vecX dst, vecX src, immI shift) %{
instruct vsraa8S_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 8);
match(Set dst (AddVS dst (RShiftVS src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5438,7 +5438,7 @@ instruct vsraa8S_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsraa2I_imm(vecD dst, vecD src, immI shift) %{
instruct vsraa2I_imm(vecD dst, vecD src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 2);
match(Set dst (AddVI dst (RShiftVI src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5451,7 +5451,7 @@ instruct vsraa2I_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsraa4I_imm(vecX dst, vecX src, immI shift) %{
instruct vsraa4I_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 4);
match(Set dst (AddVI dst (RShiftVI src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5464,7 +5464,7 @@ instruct vsraa4I_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsraa2L_imm(vecX dst, vecX src, immI shift) %{
instruct vsraa2L_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 2);
match(Set dst (AddVL dst (RShiftVL src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5477,7 +5477,7 @@ instruct vsraa2L_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsrla8B_imm(vecD dst, vecD src, immI shift) %{
instruct vsrla8B_imm(vecD dst, vecD src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 8);
match(Set dst (AddVB dst (URShiftVB src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5492,7 +5492,7 @@ instruct vsrla8B_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsrla16B_imm(vecX dst, vecX src, immI shift) %{
instruct vsrla16B_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 16);
match(Set dst (AddVB dst (URShiftVB src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5507,7 +5507,7 @@ instruct vsrla16B_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsrla4S_imm(vecD dst, vecD src, immI shift) %{
instruct vsrla4S_imm(vecD dst, vecD src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 4);
match(Set dst (AddVS dst (URShiftVS src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5522,7 +5522,7 @@ instruct vsrla4S_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsrla8S_imm(vecX dst, vecX src, immI shift) %{
instruct vsrla8S_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 8);
match(Set dst (AddVS dst (URShiftVS src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5537,7 +5537,7 @@ instruct vsrla8S_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsrla2I_imm(vecD dst, vecD src, immI shift) %{
instruct vsrla2I_imm(vecD dst, vecD src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 2);
match(Set dst (AddVI dst (URShiftVI src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5550,7 +5550,7 @@ instruct vsrla2I_imm(vecD dst, vecD src, immI shift) %{
ins_pipe(vshift64_imm);
%}
instruct vsrla4I_imm(vecX dst, vecX src, immI shift) %{
instruct vsrla4I_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 4);
match(Set dst (AddVI dst (URShiftVI src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -5563,7 +5563,7 @@ instruct vsrla4I_imm(vecX dst, vecX src, immI shift) %{
ins_pipe(vshift128_imm);
%}
instruct vsrla2L_imm(vecX dst, vecX src, immI shift) %{
instruct vsrla2L_imm(vecX dst, vecX src, immI_positive shift) %{
predicate(n->as_Vector()->length() == 2);
match(Set dst (AddVL dst (URShiftVL src (RShiftCntV shift))));
ins_cost(INSN_COST);

View File

@ -2199,7 +2199,7 @@ instruct vsll$1$2_imm`'(vec$4 dst, vec$4 src, immI shift) %{
%}')dnl
dnl
define(`VSRA_IMM', `
instruct vsra$1$2_imm`'(vec$4 dst, vec$4 src, immI shift) %{
instruct vsra$1$2_imm`'(vec$4 dst, vec$4 src, immI_positive shift) %{
PREDICATE(`$1$2', $1, assert_not_var_shift(n))
match(Set dst (RShiftV$2 src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -2221,7 +2221,7 @@ instruct vsra$1$2_imm`'(vec$4 dst, vec$4 src, immI shift) %{
%}')dnl
dnl
define(`VSRL_IMM', `
instruct vsrl$1$2_imm`'(vec$4 dst, vec$4 src, immI shift) %{
instruct vsrl$1$2_imm`'(vec$4 dst, vec$4 src, immI_positive shift) %{
PREDICATE(`$1$2', $1, assert_not_var_shift(n))
match(Set dst (URShiftV$2 src (RShiftCntV shift)));
ins_cost(INSN_COST);
@ -2253,7 +2253,7 @@ instruct vsrl$1$2_imm`'(vec$4 dst, vec$4 src, immI shift) %{
%}')dnl
dnl
define(`VSRLA_IMM', `
instruct vsrla$1$2_imm`'(vec$4 dst, vec$4 src, immI shift) %{
instruct vsrla$1$2_imm`'(vec$4 dst, vec$4 src, immI_positive shift) %{
predicate(n->as_Vector()->length() == $1);
match(Set dst (AddV$2 dst (URShiftV$2 src (RShiftCntV shift))));
ins_cost(INSN_COST);
@ -2277,7 +2277,7 @@ instruct vsrla$1$2_imm`'(vec$4 dst, vec$4 src, immI shift) %{
%}')dnl
dnl
define(`VSRAA_IMM', `
instruct vsraa$1$2_imm`'(vec$4 dst, vec$4 src, immI shift) %{
instruct vsraa$1$2_imm`'(vec$4 dst, vec$4 src, immI_positive shift) %{
predicate(n->as_Vector()->length() == $1);
match(Set dst (AddV$2 dst (RShiftV$2 src (RShiftCntV shift))));
ins_cost(INSN_COST);

View File

@ -66,7 +66,9 @@ class BlockListBuilder {
GrowableArray<ResourceBitMap> _loop_map; // caches the information if a block is contained in a loop
int _next_loop_index; // next free loop number
int _next_block_number; // for reverse postorder numbering of blocks
int _block_id_start;
int bit_number(int block_id) const { return block_id - _block_id_start; }
// accessors
Compilation* compilation() const { return _compilation; }
IRScope* scope() const { return _scope; }
@ -122,6 +124,7 @@ BlockListBuilder::BlockListBuilder(Compilation* compilation, IRScope* scope, int
, _loop_map() // size not known yet
, _next_loop_index(0)
, _next_block_number(0)
, _block_id_start(0)
{
set_entries(osr_bci);
set_leaders();
@ -384,11 +387,12 @@ void BlockListBuilder::set_leaders() {
void BlockListBuilder::mark_loops() {
ResourceMark rm;
_active.initialize(BlockBegin::number_of_blocks());
_visited.initialize(BlockBegin::number_of_blocks());
_loop_map = GrowableArray<ResourceBitMap>(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), ResourceBitMap());
for (int i = 0; i < BlockBegin::number_of_blocks(); i++) {
_loop_map.at(i).initialize(BlockBegin::number_of_blocks());
const int number_of_blocks = _blocks.length();
_active.initialize(number_of_blocks);
_visited.initialize(number_of_blocks);
_loop_map = GrowableArray<ResourceBitMap>(number_of_blocks, number_of_blocks, ResourceBitMap());
for (int i = 0; i < number_of_blocks; i++) {
_loop_map.at(i).initialize(number_of_blocks);
}
_next_loop_index = 0;
_next_block_number = _blocks.length();
@ -401,12 +405,14 @@ void BlockListBuilder::mark_loops() {
// - The bit is then propagated for all the blocks in the loop after we exit them (post-order). There could be multiple bits
// of course in case of nested loops.
// - When we exit the loop header we remove that single bit and assign the real loop state for it.
// - Now, the tricky part here is how we detect irriducible loops. In the algorithm above the loop state bits
// - Now, the tricky part here is how we detect irreducible loops. In the algorithm above the loop state bits
// are propagated to the predecessors. If we encounter an irreducible loop (a loop with multiple heads) we would see
// a node with some loop bit set that would then propagate back and be never cleared because we would
// never go back through the original loop header. Therefore if there are any irreducible loops the bits in the states
// for these loops are going to propagate back to the root.
BitMap& loop_state = mark_loops(_bci2block->at(0), false);
BlockBegin* start = _bci2block->at(0);
_block_id_start = start->block_id();
BitMap& loop_state = mark_loops(start, false);
if (!loop_state.is_empty()) {
compilation()->set_has_irreducible_loops(true);
}
@ -419,6 +425,8 @@ void BlockListBuilder::mark_loops() {
}
void BlockListBuilder::make_loop_header(BlockBegin* block) {
int block_id = block->block_id();
int block_bit = bit_number(block_id);
if (block->is_set(BlockBegin::exception_entry_flag)) {
// exception edges may look like loops but don't mark them as such
// since it screws up block ordering.
@ -427,24 +435,25 @@ void BlockListBuilder::make_loop_header(BlockBegin* block) {
if (!block->is_set(BlockBegin::parser_loop_header_flag)) {
block->set(BlockBegin::parser_loop_header_flag);
assert(_loop_map.at(block->block_id()).is_empty(), "must not be set yet");
assert(0 <= _next_loop_index && _next_loop_index < BlockBegin::number_of_blocks(), "_next_loop_index is too large");
_loop_map.at(block->block_id()).set_bit(_next_loop_index++);
assert(_loop_map.at(block_bit).is_empty(), "must not be set yet");
assert(0 <= _next_loop_index && _next_loop_index < _loop_map.length(), "_next_loop_index is too large");
_loop_map.at(block_bit).set_bit(_next_loop_index++);
} else {
// block already marked as loop header
assert(_loop_map.at(block->block_id()).count_one_bits() == 1, "exactly one bit must be set");
assert(_loop_map.at(block_bit).count_one_bits() == 1, "exactly one bit must be set");
}
}
BitMap& BlockListBuilder::mark_loops(BlockBegin* block, bool in_subroutine) {
int block_id = block->block_id();
if (_visited.at(block_id)) {
if (_active.at(block_id)) {
int block_bit = bit_number(block_id);
if (_visited.at(block_bit)) {
if (_active.at(block_bit)) {
// reached block via backward branch
make_loop_header(block);
}
// return cached loop information for this block
return _loop_map.at(block_id);
return _loop_map.at(block_bit);
}
if (block->is_set(BlockBegin::subroutine_entry_flag)) {
@ -452,18 +461,19 @@ BitMap& BlockListBuilder::mark_loops(BlockBegin* block, bool in_subroutine) {
}
// set active and visited bits before successors are processed
_visited.set_bit(block_id);
_active.set_bit(block_id);
_visited.set_bit(block_bit);
_active.set_bit(block_bit);
ResourceMark rm;
ResourceBitMap loop_state(BlockBegin::number_of_blocks());
ResourceBitMap loop_state(_loop_map.length());
for (int i = number_of_successors(block) - 1; i >= 0; i--) {
BlockBegin* sux = successor_at(block, i);
// recursively process all successors
loop_state.set_union(mark_loops(successor_at(block, i), in_subroutine));
loop_state.set_union(mark_loops(sux, in_subroutine));
}
// clear active-bit after all successors are processed
_active.clear_bit(block_id);
_active.clear_bit(block_bit);
// reverse-post-order numbering of all blocks
block->set_depth_first_number(_next_block_number);
@ -476,15 +486,15 @@ BitMap& BlockListBuilder::mark_loops(BlockBegin* block, bool in_subroutine) {
}
if (block->is_set(BlockBegin::parser_loop_header_flag)) {
BitMap& header_loop_state = _loop_map.at(block_id);
BitMap& header_loop_state = _loop_map.at(block_bit);
assert(header_loop_state.count_one_bits() == 1, "exactly one bit must be set");
// remove the bit with the loop number for the state (header is outside of the loop)
loop_state.set_difference(header_loop_state);
}
// cache and return loop information for this block
_loop_map.at(block_id).set_from(loop_state);
return _loop_map.at(block_id);
_loop_map.at(block_bit).set_from(loop_state);
return _loop_map.at(block_bit);
}
inline int BlockListBuilder::number_of_successors(BlockBegin* block)

View File

@ -2348,6 +2348,12 @@ void G1CollectedHeap::par_iterate_regions_array(HeapRegionClosure* cl,
HeapWord* G1CollectedHeap::block_start(const void* addr) const {
HeapRegion* hr = heap_region_containing(addr);
// The CollectedHeap API requires us to not fail for any given address within
// the heap. HeapRegion::block_start() has been optimized to not accept addresses
// outside of the allocated area.
if (addr >= hr->top()) {
return nullptr;
}
return hr->block_start(addr);
}

View File

@ -1861,6 +1861,24 @@ void PhaseCCP::analyze() {
}
}
}
push_and(worklist, n, m);
}
}
}
}
// AndI/L::Value() optimizes patterns similar to (v << 2) & 3 to zero if they are bitwise disjoint.
// Add the AndI/L nodes back to the worklist to re-apply Value() in case the shift value changed.
void PhaseCCP::push_and(Unique_Node_List& worklist, const Node* parent, const Node* use) const {
uint use_op = use->Opcode();
if ((use_op == Op_LShiftI || use_op == Op_LShiftL)
&& use->in(2) == parent) { // is shift value (right-hand side of LShift)
for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) {
Node* and_node = use->fast_out(i);
uint and_node_op = and_node->Opcode();
if ((and_node_op == Op_AndI || and_node_op == Op_AndL)
&& and_node->bottom_type() != type(and_node)) {
worklist.push(and_node);
}
}
}

View File

@ -568,6 +568,8 @@ class PhaseCCP : public PhaseIterGVN {
// Non-recursive. Use analysis to transform single Node.
virtual Node *transform_once( Node *n );
void push_and(Unique_Node_List& worklist, const Node* parent, const Node* use) const;
public:
PhaseCCP( PhaseIterGVN *igvn ); // Compute conditional constants
NOT_PRODUCT( ~PhaseCCP(); )

View File

@ -285,9 +285,11 @@ public interface SegmentAllocator {
Objects.requireNonNull(array);
Objects.requireNonNull(elementLayout);
int size = Array.getLength(array);
MemorySegment addr = allocate(MemoryLayout.sequenceLayout(size, elementLayout));
MemorySegment.copy(heapSegmentFactory.apply(array), elementLayout, 0,
addr, elementLayout.withOrder(ByteOrder.nativeOrder()), 0, size);
MemorySegment addr = allocateArray(elementLayout, size);
if (size > 0) {
MemorySegment.copy(heapSegmentFactory.apply(array), elementLayout, 0,
addr, elementLayout.withOrder(ByteOrder.nativeOrder()), 0, size);
}
return addr;
}

View File

@ -3654,7 +3654,7 @@ public final class Files {
* if {@code options} contains an invalid combination of options
* @throws IOException
* if an I/O error occurs writing to or creating the file, or the
* text cannot be encoded using the specified charset
* text cannot be encoded using UTF-8
* @throws UnsupportedOperationException
* if an unsupported option is specified
* @throws SecurityException

View File

@ -59,6 +59,68 @@
* {@code jdk.zipfs} module, must be available if the compiler is to be able
* to read JAR files.
*
* <h3>SuppressWarnings</h3>
*
* JLS {@jls 9.6.4.5} specifies a number of strings that can be used to
* suppress warnings that may be generated by a Java compiler.
*
* In addition, <em>javac</em> also supports other strings that can be used
* to suppress other kinds of warnings. The following table lists all the
* strings that can be used with {@code @SuppressWarnings}.
*
* <table class="striped">
* <caption>Strings supported by {@code SuppressWarnings}</caption>
* <thead>
* <tr><th>String<th>Suppress Warnings About ...
* </thead>
* <tbody>
* <tr><th scope="row">{@code auxiliaryclass} <td>an auxiliary class that is hidden in a source file, and is used
* from other files
* <tr><th scope="row">{@code cast} <td>use of unnecessary casts
* <tr><th scope="row">{@code classfile} <td>issues related to classfile contents
* <tr><th scope="row">{@code deprecation} <td>use of deprecated items
* <tr><th scope="row">{@code dep-ann} <td>items marked as deprecated in a documentation comment but not
* using the {@code @Deprecated} annotation
* <tr><th scope="row">{@code divzero} <td>division by constant integer {@code 0}
* <tr><th scope="row">{@code empty} <td>empty statement after {@code if}
* <tr><th scope="row">{@code exports} <td>issues regarding module exports
* <tr><th scope="row">{@code fallthrough} <td>falling through from one case of a {@code switch} statement to
* the next
* <tr><th scope="row">{@code finally} <td>{@code finally} clauses that do not terminate normally
* <tr><th scope="row">{@code missing-explicit-ctor} <td>missing explicit constructors in public and protected classes
* in exported packages
* <tr><th scope="row">{@code module} <td>module system related issues
* <tr><th scope="row">{@code opens} <td>issues regarding module opens
* <tr><th scope="row">{@code overloads} <td>issues regarding method overloads
* <tr><th scope="row">{@code overrides} <td>issues regarding method overrides
* <tr><th scope="row">{@code path} <td>invalid path elements on the command line
* <tr><th scope="row">{@code preview} <td>use of preview language features
* <tr><th scope="row">{@code rawtypes} <td>use of raw types
* <tr><th scope="row">{@code removal} <td>use of API that has been marked for removal
* <tr><th scope="row">{@code requires-automatic} <td>use of automatic modules in the {@code requires} clauses
* <tr><th scope="row">{@code requires-transitive-automatic} <td>automatic modules in {@code requires transitive}
* <tr><th scope="row">{@code serial} <td>{@link java.base/java.io.Serializable Serializable} classes
* that do not have a {@code serialVersionUID} field, or other
* suspect declarations in {@code Serializable} and
* {@link java.base/java.io.Externalizable Externalizable} classes
* and interfaces
* <tr><th scope="row">{@code static} <td>accessing a static member using an instance
* <tr><th scope="row">{@code strictfp} <td>unnecessary use of the {@code strictfp} modifier
* <tr><th scope="row">{@code synchronization} <td>synchronization attempts on instances of value-based classes
* <tr><th scope="row">{@code text-blocks} <td>inconsistent white space characters in text block indentation
* <tr><th scope="row">{@code try} <td>issues relating to use of {@code try} blocks
* (that is, try-with-resources)
* <tr><th scope="row">{@code unchecked} <td>unchecked operations
* <tr><th scope="row">{@code varargs} <td>potentially unsafe vararg methods
* <tr><th scope="row">{@code doclint:accessibility} <td>accessibility issues found in documentation comments
* <tr><th scope="row">{@code doclint:all} <td>all issues found in documentation comments
* <tr><th scope="row">{@code doclint:html} <td>HTML issues found in documentation comments
* <tr><th scope="row">{@code doclint:missing} <td>missing items in documentation comments
* <tr><th scope="row">{@code doclint:reference} <td>reference issues found in documentation comments
* <tr><th scope="row">{@code doclint:syntax} <td>syntax issues found in documentation comments
* </tbody>
* </table>
*
* @toolGuide javac
*
* @provides java.util.spi.ToolProvider

View File

@ -691,7 +691,7 @@ Enables or disables specific groups of checks in documentation comments.
.PP
\f[I]group\f[R] can have one of the following values:
\f[CB]accessibility\f[R], \f[CB]html\f[R], \f[CB]missing\f[R],
\f[CB]reference\f[R], \f[CB]syntax\f[R]
\f[CB]reference\f[R], \f[CB]syntax\f[R].
.PP
The variable \f[I]access\f[R] specifies the minimum visibility level of
classes and members that the \f[CB]\-Xdoclint\f[R] option checks.
@ -701,6 +701,11 @@ visible): \f[CB]public\f[R], \f[CB]protected\f[R], \f[CB]package\f[R],
.PP
The default \f[I]access\f[R] level is \f[CB]private\f[R].
.PP
When prefixed by \f[CB]doclint:\f[R], the \f[I]group\f[R] names and
\f[CB]all\f[R] can be used with \f[CB]\@SuppressWarnings\f[R] to suppress
warnings about documentation comments in parts of the code being
compiled.
.PP
For more information about these groups of checks, see the
\f[B]DocLint\f[R] section of the \f[CB]javadoc\f[R] command documentation.
The \f[CB]\-Xdoclint\f[R] option is disabled by default in the
@ -838,6 +843,10 @@ methods.
.IP \[bu] 2
\f[CB]none\f[R]: Disables all warnings.
.PP
With the exception of \f[CB]all\f[R] and \f[CB]none\f[R], the keys can be
used with the \f[CB]\@SuppressWarnings\f[R] annotation to suppress
warnings in a part of the source code being compiled.
.PP
See \f[B]Examples of Using \-Xlint keys\f[R].
.RE
.TP

View File

@ -26,7 +26,6 @@
package jdk.javadoc.internal.doclets.formats.html;
import java.util.Collection;
import java.util.Set;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.PackageElement;
@ -97,20 +96,16 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
}
@Override
public void addLinkToPackageContent(PackageElement pkg,
Set<PackageElement> printedPackageHeaders, Content content) {
public void addLinkToPackageContent(String abbrevPackageName, Content content) {
//add link to summary
Content link;
if (pkg.isUnnamed()) {
if (abbrevPackageName.isEmpty()) {
link = links.createLink(HtmlIds.UNNAMED_PACKAGE_ANCHOR,
contents.defaultPackageLabel, "");
} else {
String parsedPackageName = utils.parsePackageName(pkg);
Content packageNameContent = Text.of(parsedPackageName + ".*");
link = links.createLink(DocLink.fragment(parsedPackageName),
Content packageNameContent = Text.of(abbrevPackageName + ".*");
link = links.createLink(DocLink.fragment(abbrevPackageName),
packageNameContent, "");
PackageElement abbrevPkg = configuration.workArounds.getAbbreviatedPackageElement(pkg);
printedPackageHeaders.add(abbrevPkg);
}
content.add(HtmlTree.LI(link));
}
@ -136,26 +131,25 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
}
@Override
public void addPackageName(PackageElement pkg, Content toContent, boolean first) {
Content pkgNameContent;
public void addPackageGroup(String abbrevPackageName, Content toContent) {
Content headingContent;
HtmlId anchorName;
if (!first) {
toContent.add(summarySection);
}
if (pkg.isUnnamed()) {
if (abbrevPackageName.isEmpty()) {
anchorName = HtmlIds.UNNAMED_PACKAGE_ANCHOR;
pkgNameContent = contents.defaultPackageLabel;
headingContent = contents.defaultPackageLabel;
} else {
String parsedPackageName = utils.parsePackageName(pkg);
anchorName = htmlIds.forPackage(pkg);
pkgNameContent = getPackageLabel(parsedPackageName);
anchorName = htmlIds.forPackageName(abbrevPackageName);
headingContent = new ContentBuilder(
getPackageLabel(abbrevPackageName),
Text.of(".*"));
}
var headingContent = Text.of(".*");
var heading = HtmlTree.HEADING_TITLE(Headings.ConstantsSummary.PACKAGE_HEADING,
pkgNameContent);
heading.add(headingContent);
var heading = HtmlTree.HEADING_TITLE(
Headings.ConstantsSummary.PACKAGE_HEADING,
headingContent);
summarySection = HtmlTree.SECTION(HtmlStyle.constantsSummary, heading)
.setId(anchorName);
toContent.add(summarySection);
}
@Override
@ -175,7 +169,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
currentTypeElement = typeElement;
//generate links backward only to public classes.
Content classlink = (utils.isPublic(typeElement) || utils.isProtected(typeElement)) ?
Content classLink = (utils.isPublic(typeElement) || utils.isProtected(typeElement)) ?
getLink(new HtmlLinkInfo(configuration,
HtmlLinkInfo.Kind.CONSTANT_SUMMARY, typeElement)) :
Text.of(utils.getFullyQualifiedName(typeElement));
@ -186,7 +180,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
caption.add(enclosingPackage.getQualifiedName());
caption.add(".");
}
caption.add(classlink);
caption.add(classLink);
Table table = new Table(HtmlStyle.summaryTable)
.setCaption(caption)
@ -245,9 +239,6 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
@Override
public void addConstantSummaries(Content content) {
if (summarySection != null) {
content.add(summarySection);
}
bodyContents.addMainContent(content);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -134,6 +134,19 @@ public class HtmlIds {
: HtmlId.of(element.getQualifiedName().toString());
}
/**
* Returns an id for a package name.
*
* @param pkgName the package name
*
* @return the id
*/
HtmlId forPackageName(String pkgName) {
return pkgName.isEmpty()
? UNNAMED_PACKAGE_ANCHOR
: HtmlId.of(pkgName);
}
/**
* Returns an id for a class or interface.
*

View File

@ -55,13 +55,10 @@ public interface ConstantsSummaryWriter {
/**
* Adds the given package name link to the constant content list.
*
* @param pkg the {@link PackageElement} to index.
* @param writtenPackageHeaders the set of package headers that have already
* been indexed, we want to index utmost once.
* @param content the content to which the link will be added
* @param abbrevPackageName the abbreviated package name
* @param content the content to which the link will be added
*/
void addLinkToPackageContent(PackageElement pkg, Set<PackageElement> writtenPackageHeaders,
Content content);
void addLinkToPackageContent(String abbrevPackageName, Content content);
/**
* Add the content list to the documentation.
@ -78,17 +75,12 @@ public interface ConstantsSummaryWriter {
Content getConstantSummaries();
/**
* Adds the given package name.
* Adds a header for the given abbreviated package name.
*
* @param pkg the parsed package name. We only Write the
* first 2 directory levels of the package
* name. For example, java.lang.ref would be
* indexed as java.lang.*.
* @param abbrevPackageName the abbreviated package name
* @param toContent the summaries documentation
* @param first true if the first package is listed
* be written
*/
void addPackageName(PackageElement pkg, Content toContent, boolean first);
void addPackageGroup(String abbrevPackageName, Content toContent);
/**
* Get the class summary header for the constants summary.

View File

@ -500,22 +500,6 @@ public class WorkArounds {
}
}
// TODO: we need to eliminate this, as it is hacky.
/**
* Returns a representation of the package truncated to two levels.
* For instance if the given package represents foo.bar.baz will return
* a representation of foo.bar
* @param pkg the PackageElement
* @return an abbreviated PackageElement
*/
public PackageElement getAbbreviatedPackageElement(PackageElement pkg) {
String parsedPackageName = utils.parsePackageName(pkg);
ModuleElement encl = (ModuleElement) pkg.getEnclosingElement();
return encl == null
? utils.elementUtils.getPackageElement(parsedPackageName)
: ((JavacElements) utils.elementUtils).getPackageElement(encl, parsedPackageName);
}
public boolean isPreviewAPI(Element el) {
Symbol sym = (Symbol) el;
return (sym.flags() & Flags.PREVIEW_API) != 0;

View File

@ -45,10 +45,10 @@ import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.
public class ConstantsSummaryBuilder extends AbstractBuilder {
/**
* The maximum number of package directories shown in the constant
* value index.
* The maximum number of package directories shown in the headings of
* the constant values contents list and headings.
*/
public static final int MAX_CONSTANT_VALUE_INDEX_LENGTH = 2;
private static final int MAX_CONSTANT_VALUE_INDEX_LENGTH = 2;
/**
* The writer used to write the results.
@ -56,14 +56,14 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
protected ConstantsSummaryWriter writer;
/**
* The set of TypeElements that have constant fields.
* The set of type elements that have constant fields.
*/
protected final Set<TypeElement> typeElementsWithConstFields;
/**
* The set of printed package headers.
* The set of package-group headings.
*/
protected final Set<PackageElement> printedPackageHeaders;
protected final Set<String> packageGroupHeadings;
/**
* The current package being documented.
@ -76,25 +76,20 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
private TypeElement currentClass;
/**
* True if first package is listed.
*/
private boolean first = true;
/**
* Construct a new ConstantsSummaryBuilder.
* Constructs a new {@code ConstantsSummaryBuilder}.
*
* @param context the build context.
* @param context the build context
*/
private ConstantsSummaryBuilder(Context context) {
super(context);
this.typeElementsWithConstFields = new HashSet<>();
this.printedPackageHeaders = new TreeSet<>(utils.comparators.makePackageComparator());
this.packageGroupHeadings = new TreeSet<>(utils::compareStrings);
}
/**
* Construct a ConstantsSummaryBuilder.
* Constructs a {@code ConstantsSummaryBuilder}.
*
* @param context the build context.
* @param context the build context
* @return the new ConstantsSummaryBuilder
*/
public static ConstantsSummaryBuilder getInstance(Context context) {
@ -117,7 +112,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
}
/**
* Build the constant summary.
* Builds the constant summary page.
*
* @throws DocletException if there is a problem while building the documentation
*/
@ -132,56 +127,55 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
}
/**
* Build the list of packages.
* Builds the list of contents for the groups of packages appearing in the constants summary page.
*/
protected void buildContents() {
Content contentList = writer.getContentsHeader();
printedPackageHeaders.clear();
packageGroupHeadings.clear();
for (PackageElement pkg : configuration.packages) {
if (hasConstantField(pkg) && !hasPrintedPackageIndex(pkg)) {
writer.addLinkToPackageContent(pkg, printedPackageHeaders, contentList);
String abbrevPackageName = getAbbrevPackageName(pkg);
if (hasConstantField(pkg) && !packageGroupHeadings.contains(abbrevPackageName)) {
writer.addLinkToPackageContent(abbrevPackageName, contentList);
packageGroupHeadings.add(abbrevPackageName);
}
}
writer.addContentsList(contentList);
}
/**
* Build the summary for each documented package.
* Builds the summary for each documented package.
*
* @throws DocletException if there is a problem while building the documentation
*/
protected void buildConstantSummaries() throws DocletException {
printedPackageHeaders.clear();
packageGroupHeadings.clear();
Content summaries = writer.getConstantSummaries();
for (PackageElement aPackage : configuration.packages) {
if (hasConstantField(aPackage)) {
currentPackage = aPackage;
//Build the documentation for the current package.
buildPackageHeader(summaries);
buildClassConstantSummary();
first = false;
}
}
writer.addConstantSummaries(summaries);
}
/**
* Build the header for the given package.
* Builds the header for the given package.
*
* @param target the content to which the package header will be added
*/
protected void buildPackageHeader(Content target) {
PackageElement abbrevPkg = configuration.workArounds.getAbbreviatedPackageElement(currentPackage);
if (!printedPackageHeaders.contains(abbrevPkg)) {
writer.addPackageName(currentPackage, target, first);
printedPackageHeaders.add(abbrevPkg);
String abbrevPkgName = getAbbrevPackageName(currentPackage);
if (!packageGroupHeadings.contains(abbrevPkgName)) {
writer.addPackageGroup(abbrevPkgName, target);
packageGroupHeadings.add(abbrevPkgName);
}
}
/**
* Build the summary for the current class.
* Builds the summary for the current class.
*
* @throws DocletException if there is a problem while building the documentation
*/
@ -206,20 +200,18 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
}
/**
* Build the summary of constant members in the class.
* Builds the summary of constant members in the class.
*
* @param target the content to which the constant members table
* will be added
* @param target the content to which the table of constant members will be added
*/
protected void buildConstantMembers(Content target) {
new ConstantFieldBuilder(currentClass).buildMembersSummary(target);
}
/**
* Return true if the given package has constant fields to document.
* {@return true if the given package has constant fields to document}
*
* @param pkg the package being checked.
* @return true if the given package has constant fields to document.
* @param pkg the package to be checked
*/
private boolean hasConstantField(PackageElement pkg) {
SortedSet<TypeElement> classes = !pkg.isUnnamed()
@ -235,10 +227,9 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
}
/**
* Return true if the given class has constant fields to document.
* {@return true if the given class has constant fields to document}
*
* @param typeElement the class being checked.
* @return true if the given package has constant fields to document.
* @param typeElement the class to be checked
*/
private boolean hasConstantField (TypeElement typeElement) {
VisibleMemberTable vmt = configuration.getVisibleMemberTable(typeElement);
@ -254,33 +245,36 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
}
/**
* Return true if the given package name has been printed. Also
* return true if the root of this package has been printed.
* {@return the abbreviated name for a package, containing the leading segments of the name}
*
* @param pkg the name of the package to check.
* @param pkg the package
*/
private boolean hasPrintedPackageIndex(PackageElement pkg) {
for (PackageElement printedPkg : printedPackageHeaders) {
if (utils.getPackageName(pkg).startsWith(utils.parsePackageName(printedPkg))) {
return true;
}
public String getAbbrevPackageName(PackageElement pkg) {
if (pkg.isUnnamed()) {
return "";
}
return false;
String packageName = utils.getPackageName(pkg);
int index = -1;
for (int j = 0; j < MAX_CONSTANT_VALUE_INDEX_LENGTH; j++) {
index = packageName.indexOf(".", index + 1);
}
return index == -1 ? packageName : packageName.substring(0, index);
}
/**
* Print the table of constants.
* Builder for the table of fields with constant values.
*/
private class ConstantFieldBuilder {
/**
* The typeElement that we are examining constants for.
* The type element that we are examining constants for.
*/
protected TypeElement typeElement;
/**
* Construct a ConstantFieldSubWriter.
* @param typeElement the typeElement that we are examining constants for.
* Constructs a {@code ConstantFieldBuilder}.
* @param typeElement the type element that we are examining constants for
*/
public ConstantFieldBuilder(TypeElement typeElement) {
this.typeElement = typeElement;
@ -289,8 +283,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
/**
* Builds the table of constants for a given class.
*
* @param target the content to which the class constants table
* will be added
* @param target the content to which the table of class constants will be added
*/
protected void buildMembersSummary(Content target) {
SortedSet<VariableElement> members = members();
@ -300,8 +293,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
}
/**
* Returns a set of visible constant fields for the given type.
* @return the set of visible constant fields for the given type.
* {@return a set of visible constant fields for the given type}
*/
protected SortedSet<VariableElement> members() {
VisibleMemberTable vmt = configuration.getVisibleMemberTable(typeElement);

View File

@ -38,9 +38,8 @@ import java.util.EnumSet;
*/
public class SystemPropertyTaglet extends BaseTaglet {
SystemPropertyTaglet(){
super(DocTree.Kind.SYSTEM_PROPERTY, true, EnumSet.of(Location.CONSTRUCTOR, Location.METHOD, Location.FIELD,
Location.PACKAGE, Location.MODULE, Location.TYPE));
SystemPropertyTaglet() {
super(DocTree.Kind.SYSTEM_PROPERTY, true, EnumSet.allOf(Location.class));
}
@Override

View File

@ -124,7 +124,6 @@ import static javax.lang.model.element.ElementKind.*;
import static javax.lang.model.type.TypeKind.*;
import static com.sun.source.doctree.DocTree.Kind.*;
import static jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.MAX_CONSTANT_VALUE_INDEX_LENGTH;
/**
* Utilities Class for Doclets.
@ -905,22 +904,6 @@ public class Utils {
return searchResult;
}
/**
* Parse the package name. We only want to display package name up to
* 2 levels.
*/
public String parsePackageName(PackageElement p) {
String pkgname = p.isUnnamed() ? "" : getPackageName(p);
int index = -1;
for (int j = 0; j < MAX_CONSTANT_VALUE_INDEX_LENGTH; j++) {
index = pkgname.indexOf(".", index + 1);
}
if (index != -1) {
pkgname = pkgname.substring(0, index);
}
return pkgname;
}
/**
* Given an annotation, return true if it should be documented and false
* otherwise.

View File

@ -33,6 +33,7 @@ import java.util.Deque;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -47,6 +48,7 @@ import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Name;
import javax.lang.model.element.NestingKind;
import javax.lang.model.element.RecordComponentElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeKind;
@ -244,8 +246,10 @@ public class Checker extends DocTreePathScanner<Void, Void> {
} else if (isExecutable()) {
if (!isOverridingMethod) {
ExecutableElement ee = (ExecutableElement) env.currElement;
checkParamsDocumented(ee.getTypeParameters());
checkParamsDocumented(ee.getParameters());
if (!isCanonicalRecordConstructor(ee)) {
checkParamsDocumented(ee.getTypeParameters());
checkParamsDocumented(ee.getParameters());
}
switch (ee.getReturnType().getKind()) {
case VOID, NONE -> { }
default -> {
@ -263,6 +267,31 @@ public class Checker extends DocTreePathScanner<Void, Void> {
return null;
}
private boolean isCanonicalRecordConstructor(ExecutableElement ee) {
TypeElement te = (TypeElement) ee.getEnclosingElement();
if (te.getKind() != ElementKind.RECORD) {
return false;
}
List<? extends RecordComponentElement> stateComps = te.getRecordComponents();
List<? extends VariableElement> params = ee.getParameters();
if (stateComps.size() != params.size()) {
return false;
}
Iterator<? extends RecordComponentElement> stateIter = stateComps.iterator();
Iterator<? extends VariableElement> paramIter = params.iterator();
while (paramIter.hasNext() && stateIter.hasNext()) {
VariableElement param = paramIter.next();
RecordComponentElement comp = stateIter.next();
if (!Objects.equals(param.getSimpleName(), comp.getSimpleName())
|| !env.types.isSameType(param.asType(), comp.asType())) {
return false;
}
}
return true;
}
private void reportMissing(String code, Object... args) {
env.messages.report(MISSING, Kind.WARNING, env.currPath.getLeaf(), code, args);
}

View File

@ -96,6 +96,8 @@ vmTestbase/nsk/jdb/repeat/repeat001/repeat001.java
####
## NSK JDI tests failing with wrapper
vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011/TestDescription.java 8282379 generic-all
####
## The test expects an NPE to be uncaught, but nsk.share.MainWrapper
## introduces exception handlers.

View File

@ -0,0 +1,90 @@
/*
* Copyright (c) 2022, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8288683
* @library /test/lib
* @summary Test that And nodes are added to the CCP worklist if they have an LShift as input.
* @run main/othervm -Xbatch compiler.c2.TestAndShiftZeroCCP
*/
package compiler.c2;
import jdk.test.lib.Asserts;
public class TestAndShiftZeroCCP {
static int iFld = 0xfffff;
public static void main(String[] strArr) {
for (int i = 0; i < 10000; i++) {
Asserts.assertEQ(testAndI(), 224);
Asserts.assertEQ(testAndL(), 224L);
Asserts.assertEQ(testAndLConvI2L(), 224L);
}
}
static int testAndI() {
int x = 10;
int y = iFld;
int z = 3;
int q;
for (int i = 62; i < 70; ++i) {
q = y << i;
for (int j = 0; j < 8; j++) {
z += i;
}
z = q & 0xff;
}
return z;
}
static long testAndL() {
long x = 10;
long y = iFld;
long z = 3;
long q;
for (int i = 62; i < 70; ++i) {
q = y << i;
for (int j = 0; j < 8; j++) {
z += i;
}
z = q & 0xff;
}
return z;
}
static long testAndLConvI2L() {
long x = 10;
long y = iFld;
long z = 3;
long q;
for (int i = 62; i < 70; ++i) {
q = y << i;
for (int j = 0; j < 8; j++) {
z += i;
}
z = q & 0xff;
}
return z;
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2022, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8288445
* @summary Test shift by 0
* @run main/othervm -Xbatch -XX:-TieredCompilation
* compiler.codegen.ShiftByZero
*/
package compiler.codegen;
public class ShiftByZero {
public static final int N = 64;
public static int[] i32 = new int[N];
public static void bMeth() {
int shift = i32[0];
// This loop is to confuse the optimizer, so that "shift" is
// optimized to 0 only after loop vectorization.
for (int i8 = 279; i8 > 1; --i8) {
shift <<= 6;
}
// low 6 bits of shift are 0, so shift can be
// simplified to constant 0
{
for (int i = 0; i < N; ++i) {
i32[i] += i32[i] >>= shift;
}
for (int i = 0; i < N; ++i) {
i32[i] += i32[i] >>>= shift;
}
for (int i = 0; i < N; ++i) {
i32[i] >>>= shift;
}
for (int i = 0; i < N; ++i) {
i32[i] >>= shift;
}
for (int i = 0; i < N; ++i) {
i32[i] <<= shift;
}
}
}
public static void main(String[] strArr) {
for (int i = 0; i < 20_000; i++) {
bMeth();
}
}
}

View File

@ -30,4 +30,4 @@
java/lang/invoke/MethodHandles/CatchExceptionTest.java 8146623 generic-all
java/lang/ref/ReferenceEnqueue.java 8284236 generic-all
java/lang/ref/OOMEInReferenceHandler.java 8066859 generic-all
java/lang/reflect/callerCache/ReflectionCallerCacheTest.java 8288286 macosx-x64,windows-x64
java/lang/reflect/callerCache/ReflectionCallerCacheTest.java 8288286 generic-all

View File

@ -496,6 +496,7 @@ java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-
java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-x64
java/lang/invoke/RicochetTest.java 8251969 generic-all
java/lang/CompressExpandTest.java 8287851 generic-all
java/lang/ref/OOMEInReferenceHandler.java 8066859 generic-all
############################################################################
@ -752,6 +753,7 @@ jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-
jdk/jfr/startupargs/TestStartName.java 8214685 windows-x64
jdk/jfr/startupargs/TestStartDuration.java 8214685 windows-x64
jdk/jfr/jvm/TestWaste.java 8282427 generic-all
jdk/jfr/api/consumer/recordingstream/TestOnEvent.java 8255404 linux-x64
############################################################################

View File

@ -43,6 +43,7 @@ import java.nio.LongBuffer;
import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.IntStream;
@ -159,6 +160,32 @@ public class TestSegmentAllocators {
allocator.allocate(1, 3);
}
@Test
public void testArrayAllocateDelegation() {
AtomicInteger calls = new AtomicInteger();
SegmentAllocator allocator = new SegmentAllocator() {
@Override
public MemorySegment allocate(long bytesSize, long bytesAlignment) {
return null;
}
@Override
public MemorySegment allocateArray(MemoryLayout elementLayout, long count) {
calls.incrementAndGet();
return null;
};
};
allocator.allocateArray(ValueLayout.JAVA_BYTE);
allocator.allocateArray(ValueLayout.JAVA_SHORT);
allocator.allocateArray(ValueLayout.JAVA_CHAR);
allocator.allocateArray(ValueLayout.JAVA_INT);
allocator.allocateArray(ValueLayout.JAVA_FLOAT);
allocator.allocateArray(ValueLayout.JAVA_LONG);
allocator.allocateArray(ValueLayout.JAVA_DOUBLE);
assertEquals(calls.get(), 7);
}
@Test(dataProvider = "arrayAllocations")
public <Z> void testArray(AllocationFactory allocationFactory, ValueLayout layout, AllocationFunction<Object, ValueLayout> allocationFunction, ToArrayHelper<Z> arrayHelper) {
Z arr = arrayHelper.array();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, 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
@ -23,16 +23,18 @@
/*
* @test
* @bug 4681599
* @summary Test to make sure that constant values page does not get
* generated when doclet has nothing to document.
* @library ../../lib
* @bug 4681599 8288058
* @summary Tests for the Constant Values page.
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
* @build javadoc.tester.*
* @build toolbox.ToolBox javadoc.tester.*
* @run main TestConstantValuesPage
*/
import java.nio.file.Path;
import javadoc.tester.JavadocTester;
import toolbox.ToolBox;
public class TestConstantValuesPage extends JavadocTester {
@ -41,8 +43,14 @@ public class TestConstantValuesPage extends JavadocTester {
tester.runTests();
}
ToolBox tb = new ToolBox();
/**
* Test to make sure that constant values page does not get
* generated when doclet has nothing to document.
*/
@Test
public void test() {
public void testNoPage() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"foo");
@ -50,5 +58,200 @@ public class TestConstantValuesPage extends JavadocTester {
checkOutput(Output.OUT, false,
"constant-values.html...");
checkFiles(false, "constant-values.html");
}
/**
* Tests the "contents" list for a group of named packages in the unnamed module.
*/
@Test
public void testIndexNamed(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"""
package p1.p2a.p3a;
public class CA {
public static final int ia = 1;
public static final String sa = "string";
}
""",
"""
package p1.p2a.p3b;
public class CB {
public static final int ib = 1;
public static final String sb = "string";
}
""",
"""
package p1.p2b.p3c;
public class CC {
public static final int ic = 1;
public static final String sc = "string";
}
""",
"""
package p2;
public class CD {
public static final int id = 1;
public static final String sd = "string";
}
""");
setAutomaticCheckLinks(true); // ensure link-checking enabled for this test
javadoc("-d", base.resolve("api").toString(),
"-Xdoclint:none",
"-sourcepath", src.toString(),
"p1.p2a.p3a", "p1.p2a.p3b", "p1.p2b.p3c");
checkExit(Exit.OK);
checkOutput("constant-values.html", true,
"""
<section class="packages">
<h2 title="Contents">Contents</h2>
<ul>
<li><a href="#p1.p2a">p1.p2a.*</a></li>
<li><a href="#p1.p2b">p1.p2b.*</a></li>
</ul>
</section>""");
}
/**
* Tests the "contents" list for the unnamed package in the unnamed module.
*/
@Test
public void testIndexUnnamed(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"""
public class C {
public static final int ia = 1;
public static final String sa = "string";
}
""");
setAutomaticCheckLinks(true); // ensure link-checking enabled for this test
javadoc("-d", base.resolve("api").toString(),
"-Xdoclint:none",
"-sourcepath", src.toString(),
src.resolve("C.java").toString());
checkExit(Exit.OK);
checkOutput("constant-values.html", true,
"""
<section class="packages">
<h2 title="Contents">Contents</h2>
<ul>
<li><a href="#unnamed-package">Unnamed Package</a></li>
</ul>
</section>""");
}
/**
* Tests the "contents" list for a group of named and unnamed packages in the unnamed module.
*/
@Test
public void testMixed(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"""
package p1.p2a.p3a;
public class CA {
public static final int ia = 1;
public static final String sa = "string";
}
""",
"""
public class C {
public static final int ia = 1;
public static final String sa = "string";
}
""");
setAutomaticCheckLinks(true); // ensure link-checking enabled for this test
javadoc("-d", base.resolve("api").toString(),
"-Xdoclint:none",
"-sourcepath", src.toString(),
"p1.p2a.p3a", src.resolve("C.java").toString());
checkExit(Exit.OK);
checkOutput("constant-values.html", true,
"""
<section class="packages">
<h2 title="Contents">Contents</h2>
<ul>
<li><a href="#unnamed-package">Unnamed Package</a></li>
<li><a href="#p1.p2a">p1.p2a.*</a></li>
</ul>
</section>""");
}
/**
* Tests the "contents" list for a group of named packages in named modules.
*/
@Test
public void testModules(Path base) throws Exception {
Path src = base.resolve("src");
Path src_mA = src.resolve("mA");
tb.writeJavaFiles(src_mA,
"""
module mA {
exports p.a;
exports p.q.r1;
}
""",
"""
package p.a;
public class CA {
public static final int iA = 1;
}
""",
"""
package p.q.r1;
public class C1 {
public static final int i1 = 1;
}
""");
Path src_mB = src.resolve("mB");
tb.writeJavaFiles(src_mB,
"""
module mB {
exports p.b;
exports p.q.r2;
}
""",
"""
package p.b;
public class CB {
public static final int iB = 1;
}
""",
"""
package p.q.r2;
public class C2 {
public static final int i2 = 1;
}
""");
setAutomaticCheckLinks(true); // ensure link-checking enabled for this test
javadoc("-d", base.resolve("api").toString(),
"-Xdoclint:none",
"--module-source-path", src.toString(),
"--module", "mA,mB");
checkExit(Exit.OK);
checkOutput("constant-values.html", true,
"""
<section class="packages">
<h2 title="Contents">Contents</h2>
<ul>
<li><a href="#p.a">p.a.*</a></li>
<li><a href="#p.b">p.b.*</a></li>
<li><a href="#p.q">p.q.*</a></li>
</ul>
</section>""");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, 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
@ -197,7 +197,7 @@ public class TestHtmlVersion extends JavadocTester {
""",
"""
<section class="constants-summary" id="pkg">
<h2 title="pkg">pkg.*</h2>
<h2 title="pkg.*">pkg.*</h2>
""",
"""
<footer role="contentinfo">""",

View File

@ -22,7 +22,7 @@
@since: block overview module package type constructor method field ...... ........
{@snippet}: ..... overview module package type constructor method field inline ........
{@summary}: ..... overview module package type constructor method field inline ........
{@systemProperty}: ..... ........ module package type constructor method field inline ........
{@systemProperty}: ..... overview module package type constructor method field inline ........
@throws: block ........ ...... ....... .... constructor method ..... ...... ........
@treatAsPrivate: block ........ ...... ....... type ........... method field ...... ........
@uses: block ........ module ....... .... ........... ...... ..... ...... ........

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2022, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test /nodynamiccopyright/
* @bug 8275784
* @summary Bogus warning generated for record with compact constructor
* @modules jdk.javadoc/jdk.javadoc.internal.doclint
* @build DocLintTester
* @run main DocLintTester -Xmsgs:all RecordCompactConstructorTest.java
*/
/**
* Comment.
* @param a aaa
* @param b bbb
* @param c ccc
*/
public record RecordCompactConstructorTest(int a, int b, int c) {
/** Compact constructor. */
public RecordCompactConstructorTest { }
}