< prev index next >

src/hotspot/share/gc/parallel/psParallelCompact.cpp

Print this page

  61 #include "gc/shared/oopStorageSetParState.inline.hpp"
  62 #include "gc/shared/parallelCleaning.hpp"
  63 #include "gc/shared/preservedMarks.inline.hpp"
  64 #include "gc/shared/referencePolicy.hpp"
  65 #include "gc/shared/referenceProcessor.hpp"
  66 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
  67 #include "gc/shared/spaceDecorator.hpp"
  68 #include "gc/shared/taskTerminator.hpp"
  69 #include "gc/shared/weakProcessor.inline.hpp"
  70 #include "gc/shared/workerPolicy.hpp"
  71 #include "gc/shared/workerThread.hpp"
  72 #include "gc/shared/workerUtils.hpp"
  73 #include "logging/log.hpp"
  74 #include "memory/iterator.inline.hpp"
  75 #include "memory/memoryReserver.hpp"
  76 #include "memory/metaspaceUtils.hpp"
  77 #include "memory/resourceArea.hpp"
  78 #include "memory/universe.hpp"
  79 #include "nmt/memTracker.hpp"
  80 #include "oops/access.inline.hpp"

  81 #include "oops/instanceClassLoaderKlass.inline.hpp"
  82 #include "oops/instanceKlass.inline.hpp"
  83 #include "oops/instanceMirrorKlass.inline.hpp"
  84 #include "oops/methodData.hpp"
  85 #include "oops/objArrayKlass.inline.hpp"
  86 #include "oops/oop.inline.hpp"

  87 #include "runtime/handles.inline.hpp"
  88 #include "runtime/java.hpp"
  89 #include "runtime/safepoint.hpp"
  90 #include "runtime/threads.hpp"
  91 #include "runtime/vmThread.hpp"
  92 #include "services/memoryService.hpp"
  93 #include "utilities/align.hpp"
  94 #include "utilities/debug.hpp"
  95 #include "utilities/events.hpp"
  96 #include "utilities/formatBuffer.hpp"
  97 #include "utilities/macros.hpp"
  98 #include "utilities/stack.inline.hpp"
  99 
 100 #include <math.h>
 101 
 102 // All sizes are in HeapWords.
 103 const size_t ParallelCompactData::Log2RegionSize  = 16; // 64K words
 104 const size_t ParallelCompactData::RegionSize      = (size_t)1 << Log2RegionSize;
 105 static_assert(ParallelCompactData::RegionSize >= BitsPerWord, "region-start bit word-aligned");
 106 const size_t ParallelCompactData::RegionSizeBytes =

1409 
1410 // Split [start, end) evenly for a number of workers and return the
1411 // range for worker_id.
1412 static void split_regions_for_worker(size_t start, size_t end,
1413                                      uint worker_id, uint num_workers,
1414                                      size_t* worker_start, size_t* worker_end) {
1415   assert(start < end, "precondition");
1416   assert(num_workers > 0, "precondition");
1417   assert(worker_id < num_workers, "precondition");
1418 
1419   size_t num_regions = end - start;
1420   size_t num_regions_per_worker = num_regions / num_workers;
1421   size_t remainder = num_regions % num_workers;
1422   // The first few workers will get one extra.
1423   *worker_start = start + worker_id * num_regions_per_worker
1424                   + MIN2(checked_cast<size_t>(worker_id), remainder);
1425   *worker_end = *worker_start + num_regions_per_worker
1426                 + (worker_id < remainder ? 1 : 0);
1427 }
1428 














1429 void PSParallelCompact::forward_to_new_addr() {
1430   GCTraceTime(Info, gc, phases) tm("Forward", &_gc_timer);
1431   uint nworkers = ParallelScavengeHeap::heap()->workers().active_workers();
1432 
1433   struct ForwardTask final : public WorkerTask {
1434     uint _num_workers;
1435 
1436     explicit ForwardTask(uint num_workers) :
1437       WorkerTask("PSForward task"),
1438       _num_workers(num_workers) {}
1439 

















1440     static void forward_objs_in_range(ParCompactionManager* cm,
1441                                       HeapWord* start,
1442                                       HeapWord* end,
1443                                       HeapWord* destination) {
1444       HeapWord* cur_addr = start;
1445       HeapWord* new_addr = destination;
1446 
1447       while (cur_addr < end) {
1448         cur_addr = mark_bitmap()->find_obj_beg(cur_addr, end);
1449         if (cur_addr >= end) {
1450           return;
1451         }
1452         assert(mark_bitmap()->is_marked(cur_addr), "inv");
1453         oop obj = cast_to_oop(cur_addr);

1454         if (new_addr != cur_addr) {
1455           cm->preserved_marks()->push_if_necessary(obj, obj->mark());



1456           FullGCForwarding::forward_to(obj, cast_to_oop(new_addr));
1457         }
1458         size_t obj_size = obj->size();
1459         new_addr += obj_size;
1460         cur_addr += obj_size;
1461       }
1462     }
1463 
1464     void work(uint worker_id) override {
1465       ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(worker_id);
1466       for (uint id = old_space_id; id < last_space_id; ++id) {
1467         MutableSpace* sp = PSParallelCompact::space(SpaceId(id));
1468         HeapWord* dense_prefix_addr = dense_prefix(SpaceId(id));
1469         HeapWord* top = sp->top();
1470 
1471         if (dense_prefix_addr == top) {
1472           // Empty space
1473           continue;
1474         }
1475 

2076 
2077 HeapWord* PSParallelCompact::partial_obj_end(HeapWord* region_start_addr) {
2078   ParallelCompactData& sd = summary_data();
2079   assert(sd.is_region_aligned(region_start_addr), "precondition");
2080 
2081   // Use per-region partial_obj_size to locate the end of the obj, that extends
2082   // to region_start_addr.
2083   size_t start_region_idx = sd.addr_to_region_idx(region_start_addr);
2084   size_t end_region_idx = sd.region_count();
2085   size_t accumulated_size = 0;
2086   for (size_t region_idx = start_region_idx; region_idx < end_region_idx; ++region_idx) {
2087     size_t cur_partial_obj_size = sd.region(region_idx)->partial_obj_size();
2088     accumulated_size += cur_partial_obj_size;
2089     if (cur_partial_obj_size != ParallelCompactData::RegionSize) {
2090       break;
2091     }
2092   }
2093   return region_start_addr + accumulated_size;
2094 }
2095 














2096 // Use region_idx as the destination region, and evacuate all live objs on its
2097 // source regions to this destination region.
2098 void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosure& closure, size_t region_idx)
2099 {
2100   ParMarkBitMap* const bitmap = mark_bitmap();
2101   ParallelCompactData& sd = summary_data();
2102   RegionData* const region_ptr = sd.region(region_idx);
2103 
2104   // Get the source region and related info.
2105   size_t src_region_idx = region_ptr->source_region();
2106   SpaceId src_space_id = space_id(sd.region_to_addr(src_region_idx));
2107   HeapWord* src_space_top = _space_info[src_space_id].space()->top();
2108   HeapWord* dest_addr = sd.region_to_addr(region_idx);
2109 
2110   closure.set_source(first_src_addr(dest_addr, src_space_id, src_region_idx));
2111 
2112   // Adjust src_region_idx to prepare for decrementing destination counts (the
2113   // destination count is not decremented when a region is copied to itself).
2114   if (src_region_idx == region_idx) {
2115     src_region_idx += 1;

2191     HeapWord* cur_addr = closure.source();
2192     HeapWord* const end_addr = MIN2(sd.region_align_up(cur_addr + 1),
2193                                     src_space_top);
2194     // To handle the case where the final obj in source region extends to next region.
2195     HeapWord* final_obj_start = (end_addr == src_space_top)
2196                                 ? nullptr
2197                                 : sd.addr_to_region_ptr(end_addr)->partial_obj_addr();
2198     // Apply closure on objs inside [cur_addr, end_addr)
2199     do {
2200       cur_addr = bitmap->find_obj_beg(cur_addr, end_addr);
2201       if (cur_addr == end_addr) {
2202         break;
2203       }
2204       size_t obj_size;
2205       if (final_obj_start == cur_addr) {
2206         obj_size = pointer_delta(partial_obj_end(end_addr), cur_addr);
2207       } else {
2208         // This obj doesn't extend into next region; size() is safe to use.
2209         obj_size = cast_to_oop(cur_addr)->size();
2210       }
2211       closure.do_addr(cur_addr, obj_size);





2212       cur_addr += obj_size;
2213     } while (cur_addr < end_addr && !closure.is_full());
2214 
2215     if (closure.is_full()) {
2216       decrement_destination_counts(cm, src_space_id, src_region_idx, closure.source());
2217       closure.complete_region(dest_addr, region_ptr);
2218       return;
2219     }
2220 
2221     decrement_destination_counts(cm, src_space_id, src_region_idx, end_addr);
2222 
2223     // Move to the next source region, possibly switching spaces as well.  All
2224     // args except end_addr may be modified.
2225     src_region_idx = next_src_region(closure, src_space_id, src_space_top, end_addr);
2226   } while (true);
2227 }
2228 
2229 void PSParallelCompact::fill_and_update_region(ParCompactionManager* cm, size_t region_idx)
2230 {
2231   MoveAndUpdateClosure cl(mark_bitmap(), region_idx);

2311 }
2312 
2313 void MoveAndUpdateClosure::copy_partial_obj(size_t partial_obj_size)
2314 {
2315   size_t words = MIN2(partial_obj_size, words_remaining());
2316 
2317   // This test is necessary; if omitted, the pointer updates to a partial object
2318   // that crosses the dense prefix boundary could be overwritten.
2319   if (source() != copy_destination()) {
2320     DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
2321     Copy::aligned_conjoint_words(source(), copy_destination(), words);
2322   }
2323   update_state(words);
2324 }
2325 
2326 void MoveAndUpdateClosure::complete_region(HeapWord* dest_addr, PSParallelCompact::RegionData* region_ptr) {
2327   assert(region_ptr->shadow_state() == ParallelCompactData::RegionData::NormalRegion, "Region should be finished");
2328   region_ptr->set_completed();
2329 }
2330 
2331 void MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
2332   assert(destination() != nullptr, "sanity");
2333   _source = addr;
2334 
2335   // The start_array must be updated even if the object is not moving.
2336   if (_start_array != nullptr) {
2337     _start_array->update_for_block(destination(), destination() + words);
2338   }
2339 
2340   // Avoid overflow
2341   words = MIN2(words, words_remaining());
2342   assert(words > 0, "inv");
2343 
2344   if (copy_destination() != source()) {
2345     DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
2346     assert(source() != destination(), "inv");
2347     assert(FullGCForwarding::is_forwarded(cast_to_oop(source())), "inv");
2348     assert(FullGCForwarding::forwardee(cast_to_oop(source())) == cast_to_oop(destination()), "inv");
2349     Copy::aligned_conjoint_words(source(), copy_destination(), words);
2350     cast_to_oop(copy_destination())->init_mark();
2351   }
2352 
2353   update_state(words);
2354 }
2355 
2356 void MoveAndUpdateShadowClosure::complete_region(HeapWord* dest_addr, PSParallelCompact::RegionData* region_ptr) {
2357   assert(region_ptr->shadow_state() == ParallelCompactData::RegionData::ShadowRegion, "Region should be shadow");
2358   // Record the shadow region index
2359   region_ptr->set_shadow_region(_shadow);
2360   // Mark the shadow region as filled to indicate the data is ready to be
2361   // copied back
2362   region_ptr->mark_filled();
2363   // Try to copy the content of the shadow region back to its corresponding
2364   // heap region if available; the GC thread that decreases the destination
2365   // count to zero will do the copying otherwise (see
2366   // PSParallelCompact::decrement_destination_counts).
2367   if (((region_ptr->available() && region_ptr->claim()) || region_ptr->claimed()) && region_ptr->mark_copied()) {
2368     region_ptr->set_completed();
2369     PSParallelCompact::copy_back(PSParallelCompact::summary_data().region_to_addr(_shadow), dest_addr);
2370     ParCompactionManager::push_shadow_region_mt_safe(_shadow);

  61 #include "gc/shared/oopStorageSetParState.inline.hpp"
  62 #include "gc/shared/parallelCleaning.hpp"
  63 #include "gc/shared/preservedMarks.inline.hpp"
  64 #include "gc/shared/referencePolicy.hpp"
  65 #include "gc/shared/referenceProcessor.hpp"
  66 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
  67 #include "gc/shared/spaceDecorator.hpp"
  68 #include "gc/shared/taskTerminator.hpp"
  69 #include "gc/shared/weakProcessor.inline.hpp"
  70 #include "gc/shared/workerPolicy.hpp"
  71 #include "gc/shared/workerThread.hpp"
  72 #include "gc/shared/workerUtils.hpp"
  73 #include "logging/log.hpp"
  74 #include "memory/iterator.inline.hpp"
  75 #include "memory/memoryReserver.hpp"
  76 #include "memory/metaspaceUtils.hpp"
  77 #include "memory/resourceArea.hpp"
  78 #include "memory/universe.hpp"
  79 #include "nmt/memTracker.hpp"
  80 #include "oops/access.inline.hpp"
  81 #include "oops/flatArrayKlass.inline.hpp"
  82 #include "oops/instanceClassLoaderKlass.inline.hpp"
  83 #include "oops/instanceKlass.inline.hpp"
  84 #include "oops/instanceMirrorKlass.inline.hpp"
  85 #include "oops/methodData.hpp"
  86 #include "oops/objArrayKlass.inline.hpp"
  87 #include "oops/oop.inline.hpp"
  88 #include "runtime/arguments.hpp"
  89 #include "runtime/handles.inline.hpp"
  90 #include "runtime/java.hpp"
  91 #include "runtime/safepoint.hpp"
  92 #include "runtime/threads.hpp"
  93 #include "runtime/vmThread.hpp"
  94 #include "services/memoryService.hpp"
  95 #include "utilities/align.hpp"
  96 #include "utilities/debug.hpp"
  97 #include "utilities/events.hpp"
  98 #include "utilities/formatBuffer.hpp"
  99 #include "utilities/macros.hpp"
 100 #include "utilities/stack.inline.hpp"
 101 
 102 #include <math.h>
 103 
 104 // All sizes are in HeapWords.
 105 const size_t ParallelCompactData::Log2RegionSize  = 16; // 64K words
 106 const size_t ParallelCompactData::RegionSize      = (size_t)1 << Log2RegionSize;
 107 static_assert(ParallelCompactData::RegionSize >= BitsPerWord, "region-start bit word-aligned");
 108 const size_t ParallelCompactData::RegionSizeBytes =

1411 
1412 // Split [start, end) evenly for a number of workers and return the
1413 // range for worker_id.
1414 static void split_regions_for_worker(size_t start, size_t end,
1415                                      uint worker_id, uint num_workers,
1416                                      size_t* worker_start, size_t* worker_end) {
1417   assert(start < end, "precondition");
1418   assert(num_workers > 0, "precondition");
1419   assert(worker_id < num_workers, "precondition");
1420 
1421   size_t num_regions = end - start;
1422   size_t num_regions_per_worker = num_regions / num_workers;
1423   size_t remainder = num_regions % num_workers;
1424   // The first few workers will get one extra.
1425   *worker_start = start + worker_id * num_regions_per_worker
1426                   + MIN2(checked_cast<size_t>(worker_id), remainder);
1427   *worker_end = *worker_start + num_regions_per_worker
1428                 + (worker_id < remainder ? 1 : 0);
1429 }
1430 
1431 static bool safe_to_read_header(size_t words) {
1432   precond(words > 0);
1433 
1434   // Safe to read if we have enough words for the full header, i.e., both
1435   // markWord and Klass pointer.
1436   const bool safe = words >= (size_t)oopDesc::header_size();
1437 
1438   // If using Compact Object Headers, the full header is inside the markWord,
1439   // so will always be safe to read
1440   assert(!UseCompactObjectHeaders || safe, "Compact Object Headers should always be safe");
1441 
1442   return safe;
1443 }
1444 
1445 void PSParallelCompact::forward_to_new_addr() {
1446   GCTraceTime(Info, gc, phases) tm("Forward", &_gc_timer);
1447   uint nworkers = ParallelScavengeHeap::heap()->workers().active_workers();
1448 
1449   struct ForwardTask final : public WorkerTask {
1450     uint _num_workers;
1451 
1452     explicit ForwardTask(uint num_workers) :
1453       WorkerTask("PSForward task"),
1454       _num_workers(num_workers) {}
1455 
1456     static bool should_preserve_mark(oop obj, HeapWord* end_addr) {
1457       size_t remaining_words = pointer_delta(end_addr, cast_from_oop<HeapWord*>(obj));
1458 
1459       if (Arguments::is_valhalla_enabled() && !safe_to_read_header(remaining_words)) {
1460         // When using Valhalla, it might be necessary to preserve the Valhalla-
1461         // specific bits in the markWord. If the entire object header is
1462         // copied, the correct markWord (with the appropriate Valhalla bits)
1463         // can be safely read from the Klass. However, if the full header is
1464         // not copied, we cannot safely read the Klass to obtain this information.
1465         // In such cases, we always preserve the markWord to ensure that all
1466         // relevant bits, including Valhalla-specific ones, are retained.
1467         return true;
1468       } else {
1469         return obj->mark().must_be_preserved();
1470       }
1471     }
1472 
1473     static void forward_objs_in_range(ParCompactionManager* cm,
1474                                       HeapWord* start,
1475                                       HeapWord* end,
1476                                       HeapWord* destination) {
1477       HeapWord* cur_addr = start;
1478       HeapWord* new_addr = destination;
1479 
1480       while (cur_addr < end) {
1481         cur_addr = mark_bitmap()->find_obj_beg(cur_addr, end);
1482         if (cur_addr >= end) {
1483           return;
1484         }
1485         assert(mark_bitmap()->is_marked(cur_addr), "inv");
1486         oop obj = cast_to_oop(cur_addr);
1487 
1488         if (new_addr != cur_addr) {
1489           if (should_preserve_mark(obj, end)) {
1490             cm->preserved_marks()->push_always(obj, obj->mark());
1491           }
1492 
1493           FullGCForwarding::forward_to(obj, cast_to_oop(new_addr));
1494         }
1495         size_t obj_size = obj->size();
1496         new_addr += obj_size;
1497         cur_addr += obj_size;
1498       }
1499     }
1500 
1501     void work(uint worker_id) override {
1502       ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(worker_id);
1503       for (uint id = old_space_id; id < last_space_id; ++id) {
1504         MutableSpace* sp = PSParallelCompact::space(SpaceId(id));
1505         HeapWord* dense_prefix_addr = dense_prefix(SpaceId(id));
1506         HeapWord* top = sp->top();
1507 
1508         if (dense_prefix_addr == top) {
1509           // Empty space
1510           continue;
1511         }
1512 

2113 
2114 HeapWord* PSParallelCompact::partial_obj_end(HeapWord* region_start_addr) {
2115   ParallelCompactData& sd = summary_data();
2116   assert(sd.is_region_aligned(region_start_addr), "precondition");
2117 
2118   // Use per-region partial_obj_size to locate the end of the obj, that extends
2119   // to region_start_addr.
2120   size_t start_region_idx = sd.addr_to_region_idx(region_start_addr);
2121   size_t end_region_idx = sd.region_count();
2122   size_t accumulated_size = 0;
2123   for (size_t region_idx = start_region_idx; region_idx < end_region_idx; ++region_idx) {
2124     size_t cur_partial_obj_size = sd.region(region_idx)->partial_obj_size();
2125     accumulated_size += cur_partial_obj_size;
2126     if (cur_partial_obj_size != ParallelCompactData::RegionSize) {
2127       break;
2128     }
2129   }
2130   return region_start_addr + accumulated_size;
2131 }
2132 
2133 static markWord safe_mark_word_prototype(HeapWord* cur_addr, HeapWord* end_addr) {
2134   // If the original markWord contains bits that cannot be reconstructed because
2135   // the header cannot be safely read, a placeholder is used. In this case,
2136   // the correct markWord is preserved before compaction and restored after
2137   // compaction completes.
2138   size_t remaining_words = pointer_delta(end_addr, cur_addr);
2139 
2140   if (UseCompactObjectHeaders || (Arguments::is_valhalla_enabled() && safe_to_read_header(remaining_words))) {
2141     return cast_to_oop(cur_addr)->klass()->prototype_header();
2142   } else {
2143     return markWord::prototype();
2144   }
2145 }
2146 
2147 // Use region_idx as the destination region, and evacuate all live objs on its
2148 // source regions to this destination region.
2149 void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosure& closure, size_t region_idx)
2150 {
2151   ParMarkBitMap* const bitmap = mark_bitmap();
2152   ParallelCompactData& sd = summary_data();
2153   RegionData* const region_ptr = sd.region(region_idx);
2154 
2155   // Get the source region and related info.
2156   size_t src_region_idx = region_ptr->source_region();
2157   SpaceId src_space_id = space_id(sd.region_to_addr(src_region_idx));
2158   HeapWord* src_space_top = _space_info[src_space_id].space()->top();
2159   HeapWord* dest_addr = sd.region_to_addr(region_idx);
2160 
2161   closure.set_source(first_src_addr(dest_addr, src_space_id, src_region_idx));
2162 
2163   // Adjust src_region_idx to prepare for decrementing destination counts (the
2164   // destination count is not decremented when a region is copied to itself).
2165   if (src_region_idx == region_idx) {
2166     src_region_idx += 1;

2242     HeapWord* cur_addr = closure.source();
2243     HeapWord* const end_addr = MIN2(sd.region_align_up(cur_addr + 1),
2244                                     src_space_top);
2245     // To handle the case where the final obj in source region extends to next region.
2246     HeapWord* final_obj_start = (end_addr == src_space_top)
2247                                 ? nullptr
2248                                 : sd.addr_to_region_ptr(end_addr)->partial_obj_addr();
2249     // Apply closure on objs inside [cur_addr, end_addr)
2250     do {
2251       cur_addr = bitmap->find_obj_beg(cur_addr, end_addr);
2252       if (cur_addr == end_addr) {
2253         break;
2254       }
2255       size_t obj_size;
2256       if (final_obj_start == cur_addr) {
2257         obj_size = pointer_delta(partial_obj_end(end_addr), cur_addr);
2258       } else {
2259         // This obj doesn't extend into next region; size() is safe to use.
2260         obj_size = cast_to_oop(cur_addr)->size();
2261       }
2262 
2263       markWord mark = safe_mark_word_prototype(cur_addr, end_addr);
2264 
2265       // Perform the move and update of the object
2266       closure.do_addr(cur_addr, obj_size, mark);
2267 
2268       cur_addr += obj_size;
2269     } while (cur_addr < end_addr && !closure.is_full());
2270 
2271     if (closure.is_full()) {
2272       decrement_destination_counts(cm, src_space_id, src_region_idx, closure.source());
2273       closure.complete_region(dest_addr, region_ptr);
2274       return;
2275     }
2276 
2277     decrement_destination_counts(cm, src_space_id, src_region_idx, end_addr);
2278 
2279     // Move to the next source region, possibly switching spaces as well.  All
2280     // args except end_addr may be modified.
2281     src_region_idx = next_src_region(closure, src_space_id, src_space_top, end_addr);
2282   } while (true);
2283 }
2284 
2285 void PSParallelCompact::fill_and_update_region(ParCompactionManager* cm, size_t region_idx)
2286 {
2287   MoveAndUpdateClosure cl(mark_bitmap(), region_idx);

2367 }
2368 
2369 void MoveAndUpdateClosure::copy_partial_obj(size_t partial_obj_size)
2370 {
2371   size_t words = MIN2(partial_obj_size, words_remaining());
2372 
2373   // This test is necessary; if omitted, the pointer updates to a partial object
2374   // that crosses the dense prefix boundary could be overwritten.
2375   if (source() != copy_destination()) {
2376     DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
2377     Copy::aligned_conjoint_words(source(), copy_destination(), words);
2378   }
2379   update_state(words);
2380 }
2381 
2382 void MoveAndUpdateClosure::complete_region(HeapWord* dest_addr, PSParallelCompact::RegionData* region_ptr) {
2383   assert(region_ptr->shadow_state() == ParallelCompactData::RegionData::NormalRegion, "Region should be finished");
2384   region_ptr->set_completed();
2385 }
2386 
2387 void MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words, markWord mark) {
2388   assert(destination() != nullptr, "sanity");
2389   _source = addr;
2390 
2391   // The start_array must be updated even if the object is not moving.
2392   if (_start_array != nullptr) {
2393     _start_array->update_for_block(destination(), destination() + words);
2394   }
2395 
2396   // Avoid overflow
2397   words = MIN2(words, words_remaining());
2398   assert(words > 0, "inv");
2399 
2400   if (copy_destination() != source()) {
2401     DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
2402     assert(source() != destination(), "inv");
2403     assert(FullGCForwarding::is_forwarded(cast_to_oop(source())), "inv");
2404     assert(FullGCForwarding::forwardee(cast_to_oop(source())) == cast_to_oop(destination()), "inv");
2405     Copy::aligned_conjoint_words(source(), copy_destination(), words);
2406     cast_to_oop(copy_destination())->set_mark(mark);
2407   }
2408 
2409   update_state(words);
2410 }
2411 
2412 void MoveAndUpdateShadowClosure::complete_region(HeapWord* dest_addr, PSParallelCompact::RegionData* region_ptr) {
2413   assert(region_ptr->shadow_state() == ParallelCompactData::RegionData::ShadowRegion, "Region should be shadow");
2414   // Record the shadow region index
2415   region_ptr->set_shadow_region(_shadow);
2416   // Mark the shadow region as filled to indicate the data is ready to be
2417   // copied back
2418   region_ptr->mark_filled();
2419   // Try to copy the content of the shadow region back to its corresponding
2420   // heap region if available; the GC thread that decreases the destination
2421   // count to zero will do the copying otherwise (see
2422   // PSParallelCompact::decrement_destination_counts).
2423   if (((region_ptr->available() && region_ptr->claim()) || region_ptr->claimed()) && region_ptr->mark_copied()) {
2424     region_ptr->set_completed();
2425     PSParallelCompact::copy_back(PSParallelCompact::summary_data().region_to_addr(_shadow), dest_addr);
2426     ParCompactionManager::push_shadow_region_mt_safe(_shadow);
< prev index next >