Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sspitsyn committed Mar 1, 2024
2 parents 7244d34 + e85265a commit f1a97f5
Show file tree
Hide file tree
Showing 777 changed files with 1,841 additions and 1,802 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jint ParallelScavengeHeap::initialize() {
_gc_policy_counters =
new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 2, _size_policy);

if (!PSParallelCompact::initialize()) {
if (!PSParallelCompact::initialize_aux_data()) {
return JNI_ENOMEM;
}

Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/share/gc/parallel/psOldGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ void PSOldGen::initialize_performance_counters(const char* perf_data_name, int l
_object_space, _gen_counters);
}

// Assume that the generation has been allocated if its
// reserved size is not 0.
bool PSOldGen::is_allocated() {
return virtual_space()->reserved_size() != 0;
}

size_t PSOldGen::num_iterable_blocks() const {
return (object_space()->used_in_bytes() + IterateBlockSize - 1) / IterateBlockSize;
}
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/gc/parallel/psOldGen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ class PSOldGen : public CHeapObj<mtGC> {
ObjectStartArray* start_array() { return &_start_array; }
PSVirtualSpace* virtual_space() const { return _virtual_space;}

// Has the generation been successfully allocated?
bool is_allocated();

// Size info
size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); }
size_t used_in_bytes() const { return object_space()->used_in_bytes(); }
Expand Down
153 changes: 2 additions & 151 deletions src/hotspot/share/gc/parallel/psParallelCompact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,14 +862,10 @@ void PSParallelCompact::post_initialize() {
ParCompactionManager::initialize(mark_bitmap());
}

bool PSParallelCompact::initialize() {
bool PSParallelCompact::initialize_aux_data() {
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
MemRegion mr = heap->reserved_region();

// Was the old gen get allocated successfully?
if (!heap->old_gen()->is_allocated()) {
return false;
}
assert(mr.byte_size() != 0, "heap should be reserved");

initialize_space_info();
initialize_dead_wood_limiter();
Expand Down Expand Up @@ -1048,142 +1044,6 @@ void PSParallelCompact::post_compact()
Universe::heap()->record_whole_heap_examined_timestamp();
}

HeapWord*
PSParallelCompact::compute_dense_prefix_via_density(const SpaceId id,
bool maximum_compaction)
{
const size_t region_size = ParallelCompactData::RegionSize;
const ParallelCompactData& sd = summary_data();

const MutableSpace* const space = _space_info[id].space();
HeapWord* const top_aligned_up = sd.region_align_up(space->top());
const RegionData* const beg_cp = sd.addr_to_region_ptr(space->bottom());
const RegionData* const end_cp = sd.addr_to_region_ptr(top_aligned_up);

// Skip full regions at the beginning of the space--they are necessarily part
// of the dense prefix.
size_t full_count = 0;
const RegionData* cp;
for (cp = beg_cp; cp < end_cp && cp->data_size() == region_size; ++cp) {
++full_count;
}

const uint total_invocations = ParallelScavengeHeap::heap()->total_full_collections();
assert(total_invocations >= _maximum_compaction_gc_num, "sanity");
const size_t gcs_since_max = total_invocations - _maximum_compaction_gc_num;
const bool interval_ended = gcs_since_max > HeapMaximumCompactionInterval;
if (maximum_compaction || cp == end_cp || interval_ended) {
_maximum_compaction_gc_num = total_invocations;
return sd.region_to_addr(cp);
}

HeapWord* const new_top = _space_info[id].new_top();
const size_t space_live = pointer_delta(new_top, space->bottom());
const size_t space_used = space->used_in_words();
const size_t space_capacity = space->capacity_in_words();

const double cur_density = double(space_live) / space_capacity;
const double deadwood_density =
(1.0 - cur_density) * (1.0 - cur_density) * cur_density * cur_density;
const size_t deadwood_goal = size_t(space_capacity * deadwood_density);

log_develop_debug(gc, compaction)(
"cur_dens=%5.3f dw_dens=%5.3f dw_goal=" SIZE_FORMAT,
cur_density, deadwood_density, deadwood_goal);
log_develop_debug(gc, compaction)(
"space_live=" SIZE_FORMAT " space_used=" SIZE_FORMAT " "
"space_cap=" SIZE_FORMAT,
space_live, space_used,
space_capacity);

// XXX - Use binary search?
HeapWord* dense_prefix = sd.region_to_addr(cp);
const RegionData* full_cp = cp;
const RegionData* const top_cp = sd.addr_to_region_ptr(space->top() - 1);
while (cp < end_cp) {
HeapWord* region_destination = cp->destination();
const size_t cur_deadwood = pointer_delta(dense_prefix, region_destination);

log_develop_trace(gc, compaction)(
"c#=" SIZE_FORMAT_W(4) " dst=" PTR_FORMAT " "
"dp=" PTR_FORMAT " cdw=" SIZE_FORMAT_W(8),
sd.region(cp), p2i(region_destination),
p2i(dense_prefix), cur_deadwood);

if (cur_deadwood >= deadwood_goal) {
// Found the region that has the correct amount of deadwood to the left.
// This typically occurs after crossing a fairly sparse set of regions, so
// iterate backwards over those sparse regions, looking for the region
// that has the lowest density of live objects 'to the right.'
size_t space_to_left = sd.region(cp) * region_size;
size_t live_to_left = space_to_left - cur_deadwood;
size_t space_to_right = space_capacity - space_to_left;
size_t live_to_right = space_live - live_to_left;
double density_to_right = double(live_to_right) / space_to_right;
while (cp > full_cp) {
--cp;
const size_t prev_region_live_to_right = live_to_right -
cp->data_size();
const size_t prev_region_space_to_right = space_to_right + region_size;
double prev_region_density_to_right =
double(prev_region_live_to_right) / prev_region_space_to_right;
if (density_to_right <= prev_region_density_to_right) {
return dense_prefix;
}

log_develop_trace(gc, compaction)(
"backing up from c=" SIZE_FORMAT_W(4) " d2r=%10.8f "
"pc_d2r=%10.8f",
sd.region(cp), density_to_right,
prev_region_density_to_right);

dense_prefix -= region_size;
live_to_right = prev_region_live_to_right;
space_to_right = prev_region_space_to_right;
density_to_right = prev_region_density_to_right;
}
return dense_prefix;
}

dense_prefix += region_size;
++cp;
}

return dense_prefix;
}

#ifndef PRODUCT
void PSParallelCompact::print_dense_prefix_stats(const char* const algorithm,
const SpaceId id,
const bool maximum_compaction,
HeapWord* const addr)
{
const size_t region_idx = summary_data().addr_to_region_idx(addr);
RegionData* const cp = summary_data().region(region_idx);
const MutableSpace* const space = _space_info[id].space();
HeapWord* const new_top = _space_info[id].new_top();

const size_t space_live = pointer_delta(new_top, space->bottom());
const size_t dead_to_left = pointer_delta(addr, cp->destination());
const size_t space_cap = space->capacity_in_words();
const double dead_to_left_pct = double(dead_to_left) / space_cap;
const size_t live_to_right = new_top - cp->destination();
const size_t dead_to_right = space->top() - addr - live_to_right;

log_develop_debug(gc, compaction)(
"%s=" PTR_FORMAT " dpc=" SIZE_FORMAT_W(5) " "
"spl=" SIZE_FORMAT " "
"d2l=" SIZE_FORMAT " d2l%%=%6.4f "
"d2r=" SIZE_FORMAT " l2r=" SIZE_FORMAT " "
"ratio=%10.8f",
algorithm, p2i(addr), region_idx,
space_live,
dead_to_left, dead_to_left_pct,
dead_to_right, live_to_right,
double(dead_to_right) / live_to_right);
}
#endif // #ifndef PRODUCT

// Return a fraction indicating how much of the generation can be treated as
// "dead wood" (i.e., not reclaimed). The function uses a normal distribution
// based on the density of live objects in the generation to determine a limit,
Expand Down Expand Up @@ -1511,15 +1371,6 @@ PSParallelCompact::summarize_space(SpaceId id, bool maximum_compaction)
HeapWord* dense_prefix_end = compute_dense_prefix(id, maximum_compaction);
_space_info[id].set_dense_prefix(dense_prefix_end);

#ifndef PRODUCT
if (log_is_enabled(Debug, gc, compaction)) {
print_dense_prefix_stats("ratio", id, maximum_compaction,
dense_prefix_end);
HeapWord* addr = compute_dense_prefix_via_density(id, maximum_compaction);
print_dense_prefix_stats("density", id, maximum_compaction, addr);
}
#endif // #ifndef PRODUCT

// Recompute the summary data, taking into account the dense prefix. If
// every last byte will be reclaimed, then the existing summary data which
// compacts everything can be left in place.
Expand Down
11 changes: 1 addition & 10 deletions src/hotspot/share/gc/parallel/psParallelCompact.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,11 +975,6 @@ class PSParallelCompact : AllStatic {
// Mark live objects
static void marking_phase(ParallelOldTracer *gc_tracer);

// Compute the dense prefix for the designated space. This is an experimental
// implementation currently not used in production.
static HeapWord* compute_dense_prefix_via_density(const SpaceId id,
bool maximum_compaction);

// Methods used to compute the dense prefix.

// Compute the value of the normal distribution at x = density. The mean and
Expand Down Expand Up @@ -1069,7 +1064,7 @@ class PSParallelCompact : AllStatic {
// allocations. This should be called during the VM initialization
// at a pointer where it would be appropriate to return a JNI_ENOMEM
// in the event of a failure.
static bool initialize();
static bool initialize_aux_data();

// Closure accessors
static BoolObjectClosure* is_alive_closure() { return &_is_alive_closure; }
Expand Down Expand Up @@ -1170,10 +1165,6 @@ class PSParallelCompact : AllStatic {
// Debugging support.
static const char* space_names[last_space_id];
static void print_region_ranges();
static void print_dense_prefix_stats(const char* const algorithm,
const SpaceId id,
const bool maximum_compaction,
HeapWord* const addr);
static void summary_phase_msg(SpaceId dst_space_id,
HeapWord* dst_beg, HeapWord* dst_end,
SpaceId src_space_id,
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/parallel/psScavenge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ class ScavengeRootsTask : public WorkerTask {
_active_workers(active_workers),
_is_old_gen_empty(old_gen->object_space()->is_empty()),
_terminator(active_workers, PSPromotionManager::vm_thread_promotion_manager()->stack_array_depth()) {
assert(_old_gen != nullptr, "Sanity");

if (!_is_old_gen_empty) {
PSCardTable* card_table = ParallelScavengeHeap::heap()->card_table();
card_table->pre_scavenge(active_workers);
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4879,6 +4879,7 @@ void Compile::add_coarsened_locks(GrowableArray<AbstractLockNode*>& locks) {
// Locking regions (BoxLock) could be Unbalanced here:
// - its coarsened locks were eliminated in earlier
// macro nodes elimination followed by loop unroll
// - it is OSR locking region (no Lock node)
// Preserve Unbalanced status in such cases.
if (!this_box->is_unbalanced()) {
this_box->set_coarsened();
Expand Down
80 changes: 37 additions & 43 deletions src/hotspot/share/opto/ifnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,63 +1031,57 @@ bool IfNode::fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* f
const TypeInt* type2 = filtered_int_type(igvn, n, fail);
if (type2 != nullptr) {
failtype = failtype->join(type2)->is_int();
if (failtype->_lo > failtype->_hi) {
if (failtype->empty()) {
// previous if determines the result of this if so
// replace Bool with constant
igvn->replace_input_of(this, 1, igvn->intcon(success->_con));
return true;
}
}
}
lo = nullptr;
hi = nullptr;
return false;
}

assert(lo != nullptr && hi != nullptr, "sanity");
Node* hook = new Node(lo); // Add a use to lo to prevent him from dying
// Merge the two compares into a single unsigned compare by building (CmpU (n - lo) (hi - lo))
Node* adjusted_val = igvn->transform(new SubINode(n, lo));
if (adjusted_lim == nullptr) {
adjusted_lim = igvn->transform(new SubINode(hi, lo));
}
hook->destruct(igvn);

if (lo && hi) {
Node* hook = new Node(1);
hook->init_req(0, lo); // Add a use to lo to prevent him from dying
// Merge the two compares into a single unsigned compare by building (CmpU (n - lo) (hi - lo))
Node* adjusted_val = igvn->transform(new SubINode(n, lo));
if (adjusted_lim == nullptr) {
adjusted_lim = igvn->transform(new SubINode(hi, lo));
if (igvn->type(adjusted_lim)->is_int()->_lo < 0 &&
!igvn->C->post_loop_opts_phase()) {
// If range check elimination applies to this comparison, it includes code to protect from overflows that may
// cause the main loop to be skipped entirely. Delay this transformation.
// Example:
// for (int i = 0; i < limit; i++) {
// if (i < max_jint && i > min_jint) {...
// }
// Comparisons folded as:
// i - min_jint - 1 <u -2
// when RC applies, main loop limit becomes:
// min(limit, max(-2 + min_jint + 1, min_jint))
// = min(limit, min_jint)
// = min_jint
if (adjusted_val->outcnt() == 0) {
igvn->remove_dead_node(adjusted_val);
}
hook->destruct(igvn);

int lo = igvn->type(adjusted_lim)->is_int()->_lo;
if (lo < 0) {
// If range check elimination applies to this comparison, it includes code to protect from overflows that may
// cause the main loop to be skipped entirely. Delay this transformation.
// Example:
// for (int i = 0; i < limit; i++) {
// if (i < max_jint && i > min_jint) {...
// }
// Comparisons folded as:
// i - min_jint - 1 <u -2
// when RC applies, main loop limit becomes:
// min(limit, max(-2 + min_jint + 1, min_jint))
// = min(limit, min_jint)
// = min_jint
if (!igvn->C->post_loop_opts_phase()) {
if (adjusted_val->outcnt() == 0) {
igvn->remove_dead_node(adjusted_val);
}
if (adjusted_lim->outcnt() == 0) {
igvn->remove_dead_node(adjusted_lim);
}
igvn->C->record_for_post_loop_opts_igvn(this);
return false;
}
if (adjusted_lim->outcnt() == 0) {
igvn->remove_dead_node(adjusted_lim);
}
igvn->C->record_for_post_loop_opts_igvn(this);
return false;
}

Node* newcmp = igvn->transform(new CmpUNode(adjusted_val, adjusted_lim));
Node* newbool = igvn->transform(new BoolNode(newcmp, cond));
Node* newcmp = igvn->transform(new CmpUNode(adjusted_val, adjusted_lim));
Node* newbool = igvn->transform(new BoolNode(newcmp, cond));

igvn->replace_input_of(dom_iff, 1, igvn->intcon(proj->_con));
igvn->replace_input_of(this, 1, newbool);
igvn->replace_input_of(dom_iff, 1, igvn->intcon(proj->_con));
igvn->replace_input_of(this, 1, newbool);

return true;
}
return false;
return true;
}

// Merge the branches that trap for this If and the dominating If into
Expand Down
Loading

0 comments on commit f1a97f5

Please sign in to comment.