comparison src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @ 269:850fdf70db2b

Merge
author jmasa
date Mon, 28 Jul 2008 15:30:23 -0700
parents 1fdb98a17101 2214b226b7f0
children a4b729f5b611
comparison
equal deleted inserted replaced
238:3df2fe7c4451 269:850fdf70db2b
198 tty->print_cr("------ ---------- ---------- ---------- ----------"); 198 tty->print_cr("------ ---------- ---------- ---------- ----------");
199 199
200 for (unsigned int id = 0; id < last_space_id; ++id) { 200 for (unsigned int id = 0; id < last_space_id; ++id) {
201 const MutableSpace* space = _space_info[id].space(); 201 const MutableSpace* space = _space_info[id].space();
202 tty->print_cr("%u %s " 202 tty->print_cr("%u %s "
203 SIZE_FORMAT_W("10") " " SIZE_FORMAT_W("10") " " 203 SIZE_FORMAT_W(10) " " SIZE_FORMAT_W(10) " "
204 SIZE_FORMAT_W("10") " " SIZE_FORMAT_W("10") " ", 204 SIZE_FORMAT_W(10) " " SIZE_FORMAT_W(10) " ",
205 id, space_names[id], 205 id, space_names[id],
206 summary_data().addr_to_chunk_idx(space->bottom()), 206 summary_data().addr_to_chunk_idx(space->bottom()),
207 summary_data().addr_to_chunk_idx(space->top()), 207 summary_data().addr_to_chunk_idx(space->top()),
208 summary_data().addr_to_chunk_idx(space->end()), 208 summary_data().addr_to_chunk_idx(space->end()),
209 summary_data().addr_to_chunk_idx(_space_info[id].new_top())); 209 summary_data().addr_to_chunk_idx(_space_info[id].new_top()));
211 } 211 }
212 212
213 void 213 void
214 print_generic_summary_chunk(size_t i, const ParallelCompactData::ChunkData* c) 214 print_generic_summary_chunk(size_t i, const ParallelCompactData::ChunkData* c)
215 { 215 {
216 #define CHUNK_IDX_FORMAT SIZE_FORMAT_W("7") 216 #define CHUNK_IDX_FORMAT SIZE_FORMAT_W(7)
217 #define CHUNK_DATA_FORMAT SIZE_FORMAT_W("5") 217 #define CHUNK_DATA_FORMAT SIZE_FORMAT_W(5)
218 218
219 ParallelCompactData& sd = PSParallelCompact::summary_data(); 219 ParallelCompactData& sd = PSParallelCompact::summary_data();
220 size_t dci = c->destination() ? sd.addr_to_chunk_idx(c->destination()) : 0; 220 size_t dci = c->destination() ? sd.addr_to_chunk_idx(c->destination()) : 0;
221 tty->print_cr(CHUNK_IDX_FORMAT " " PTR_FORMAT " " 221 tty->print_cr(CHUNK_IDX_FORMAT " " PTR_FORMAT " "
222 CHUNK_IDX_FORMAT " " PTR_FORMAT " " 222 CHUNK_IDX_FORMAT " " PTR_FORMAT " "
267 void 267 void
268 print_initial_summary_chunk(size_t i, 268 print_initial_summary_chunk(size_t i,
269 const ParallelCompactData::ChunkData* c, 269 const ParallelCompactData::ChunkData* c,
270 bool newline = true) 270 bool newline = true)
271 { 271 {
272 tty->print(SIZE_FORMAT_W("5") " " PTR_FORMAT " " 272 tty->print(SIZE_FORMAT_W(5) " " PTR_FORMAT " "
273 SIZE_FORMAT_W("5") " " SIZE_FORMAT_W("5") " " 273 SIZE_FORMAT_W(5) " " SIZE_FORMAT_W(5) " "
274 SIZE_FORMAT_W("5") " " SIZE_FORMAT_W("5") " %d", 274 SIZE_FORMAT_W(5) " " SIZE_FORMAT_W(5) " %d",
275 i, c->destination(), 275 i, c->destination(),
276 c->partial_obj_size(), c->live_obj_size(), 276 c->partial_obj_size(), c->live_obj_size(),
277 c->data_size(), c->source_chunk(), c->destination_count()); 277 c->data_size(), c->source_chunk(), c->destination_count());
278 if (newline) tty->cr(); 278 if (newline) tty->cr();
279 } 279 }
324 max_dead_to_right = dead_to_right; 324 max_dead_to_right = dead_to_right;
325 max_live_to_right = live_to_right; 325 max_live_to_right = live_to_right;
326 } 326 }
327 327
328 print_initial_summary_chunk(i, c, false); 328 print_initial_summary_chunk(i, c, false);
329 tty->print_cr(" %12.10f " SIZE_FORMAT_W("10") " " SIZE_FORMAT_W("10"), 329 tty->print_cr(" %12.10f " SIZE_FORMAT_W(10) " " SIZE_FORMAT_W(10),
330 reclaimed_ratio, dead_to_right, live_to_right); 330 reclaimed_ratio, dead_to_right, live_to_right);
331 331
332 live_to_right -= c->data_size(); 332 live_to_right -= c->data_size();
333 ++i; 333 ++i;
334 } 334 }
336 // Any remaining chunks are empty. Print one more if there is one. 336 // Any remaining chunks are empty. Print one more if there is one.
337 if (i < end_chunk) { 337 if (i < end_chunk) {
338 print_initial_summary_chunk(i, summary_data.chunk(i)); 338 print_initial_summary_chunk(i, summary_data.chunk(i));
339 } 339 }
340 340
341 tty->print_cr("max: " SIZE_FORMAT_W("4") " d2r=" SIZE_FORMAT_W("10") " " 341 tty->print_cr("max: " SIZE_FORMAT_W(4) " d2r=" SIZE_FORMAT_W(10) " "
342 "l2r=" SIZE_FORMAT_W("10") " max_ratio=%14.12f", 342 "l2r=" SIZE_FORMAT_W(10) " max_ratio=%14.12f",
343 max_reclaimed_ratio_chunk, max_dead_to_right, 343 max_reclaimed_ratio_chunk, max_dead_to_right,
344 max_live_to_right, max_reclaimed_ratio); 344 max_live_to_right, max_reclaimed_ratio);
345 } 345 }
346 346
347 void 347 void
1058 1058
1059 COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); 1059 COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
1060 1060
1061 ref_processor()->enqueue_discovered_references(NULL); 1061 ref_processor()->enqueue_discovered_references(NULL);
1062 1062
1063 if (ZapUnusedHeapArea) {
1064 heap->gen_mangle_unused_area();
1065 }
1066
1063 // Update time of last GC 1067 // Update time of last GC
1064 reset_millis_since_last_gc(); 1068 reset_millis_since_last_gc();
1065 } 1069 }
1066 1070
1067 HeapWord* 1071 HeapWord*
1117 const ChunkData* const top_cp = sd.addr_to_chunk_ptr(space->top() - 1); 1121 const ChunkData* const top_cp = sd.addr_to_chunk_ptr(space->top() - 1);
1118 while (cp < end_cp) { 1122 while (cp < end_cp) {
1119 HeapWord* chunk_destination = cp->destination(); 1123 HeapWord* chunk_destination = cp->destination();
1120 const size_t cur_deadwood = pointer_delta(dense_prefix, chunk_destination); 1124 const size_t cur_deadwood = pointer_delta(dense_prefix, chunk_destination);
1121 if (TraceParallelOldGCDensePrefix && Verbose) { 1125 if (TraceParallelOldGCDensePrefix && Verbose) {
1122 tty->print_cr("c#=" SIZE_FORMAT_W("04") " dst=" PTR_FORMAT " " 1126 tty->print_cr("c#=" SIZE_FORMAT_W(4) " dst=" PTR_FORMAT " "
1123 "dp=" SIZE_FORMAT_W("08") " " "cdw=" SIZE_FORMAT_W("08"), 1127 "dp=" SIZE_FORMAT_W(8) " " "cdw=" SIZE_FORMAT_W(8),
1124 sd.chunk(cp), chunk_destination, 1128 sd.chunk(cp), chunk_destination,
1125 dense_prefix, cur_deadwood); 1129 dense_prefix, cur_deadwood);
1126 } 1130 }
1127 1131
1128 if (cur_deadwood >= deadwood_goal) { 1132 if (cur_deadwood >= deadwood_goal) {
1143 double(prev_chunk_live_to_right) / prev_chunk_space_to_right; 1147 double(prev_chunk_live_to_right) / prev_chunk_space_to_right;
1144 if (density_to_right <= prev_chunk_density_to_right) { 1148 if (density_to_right <= prev_chunk_density_to_right) {
1145 return dense_prefix; 1149 return dense_prefix;
1146 } 1150 }
1147 if (TraceParallelOldGCDensePrefix && Verbose) { 1151 if (TraceParallelOldGCDensePrefix && Verbose) {
1148 tty->print_cr("backing up from c=" SIZE_FORMAT_W("4") " d2r=%10.8f " 1152 tty->print_cr("backing up from c=" SIZE_FORMAT_W(4) " d2r=%10.8f "
1149 "pc_d2r=%10.8f", sd.chunk(cp), density_to_right, 1153 "pc_d2r=%10.8f", sd.chunk(cp), density_to_right,
1150 prev_chunk_density_to_right); 1154 prev_chunk_density_to_right);
1151 } 1155 }
1152 dense_prefix -= chunk_size; 1156 dense_prefix -= chunk_size;
1153 live_to_right = prev_chunk_live_to_right; 1157 live_to_right = prev_chunk_live_to_right;
1180 const size_t space_cap = space->capacity_in_words(); 1184 const size_t space_cap = space->capacity_in_words();
1181 const double dead_to_left_pct = double(dead_to_left) / space_cap; 1185 const double dead_to_left_pct = double(dead_to_left) / space_cap;
1182 const size_t live_to_right = new_top - cp->destination(); 1186 const size_t live_to_right = new_top - cp->destination();
1183 const size_t dead_to_right = space->top() - addr - live_to_right; 1187 const size_t dead_to_right = space->top() - addr - live_to_right;
1184 1188
1185 tty->print_cr("%s=" PTR_FORMAT " dpc=" SIZE_FORMAT_W("05") " " 1189 tty->print_cr("%s=" PTR_FORMAT " dpc=" SIZE_FORMAT_W(5) " "
1186 "spl=" SIZE_FORMAT " " 1190 "spl=" SIZE_FORMAT " "
1187 "d2l=" SIZE_FORMAT " d2l%%=%6.4f " 1191 "d2l=" SIZE_FORMAT " d2l%%=%6.4f "
1188 "d2r=" SIZE_FORMAT " l2r=" SIZE_FORMAT 1192 "d2r=" SIZE_FORMAT " l2r=" SIZE_FORMAT
1189 " ratio=%10.8f", 1193 " ratio=%10.8f",
1190 algorithm, addr, chunk_idx, 1194 algorithm, addr, chunk_idx,
1520 1524
1521 void 1525 void
1522 PSParallelCompact::summarize_space(SpaceId id, bool maximum_compaction) 1526 PSParallelCompact::summarize_space(SpaceId id, bool maximum_compaction)
1523 { 1527 {
1524 assert(id < last_space_id, "id out of range"); 1528 assert(id < last_space_id, "id out of range");
1529 assert(_space_info[id].dense_prefix() == _space_info[id].space()->bottom(),
1530 "should have been set in summarize_spaces_quick()");
1525 1531
1526 const MutableSpace* space = _space_info[id].space(); 1532 const MutableSpace* space = _space_info[id].space();
1527 HeapWord** new_top_addr = _space_info[id].new_top_addr(); 1533 if (_space_info[id].new_top() != space->bottom()) {
1528 1534 HeapWord* dense_prefix_end = compute_dense_prefix(id, maximum_compaction);
1529 HeapWord* dense_prefix_end = compute_dense_prefix(id, maximum_compaction); 1535 _space_info[id].set_dense_prefix(dense_prefix_end);
1530 _space_info[id].set_dense_prefix(dense_prefix_end);
1531 1536
1532 #ifndef PRODUCT 1537 #ifndef PRODUCT
1533 if (TraceParallelOldGCDensePrefix) { 1538 if (TraceParallelOldGCDensePrefix) {
1534 print_dense_prefix_stats("ratio", id, maximum_compaction, dense_prefix_end); 1539 print_dense_prefix_stats("ratio", id, maximum_compaction,
1535 HeapWord* addr = compute_dense_prefix_via_density(id, maximum_compaction); 1540 dense_prefix_end);
1536 print_dense_prefix_stats("density", id, maximum_compaction, addr); 1541 HeapWord* addr = compute_dense_prefix_via_density(id, maximum_compaction);
1537 } 1542 print_dense_prefix_stats("density", id, maximum_compaction, addr);
1543 }
1538 #endif // #ifndef PRODUCT 1544 #endif // #ifndef PRODUCT
1539 1545
1540 // If dead space crosses the dense prefix boundary, it is (at least partially) 1546 // If dead space crosses the dense prefix boundary, it is (at least
1541 // filled with a dummy object, marked live and added to the summary data. 1547 // partially) filled with a dummy object, marked live and added to the
1542 // This simplifies the copy/update phase and must be done before the final 1548 // summary data. This simplifies the copy/update phase and must be done
1543 // locations of objects are determined, to prevent leaving a fragment of dead 1549 // before the final locations of objects are determined, to prevent leaving
1544 // space that is too small to fill with an object. 1550 // a fragment of dead space that is too small to fill with an object.
1545 if (!maximum_compaction && dense_prefix_end != space->bottom()) { 1551 if (!maximum_compaction && dense_prefix_end != space->bottom()) {
1546 fill_dense_prefix_end(id); 1552 fill_dense_prefix_end(id);
1547 } 1553 }
1548 1554
1549 // Compute the destination of each Chunk, and thus each object. 1555 // Compute the destination of each Chunk, and thus each object.
1550 _summary_data.summarize_dense_prefix(space->bottom(), dense_prefix_end); 1556 _summary_data.summarize_dense_prefix(space->bottom(), dense_prefix_end);
1551 _summary_data.summarize(dense_prefix_end, space->end(), 1557 _summary_data.summarize(dense_prefix_end, space->end(),
1552 dense_prefix_end, space->top(), 1558 dense_prefix_end, space->top(),
1553 new_top_addr); 1559 _space_info[id].new_top_addr());
1560 }
1554 1561
1555 if (TraceParallelOldGCSummaryPhase) { 1562 if (TraceParallelOldGCSummaryPhase) {
1556 const size_t chunk_size = ParallelCompactData::ChunkSize; 1563 const size_t chunk_size = ParallelCompactData::ChunkSize;
1564 HeapWord* const dense_prefix_end = _space_info[id].dense_prefix();
1557 const size_t dp_chunk = _summary_data.addr_to_chunk_idx(dense_prefix_end); 1565 const size_t dp_chunk = _summary_data.addr_to_chunk_idx(dense_prefix_end);
1558 const size_t dp_words = pointer_delta(dense_prefix_end, space->bottom()); 1566 const size_t dp_words = pointer_delta(dense_prefix_end, space->bottom());
1559 const HeapWord* nt_aligned_up = _summary_data.chunk_align_up(*new_top_addr); 1567 HeapWord* const new_top = _space_info[id].new_top();
1568 const HeapWord* nt_aligned_up = _summary_data.chunk_align_up(new_top);
1560 const size_t cr_words = pointer_delta(nt_aligned_up, dense_prefix_end); 1569 const size_t cr_words = pointer_delta(nt_aligned_up, dense_prefix_end);
1561 tty->print_cr("id=%d cap=" SIZE_FORMAT " dp=" PTR_FORMAT " " 1570 tty->print_cr("id=%d cap=" SIZE_FORMAT " dp=" PTR_FORMAT " "
1562 "dp_chunk=" SIZE_FORMAT " " "dp_count=" SIZE_FORMAT " " 1571 "dp_chunk=" SIZE_FORMAT " " "dp_count=" SIZE_FORMAT " "
1563 "cr_count=" SIZE_FORMAT " " "nt=" PTR_FORMAT, 1572 "cr_count=" SIZE_FORMAT " " "nt=" PTR_FORMAT,
1564 id, space->capacity_in_words(), dense_prefix_end, 1573 id, space->capacity_in_words(), dense_prefix_end,
1565 dp_chunk, dp_words / chunk_size, 1574 dp_chunk, dp_words / chunk_size,
1566 cr_words / chunk_size, *new_top_addr); 1575 cr_words / chunk_size, new_top);
1567 } 1576 }
1568 } 1577 }
1569 1578
1570 void PSParallelCompact::summary_phase(ParCompactionManager* cm, 1579 void PSParallelCompact::summary_phase(ParCompactionManager* cm,
1571 bool maximum_compaction) 1580 bool maximum_compaction)
1630 for (id = eden_space_id; id < last_space_id; ++id) { 1639 for (id = eden_space_id; id < last_space_id; ++id) {
1631 const MutableSpace* space = _space_info[id].space(); 1640 const MutableSpace* space = _space_info[id].space();
1632 const size_t live = pointer_delta(_space_info[id].new_top(), 1641 const size_t live = pointer_delta(_space_info[id].new_top(),
1633 space->bottom()); 1642 space->bottom());
1634 const size_t available = pointer_delta(target_space_end, *new_top_addr); 1643 const size_t available = pointer_delta(target_space_end, *new_top_addr);
1635 if (live <= available) { 1644 if (live > 0 && live <= available) {
1636 // All the live data will fit. 1645 // All the live data will fit.
1637 if (TraceParallelOldGCSummaryPhase) { 1646 if (TraceParallelOldGCSummaryPhase) {
1638 tty->print_cr("summarizing %d into old_space @ " PTR_FORMAT, 1647 tty->print_cr("summarizing %d into old_space @ " PTR_FORMAT,
1639 id, *new_top_addr); 1648 id, *new_top_addr);
1640 } 1649 }
1641 _summary_data.summarize(*new_top_addr, target_space_end, 1650 _summary_data.summarize(*new_top_addr, target_space_end,
1642 space->bottom(), space->top(), 1651 space->bottom(), space->top(),
1643 new_top_addr); 1652 new_top_addr);
1644 1653
1645 // Reset the new_top value for the space.
1646 _space_info[id].set_new_top(space->bottom());
1647
1648 // Clear the source_chunk field for each chunk in the space. 1654 // Clear the source_chunk field for each chunk in the space.
1655 HeapWord* const new_top = _space_info[id].new_top();
1656 HeapWord* const clear_end = _summary_data.chunk_align_up(new_top);
1649 ChunkData* beg_chunk = _summary_data.addr_to_chunk_ptr(space->bottom()); 1657 ChunkData* beg_chunk = _summary_data.addr_to_chunk_ptr(space->bottom());
1650 ChunkData* end_chunk = _summary_data.addr_to_chunk_ptr(space->top() - 1); 1658 ChunkData* end_chunk = _summary_data.addr_to_chunk_ptr(clear_end);
1651 while (beg_chunk <= end_chunk) { 1659 while (beg_chunk < end_chunk) {
1652 beg_chunk->set_source_chunk(0); 1660 beg_chunk->set_source_chunk(0);
1653 ++beg_chunk; 1661 ++beg_chunk;
1654 } 1662 }
1663
1664 // Reset the new_top value for the space.
1665 _space_info[id].set_new_top(space->bottom());
1655 } 1666 }
1656 } 1667 }
1657 1668
1658 // Fill in the block data after any changes to the chunks have 1669 // Fill in the block data after any changes to the chunks have
1659 // been made. 1670 // been made.
1959 PSYoungGen* young_gen = heap->young_gen(); 1970 PSYoungGen* young_gen = heap->young_gen();
1960 PSOldGen* old_gen = heap->old_gen(); 1971 PSOldGen* old_gen = heap->old_gen();
1961 PSPermGen* perm_gen = heap->perm_gen(); 1972 PSPermGen* perm_gen = heap->perm_gen();
1962 PSAdaptiveSizePolicy* size_policy = heap->size_policy(); 1973 PSAdaptiveSizePolicy* size_policy = heap->size_policy();
1963 1974
1975 if (ZapUnusedHeapArea) {
1976 // Save information needed to minimize mangling
1977 heap->record_gen_tops_before_GC();
1978 }
1979
1964 _print_phases = PrintGCDetails && PrintParallelOldGCPhaseTimes; 1980 _print_phases = PrintGCDetails && PrintParallelOldGCPhaseTimes;
1965 1981
1966 // Make sure data structures are sane, make the heap parsable, and do other 1982 // Make sure data structures are sane, make the heap parsable, and do other
1967 // miscellaneous bookkeeping. 1983 // miscellaneous bookkeeping.
1968 PreGCValues pre_gc_values; 1984 PreGCValues pre_gc_values;
2127 young_gen->to_space()->capacity_in_bytes(), 2143 young_gen->to_space()->capacity_in_bytes(),
2128 "Sizes of space in young gen are out-of-bounds"); 2144 "Sizes of space in young gen are out-of-bounds");
2129 size_t max_eden_size = young_gen->max_size() - 2145 size_t max_eden_size = young_gen->max_size() -
2130 young_gen->from_space()->capacity_in_bytes() - 2146 young_gen->from_space()->capacity_in_bytes() -
2131 young_gen->to_space()->capacity_in_bytes(); 2147 young_gen->to_space()->capacity_in_bytes();
2132 size_policy->compute_generation_free_space(young_gen->used_in_bytes(), 2148 size_policy->compute_generation_free_space(
2133 young_gen->eden_space()->used_in_bytes(), 2149 young_gen->used_in_bytes(),
2134 old_gen->used_in_bytes(), 2150 young_gen->eden_space()->used_in_bytes(),
2135 perm_gen->used_in_bytes(), 2151 old_gen->used_in_bytes(),
2136 young_gen->eden_space()->capacity_in_bytes(), 2152 perm_gen->used_in_bytes(),
2137 old_gen->max_gen_size(), 2153 young_gen->eden_space()->capacity_in_bytes(),
2138 max_eden_size, 2154 old_gen->max_gen_size(),
2139 true /* full gc*/, 2155 max_eden_size,
2140 gc_cause); 2156 true /* full gc*/,
2141 2157 gc_cause);
2142 heap->resize_old_gen(size_policy->calculated_old_free_size_in_bytes()); 2158
2159 heap->resize_old_gen(
2160 size_policy->calculated_old_free_size_in_bytes());
2143 2161
2144 // Don't resize the young generation at an major collection. A 2162 // Don't resize the young generation at an major collection. A
2145 // desired young generation size may have been calculated but 2163 // desired young generation size may have been calculated but
2146 // resizing the young generation complicates the code because the 2164 // resizing the young generation complicates the code because the
2147 // resizing of the old generation may have moved the boundary 2165 // resizing of the old generation may have moved the boundary
2208 // Re-verify object start arrays 2226 // Re-verify object start arrays
2209 if (VerifyObjectStartArray && 2227 if (VerifyObjectStartArray &&
2210 VerifyAfterGC) { 2228 VerifyAfterGC) {
2211 old_gen->verify_object_start_array(); 2229 old_gen->verify_object_start_array();
2212 perm_gen->verify_object_start_array(); 2230 perm_gen->verify_object_start_array();
2231 }
2232
2233 if (ZapUnusedHeapArea) {
2234 old_gen->object_space()->check_mangled_unused_area_complete();
2235 perm_gen->object_space()->check_mangled_unused_area_complete();
2213 } 2236 }
2214 2237
2215 NOT_PRODUCT(ref_processor()->verify_no_references_recorded()); 2238 NOT_PRODUCT(ref_processor()->verify_no_references_recorded());
2216 2239
2217 collection_exit.update(); 2240 collection_exit.update();
2497 cm->save_for_processing(cur); 2520 cm->save_for_processing(cur);
2498 2521
2499 if (TraceParallelOldGCCompactionPhase && Verbose) { 2522 if (TraceParallelOldGCCompactionPhase && Verbose) {
2500 const size_t count_mod_8 = fillable_chunks & 7; 2523 const size_t count_mod_8 = fillable_chunks & 7;
2501 if (count_mod_8 == 0) gclog_or_tty->print("fillable: "); 2524 if (count_mod_8 == 0) gclog_or_tty->print("fillable: ");
2502 gclog_or_tty->print(" " SIZE_FORMAT_W("7"), cur); 2525 gclog_or_tty->print(" " SIZE_FORMAT_W(7), cur);
2503 if (count_mod_8 == 7) gclog_or_tty->cr(); 2526 if (count_mod_8 == 7) gclog_or_tty->cr();
2504 } 2527 }
2505 2528
2506 NOT_PRODUCT(++fillable_chunks;) 2529 NOT_PRODUCT(++fillable_chunks;)
2507 2530