< prev index next >

src/hotspot/share/gc/g1/g1CollectionSet.cpp

Print this page
rev 56885 : imported patch 8233998-new-young-regions-registered-too-early


 260   // separate fields (*_diff) and we'll just add them to the "main"
 261   // fields at the start of a GC.
 262 
 263   ssize_t old_rs_length = (ssize_t) hr->recorded_rs_length();
 264   ssize_t rs_length_diff = (ssize_t) new_rs_length - old_rs_length;
 265   _inc_recorded_rs_length_diff += rs_length_diff;
 266 
 267   double old_elapsed_time_ms = hr->predicted_elapsed_time_ms();
 268   double new_region_elapsed_time_ms = predict_region_elapsed_time_ms(hr);
 269   double elapsed_ms_diff = new_region_elapsed_time_ms - old_elapsed_time_ms;
 270   _inc_predicted_elapsed_time_ms_diff += elapsed_ms_diff;
 271 
 272   hr->set_recorded_rs_length(new_rs_length);
 273   hr->set_predicted_elapsed_time_ms(new_region_elapsed_time_ms);
 274 }
 275 
 276 void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
 277   assert(hr->is_young(), "invariant");
 278   assert(_inc_build_state == Active, "Precondition");
 279 
 280   size_t collection_set_length = _collection_set_cur_length;
 281   // We use UINT_MAX as "invalid" marker in verification.
 282   assert(collection_set_length < (UINT_MAX - 1),
 283          "Collection set is too large with " SIZE_FORMAT " entries", collection_set_length);
 284   hr->set_young_index_in_cset((uint)collection_set_length + 1);
 285 
 286   _collection_set_regions[collection_set_length] = hr->hrm_index();
 287   // Concurrent readers must observe the store of the value in the array before an
 288   // update to the length field.
 289   OrderAccess::storestore();
 290   _collection_set_cur_length++;
 291   assert(_collection_set_cur_length <= _collection_set_max_length, "Collection set larger than maximum allowed.");
 292 
 293   // This routine is used when:
 294   // * adding survivor regions to the incremental cset at the end of an
 295   //   evacuation pause or
 296   // * adding the current allocation region to the incremental cset
 297   //   when it is retired.
 298   // Therefore this routine may be called at a safepoint by the
 299   // VM thread, or in-between safepoints by mutator threads (when
 300   // retiring the current allocation region)
 301   // We need to clear and set the cached recorded/cached collection set
 302   // information in the heap region here (before the region gets added
 303   // to the collection set). An individual heap region's cached values
 304   // are calculated, aggregated with the policy collection set info,
 305   // and cached in the heap region here (initially) and (subsequently)
 306   // by the Young List sampling code.
 307   // Ignore calls to this due to retirement during full gc.
 308 
 309   if (!_g1h->collector_state()->in_full_gc()) {
 310     size_t rs_length = hr->rem_set()->occupied();
 311     double region_elapsed_time_ms = predict_region_elapsed_time_ms(hr);
 312 
 313     // Cache the values we have added to the aggregated information
 314     // in the heap region in case we have to remove this region from
 315     // the incremental collection set, or it is updated by the
 316     // rset sampling code
 317     hr->set_recorded_rs_length(rs_length);
 318     hr->set_predicted_elapsed_time_ms(region_elapsed_time_ms);
 319 
 320     _inc_recorded_rs_length += rs_length;
 321     _inc_predicted_elapsed_time_ms += region_elapsed_time_ms;
 322     _inc_bytes_used_before += hr->used();
 323   }
 324 
 325   assert(!hr->in_collection_set(), "invariant");
 326   _g1h->register_young_region_with_region_attr(hr);













 327 }
 328 
 329 void G1CollectionSet::add_survivor_regions(HeapRegion* hr) {
 330   assert(hr->is_survivor(), "Must only add survivor regions, but is %s", hr->get_type_str());
 331   add_young_region_common(hr);
 332 }
 333 
 334 void G1CollectionSet::add_eden_region(HeapRegion* hr) {
 335   assert(hr->is_eden(), "Must only add eden regions, but is %s", hr->get_type_str());
 336   add_young_region_common(hr);
 337 }
 338 
 339 #ifndef PRODUCT
 340 class G1VerifyYoungAgesClosure : public HeapRegionClosure {
 341 public:
 342   bool _valid;
 343 public:
 344   G1VerifyYoungAgesClosure() : HeapRegionClosure(), _valid(true) { }
 345 
 346   virtual bool do_heap_region(HeapRegion* r) {




 260   // separate fields (*_diff) and we'll just add them to the "main"
 261   // fields at the start of a GC.
 262 
 263   ssize_t old_rs_length = (ssize_t) hr->recorded_rs_length();
 264   ssize_t rs_length_diff = (ssize_t) new_rs_length - old_rs_length;
 265   _inc_recorded_rs_length_diff += rs_length_diff;
 266 
 267   double old_elapsed_time_ms = hr->predicted_elapsed_time_ms();
 268   double new_region_elapsed_time_ms = predict_region_elapsed_time_ms(hr);
 269   double elapsed_ms_diff = new_region_elapsed_time_ms - old_elapsed_time_ms;
 270   _inc_predicted_elapsed_time_ms_diff += elapsed_ms_diff;
 271 
 272   hr->set_recorded_rs_length(new_rs_length);
 273   hr->set_predicted_elapsed_time_ms(new_region_elapsed_time_ms);
 274 }
 275 
 276 void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
 277   assert(hr->is_young(), "invariant");
 278   assert(_inc_build_state == Active, "Precondition");
 279 













 280   // This routine is used when:
 281   // * adding survivor regions to the incremental cset at the end of an
 282   //   evacuation pause or
 283   // * adding the current allocation region to the incremental cset
 284   //   when it is retired.
 285   // Therefore this routine may be called at a safepoint by the
 286   // VM thread, or in-between safepoints by mutator threads (when
 287   // retiring the current allocation region)
 288   // We need to clear and set the cached recorded/cached collection set
 289   // information in the heap region here (before the region gets added
 290   // to the collection set). An individual heap region's cached values
 291   // are calculated, aggregated with the policy collection set info,
 292   // and cached in the heap region here (initially) and (subsequently)
 293   // by the Young List sampling code.
 294   // Ignore calls to this due to retirement during full gc.
 295 
 296   if (!_g1h->collector_state()->in_full_gc()) {
 297     size_t rs_length = hr->rem_set()->occupied();
 298     double region_elapsed_time_ms = predict_region_elapsed_time_ms(hr);
 299 
 300     // Cache the values we have added to the aggregated information
 301     // in the heap region in case we have to remove this region from
 302     // the incremental collection set, or it is updated by the
 303     // rset sampling code
 304     hr->set_recorded_rs_length(rs_length);
 305     hr->set_predicted_elapsed_time_ms(region_elapsed_time_ms);
 306 
 307     _inc_recorded_rs_length += rs_length;
 308     _inc_predicted_elapsed_time_ms += region_elapsed_time_ms;
 309     _inc_bytes_used_before += hr->used();
 310   }
 311 
 312   assert(!hr->in_collection_set(), "invariant");
 313   _g1h->register_young_region_with_region_attr(hr);
 314 
 315   size_t collection_set_length = _collection_set_cur_length;
 316   // We use UINT_MAX as "invalid" marker in verification.
 317   assert(collection_set_length < (UINT_MAX - 1),
 318          "Collection set is too large with " SIZE_FORMAT " entries", collection_set_length);
 319   hr->set_young_index_in_cset((uint)collection_set_length + 1);
 320 
 321   _collection_set_regions[collection_set_length] = hr->hrm_index();
 322   // Concurrent readers must observe the store of the value in the array before an
 323   // update to the length field.
 324   OrderAccess::storestore();
 325   _collection_set_cur_length++;
 326   assert(_collection_set_cur_length <= _collection_set_max_length, "Collection set larger than maximum allowed.");
 327 }
 328 
 329 void G1CollectionSet::add_survivor_regions(HeapRegion* hr) {
 330   assert(hr->is_survivor(), "Must only add survivor regions, but is %s", hr->get_type_str());
 331   add_young_region_common(hr);
 332 }
 333 
 334 void G1CollectionSet::add_eden_region(HeapRegion* hr) {
 335   assert(hr->is_eden(), "Must only add eden regions, but is %s", hr->get_type_str());
 336   add_young_region_common(hr);
 337 }
 338 
 339 #ifndef PRODUCT
 340 class G1VerifyYoungAgesClosure : public HeapRegionClosure {
 341 public:
 342   bool _valid;
 343 public:
 344   G1VerifyYoungAgesClosure() : HeapRegionClosure(), _valid(true) { }
 345 
 346   virtual bool do_heap_region(HeapRegion* r) {


< prev index next >