949 public:
950 void do_klass(Klass* klass);
951 };
952
953 friend class AdjustPointerClosure;
954 friend class AdjustKlassClosure;
955 friend class RefProcTaskProxy;
956
957 private:
958 static STWGCTimer _gc_timer;
959 static ParallelOldTracer _gc_tracer;
960 static elapsedTimer _accumulated_time;
961 static unsigned int _total_invocations;
962 static unsigned int _maximum_compaction_gc_num;
963 static jlong _time_of_last_gc; // ms
964 static CollectorCounters* _counters;
965 static ParMarkBitMap _mark_bitmap;
966 static ParallelCompactData _summary_data;
967 static IsAliveClosure _is_alive_closure;
968 static SpaceInfo _space_info[last_space_id];
969 static bool _print_phases;
970 static AdjustPointerClosure _adjust_pointer_closure;
971 static AdjustKlassClosure _adjust_klass_closure;
972
973 // Reference processing (used in ...follow_contents)
974 static ReferenceProcessor* _ref_processor;
975
976 // Values computed at initialization and used by dead_wood_limiter().
977 static double _dwl_mean;
978 static double _dwl_std_dev;
979 static double _dwl_first_term;
980 static double _dwl_adjustment;
981 #ifdef ASSERT
982 static bool _dwl_initialized;
983 #endif // #ifdef ASSERT
984
985 public:
986 static ParallelOldTracer* gc_tracer() { return &_gc_tracer; }
987
988 private:
989
990 static void initialize_space_info();
991
992 // Return true if details about individual phases should be printed.
993 static inline bool print_phases();
994
995 // Clear the marking bitmap and summary data that cover the specified space.
996 static void clear_data_covering_space(SpaceId id);
997
998 static void pre_compact(PreGCValues* pre_gc_values);
999 static void post_compact();
1000
1001 // Mark live objects
1002 static void marking_phase(ParCompactionManager* cm,
1003 bool maximum_heap_compaction,
1004 ParallelOldTracer *gc_tracer);
1005
1006 // Compute the dense prefix for the designated space. This is an experimental
1007 // implementation currently not used in production.
1008 static HeapWord* compute_dense_prefix_via_density(const SpaceId id,
1009 bool maximum_compaction);
1010
1011 // Methods used to compute the dense prefix.
1012
1013 // Compute the value of the normal distribution at x = density. The mean and
1014 // standard deviation are values saved by initialize_dead_wood_limiter().
1015 static inline double normal_distribution(double density);
1016
1017 // Initialize the static vars used by dead_wood_limiter().
1018 static void initialize_dead_wood_limiter();
1052 // Return true if dead space crosses onto the specified Region; bit must be
1053 // the bit index corresponding to the first word of the Region.
1054 static inline bool dead_space_crosses_boundary(const RegionData* region,
1055 idx_t bit);
1056
1057 // Summary phase utility routine to fill dead space (if any) at the dense
1058 // prefix boundary. Should only be called if the the dense prefix is
1059 // non-empty.
1060 static void fill_dense_prefix_end(SpaceId id);
1061
1062 // Clear the summary data source_region field for the specified addresses.
1063 static void clear_source_region(HeapWord* beg_addr, HeapWord* end_addr);
1064
1065 static void summarize_spaces_quick();
1066 static void summarize_space(SpaceId id, bool maximum_compaction);
1067 static void summary_phase(ParCompactionManager* cm, bool maximum_compaction);
1068
1069 // Adjust addresses in roots. Does not adjust addresses in heap.
1070 static void adjust_roots();
1071
1072 DEBUG_ONLY(static void write_block_fill_histogram(outputStream* const out);)
1073
1074 // Move objects to new locations.
1075 static void compact_perm(ParCompactionManager* cm);
1076 static void compact();
1077
1078 // Add available regions to the stack and draining tasks to the task queue.
1079 static void enqueue_region_draining_tasks(GCTaskQueue* q,
1080 uint parallel_gc_threads);
1081
1082 // Add dense prefix update tasks to the task queue.
1083 static void enqueue_dense_prefix_tasks(GCTaskQueue* q,
1084 uint parallel_gc_threads);
1085
1086 // Add region stealing tasks to the task queue.
1087 static void enqueue_region_stealing_tasks(
1088 GCTaskQueue* q,
1089 ParallelTaskTerminator* terminator_ptr,
1090 uint parallel_gc_threads);
1091
1092 // If objects are left in eden after a collection, try to move the boundary
1241 #ifdef ASSERT
1242 // Sanity check the new location of a word in the heap.
1243 static inline void check_new_location(HeapWord* old_addr, HeapWord* new_addr);
1244 // Verify that all the regions have been emptied.
1245 static void verify_complete(SpaceId space_id);
1246 #endif // #ifdef ASSERT
1247 };
1248
1249 inline bool PSParallelCompact::mark_obj(oop obj) {
1250 const int obj_size = obj->size();
1251 if (mark_bitmap()->mark_obj(obj, obj_size)) {
1252 _summary_data.add_obj(obj, obj_size);
1253 return true;
1254 } else {
1255 return false;
1256 }
1257 }
1258
1259 inline bool PSParallelCompact::is_marked(oop obj) {
1260 return mark_bitmap()->is_marked(obj);
1261 }
1262
1263 inline bool PSParallelCompact::print_phases() {
1264 return _print_phases;
1265 }
1266
1267 inline double PSParallelCompact::normal_distribution(double density) {
1268 assert(_dwl_initialized, "uninitialized");
1269 const double squared_term = (density - _dwl_mean) / _dwl_std_dev;
1270 return _dwl_first_term * exp(-0.5 * squared_term * squared_term);
1271 }
1272
1273 inline bool
1274 PSParallelCompact::dead_space_crosses_boundary(const RegionData* region,
1275 idx_t bit)
1276 {
1277 assert(bit > 0, "cannot call this for the first bit/region");
1278 assert(_summary_data.region_to_addr(region) == _mark_bitmap.bit_to_addr(bit),
1279 "sanity check");
1280
1281 // Dead space crosses the boundary if (1) a partial object does not extend
1282 // onto the region, (2) an object does not start at the beginning of the
1283 // region, and (3) an object does not end at the end of the prior region.
1284 return region->partial_obj_size() == 0 &&
|
949 public:
950 void do_klass(Klass* klass);
951 };
952
953 friend class AdjustPointerClosure;
954 friend class AdjustKlassClosure;
955 friend class RefProcTaskProxy;
956
957 private:
958 static STWGCTimer _gc_timer;
959 static ParallelOldTracer _gc_tracer;
960 static elapsedTimer _accumulated_time;
961 static unsigned int _total_invocations;
962 static unsigned int _maximum_compaction_gc_num;
963 static jlong _time_of_last_gc; // ms
964 static CollectorCounters* _counters;
965 static ParMarkBitMap _mark_bitmap;
966 static ParallelCompactData _summary_data;
967 static IsAliveClosure _is_alive_closure;
968 static SpaceInfo _space_info[last_space_id];
969 static AdjustPointerClosure _adjust_pointer_closure;
970 static AdjustKlassClosure _adjust_klass_closure;
971
972 // Reference processing (used in ...follow_contents)
973 static ReferenceProcessor* _ref_processor;
974
975 // Values computed at initialization and used by dead_wood_limiter().
976 static double _dwl_mean;
977 static double _dwl_std_dev;
978 static double _dwl_first_term;
979 static double _dwl_adjustment;
980 #ifdef ASSERT
981 static bool _dwl_initialized;
982 #endif // #ifdef ASSERT
983
984 public:
985 static ParallelOldTracer* gc_tracer() { return &_gc_tracer; }
986
987 private:
988
989 static void initialize_space_info();
990
991 // Clear the marking bitmap and summary data that cover the specified space.
992 static void clear_data_covering_space(SpaceId id);
993
994 static void pre_compact();
995 static void post_compact();
996
997 // Mark live objects
998 static void marking_phase(ParCompactionManager* cm,
999 bool maximum_heap_compaction,
1000 ParallelOldTracer *gc_tracer);
1001
1002 // Compute the dense prefix for the designated space. This is an experimental
1003 // implementation currently not used in production.
1004 static HeapWord* compute_dense_prefix_via_density(const SpaceId id,
1005 bool maximum_compaction);
1006
1007 // Methods used to compute the dense prefix.
1008
1009 // Compute the value of the normal distribution at x = density. The mean and
1010 // standard deviation are values saved by initialize_dead_wood_limiter().
1011 static inline double normal_distribution(double density);
1012
1013 // Initialize the static vars used by dead_wood_limiter().
1014 static void initialize_dead_wood_limiter();
1048 // Return true if dead space crosses onto the specified Region; bit must be
1049 // the bit index corresponding to the first word of the Region.
1050 static inline bool dead_space_crosses_boundary(const RegionData* region,
1051 idx_t bit);
1052
1053 // Summary phase utility routine to fill dead space (if any) at the dense
1054 // prefix boundary. Should only be called if the the dense prefix is
1055 // non-empty.
1056 static void fill_dense_prefix_end(SpaceId id);
1057
1058 // Clear the summary data source_region field for the specified addresses.
1059 static void clear_source_region(HeapWord* beg_addr, HeapWord* end_addr);
1060
1061 static void summarize_spaces_quick();
1062 static void summarize_space(SpaceId id, bool maximum_compaction);
1063 static void summary_phase(ParCompactionManager* cm, bool maximum_compaction);
1064
1065 // Adjust addresses in roots. Does not adjust addresses in heap.
1066 static void adjust_roots();
1067
1068 DEBUG_ONLY(static void write_block_fill_histogram();)
1069
1070 // Move objects to new locations.
1071 static void compact_perm(ParCompactionManager* cm);
1072 static void compact();
1073
1074 // Add available regions to the stack and draining tasks to the task queue.
1075 static void enqueue_region_draining_tasks(GCTaskQueue* q,
1076 uint parallel_gc_threads);
1077
1078 // Add dense prefix update tasks to the task queue.
1079 static void enqueue_dense_prefix_tasks(GCTaskQueue* q,
1080 uint parallel_gc_threads);
1081
1082 // Add region stealing tasks to the task queue.
1083 static void enqueue_region_stealing_tasks(
1084 GCTaskQueue* q,
1085 ParallelTaskTerminator* terminator_ptr,
1086 uint parallel_gc_threads);
1087
1088 // If objects are left in eden after a collection, try to move the boundary
1237 #ifdef ASSERT
1238 // Sanity check the new location of a word in the heap.
1239 static inline void check_new_location(HeapWord* old_addr, HeapWord* new_addr);
1240 // Verify that all the regions have been emptied.
1241 static void verify_complete(SpaceId space_id);
1242 #endif // #ifdef ASSERT
1243 };
1244
1245 inline bool PSParallelCompact::mark_obj(oop obj) {
1246 const int obj_size = obj->size();
1247 if (mark_bitmap()->mark_obj(obj, obj_size)) {
1248 _summary_data.add_obj(obj, obj_size);
1249 return true;
1250 } else {
1251 return false;
1252 }
1253 }
1254
1255 inline bool PSParallelCompact::is_marked(oop obj) {
1256 return mark_bitmap()->is_marked(obj);
1257 }
1258
1259 inline double PSParallelCompact::normal_distribution(double density) {
1260 assert(_dwl_initialized, "uninitialized");
1261 const double squared_term = (density - _dwl_mean) / _dwl_std_dev;
1262 return _dwl_first_term * exp(-0.5 * squared_term * squared_term);
1263 }
1264
1265 inline bool
1266 PSParallelCompact::dead_space_crosses_boundary(const RegionData* region,
1267 idx_t bit)
1268 {
1269 assert(bit > 0, "cannot call this for the first bit/region");
1270 assert(_summary_data.region_to_addr(region) == _mark_bitmap.bit_to_addr(bit),
1271 "sanity check");
1272
1273 // Dead space crosses the boundary if (1) a partial object does not extend
1274 // onto the region, (2) an object does not start at the beginning of the
1275 // region, and (3) an object does not end at the end of the prior region.
1276 return region->partial_obj_size() == 0 &&
|