< prev index next >

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

Print this page

  53 #include "gc/shared/gcVMOperations.hpp"
  54 #include "gc/shared/partialArraySplitter.inline.hpp"
  55 #include "gc/shared/partialArrayState.hpp"
  56 #include "gc/shared/partialArrayTaskStats.hpp"
  57 #include "gc/shared/referencePolicy.hpp"
  58 #include "gc/shared/suspendibleThreadSet.hpp"
  59 #include "gc/shared/taskqueue.inline.hpp"
  60 #include "gc/shared/taskTerminator.hpp"
  61 #include "gc/shared/weakProcessor.inline.hpp"
  62 #include "gc/shared/workerPolicy.hpp"
  63 #include "jvm.h"
  64 #include "logging/log.hpp"
  65 #include "memory/allocation.hpp"
  66 #include "memory/iterator.hpp"
  67 #include "memory/metaspaceUtils.hpp"
  68 #include "memory/resourceArea.hpp"
  69 #include "memory/universe.hpp"
  70 #include "nmt/memTracker.hpp"
  71 #include "oops/access.inline.hpp"
  72 #include "oops/oop.inline.hpp"

  73 #include "runtime/globals_extension.hpp"
  74 #include "runtime/handles.inline.hpp"
  75 #include "runtime/java.hpp"
  76 #include "runtime/orderAccess.hpp"
  77 #include "runtime/os.hpp"
  78 #include "runtime/prefetch.inline.hpp"
  79 #include "runtime/threads.hpp"
  80 #include "utilities/align.hpp"
  81 #include "utilities/checkedCast.hpp"
  82 #include "utilities/formatBuffer.hpp"
  83 #include "utilities/growableArray.hpp"
  84 #include "utilities/powerOfTwo.hpp"
  85 
  86 G1CMIsAliveClosure::G1CMIsAliveClosure() : _cm(nullptr) { }
  87 
  88 G1CMIsAliveClosure::G1CMIsAliveClosure(G1ConcurrentMark* cm) : _cm(cm) {
  89   assert(cm != nullptr, "must be");
  90 }
  91 
  92 void G1CMIsAliveClosure::initialize(G1ConcurrentMark* cm) {

2337     target_size = 0;
2338   }
2339 
2340   if (_task_queue->size() > target_size) {
2341     G1TaskQueueEntry entry;
2342     bool ret = _task_queue->pop_local(entry);
2343     while (ret) {
2344       process_entry(entry, false /* stolen */);
2345       if (_task_queue->size() <= target_size || has_aborted()) {
2346         ret = false;
2347       } else {
2348         ret = _task_queue->pop_local(entry);
2349       }
2350     }
2351   }
2352 }
2353 
2354 size_t G1CMTask::start_partial_array_processing(objArrayOop obj) {
2355   assert(obj->length() >= (int)ObjArrayMarkingStride, "Must be a large array object %d", obj->length());
2356 
2357   // Mark objArray klass metadata
2358   process_klass(obj->klass());
2359 
2360   size_t array_length = obj->length();
2361   size_t initial_chunk_size = _partial_array_splitter.start(_task_queue, obj, nullptr, array_length, ObjArrayMarkingStride);
2362 
2363   process_array_chunk(obj, 0, initial_chunk_size);
2364 
2365   // Include object header size
2366   return objArrayOopDesc::object_size(checked_cast<int>(initial_chunk_size));





2367 }
2368 
2369 size_t G1CMTask::process_partial_array(const G1TaskQueueEntry& task, bool stolen) {
2370   PartialArrayState* state = task.to_partial_array_state();
2371   // Access state before release by claim().
2372   objArrayOop obj = objArrayOop(state->source());
2373 
2374   PartialArraySplitter::Claim claim =
2375     _partial_array_splitter.claim(state, _task_queue, stolen);
2376 
2377   process_array_chunk(obj, claim._start, claim._end);
2378   return heap_word_size((claim._end - claim._start) * heapOopSize);








2379 }
2380 
2381 void G1CMTask::drain_global_stack(bool partially) {
2382   if (has_aborted()) {
2383     return;
2384   }
2385 
2386   // We have a policy to drain the local queue before we attempt to
2387   // drain the global stack.
2388   assert(partially || _task_queue->size() == 0, "invariant");
2389 
2390   // Decide what the target size is, depending whether we're going to
2391   // drain it partially (so that other tasks can steal if they run out
2392   // of things to do) or totally (at the very end).
2393   // Notice that when draining the global mark stack partially, due to the racyness
2394   // of the mark stack size update we might in fact drop below the target. But,
2395   // this is not a problem.
2396   // In case of total draining, we simply process until the global mark stack is
2397   // totally empty, disregarding the size counter.
2398   if (partially) {

  53 #include "gc/shared/gcVMOperations.hpp"
  54 #include "gc/shared/partialArraySplitter.inline.hpp"
  55 #include "gc/shared/partialArrayState.hpp"
  56 #include "gc/shared/partialArrayTaskStats.hpp"
  57 #include "gc/shared/referencePolicy.hpp"
  58 #include "gc/shared/suspendibleThreadSet.hpp"
  59 #include "gc/shared/taskqueue.inline.hpp"
  60 #include "gc/shared/taskTerminator.hpp"
  61 #include "gc/shared/weakProcessor.inline.hpp"
  62 #include "gc/shared/workerPolicy.hpp"
  63 #include "jvm.h"
  64 #include "logging/log.hpp"
  65 #include "memory/allocation.hpp"
  66 #include "memory/iterator.hpp"
  67 #include "memory/metaspaceUtils.hpp"
  68 #include "memory/resourceArea.hpp"
  69 #include "memory/universe.hpp"
  70 #include "nmt/memTracker.hpp"
  71 #include "oops/access.inline.hpp"
  72 #include "oops/oop.inline.hpp"
  73 #include "oops/oopCast.inline.hpp"
  74 #include "runtime/globals_extension.hpp"
  75 #include "runtime/handles.inline.hpp"
  76 #include "runtime/java.hpp"
  77 #include "runtime/orderAccess.hpp"
  78 #include "runtime/os.hpp"
  79 #include "runtime/prefetch.inline.hpp"
  80 #include "runtime/threads.hpp"
  81 #include "utilities/align.hpp"
  82 #include "utilities/checkedCast.hpp"
  83 #include "utilities/formatBuffer.hpp"
  84 #include "utilities/growableArray.hpp"
  85 #include "utilities/powerOfTwo.hpp"
  86 
  87 G1CMIsAliveClosure::G1CMIsAliveClosure() : _cm(nullptr) { }
  88 
  89 G1CMIsAliveClosure::G1CMIsAliveClosure(G1ConcurrentMark* cm) : _cm(cm) {
  90   assert(cm != nullptr, "must be");
  91 }
  92 
  93 void G1CMIsAliveClosure::initialize(G1ConcurrentMark* cm) {

2338     target_size = 0;
2339   }
2340 
2341   if (_task_queue->size() > target_size) {
2342     G1TaskQueueEntry entry;
2343     bool ret = _task_queue->pop_local(entry);
2344     while (ret) {
2345       process_entry(entry, false /* stolen */);
2346       if (_task_queue->size() <= target_size || has_aborted()) {
2347         ret = false;
2348       } else {
2349         ret = _task_queue->pop_local(entry);
2350       }
2351     }
2352   }
2353 }
2354 
2355 size_t G1CMTask::start_partial_array_processing(objArrayOop obj) {
2356   assert(obj->length() >= (int)ObjArrayMarkingStride, "Must be a large array object %d", obj->length());
2357 
2358   // Mark klass metadata
2359   process_klass(obj->klass());
2360 
2361   size_t array_length = obj->length();
2362   size_t initial_chunk_size = _partial_array_splitter.start(_task_queue, obj, nullptr, array_length, ObjArrayMarkingStride);
2363 
2364   process_array_chunk(obj, 0, initial_chunk_size);
2365 
2366   // Include object header size
2367   if (obj->is_refArray()) {
2368     return refArrayOopDesc::object_size(checked_cast<int>(initial_chunk_size));
2369   } else {
2370     FlatArrayKlass* fak = FlatArrayKlass::cast(obj->klass());
2371     return flatArrayOopDesc::object_size(fak->layout_helper(), checked_cast<int>(initial_chunk_size));
2372   }
2373 }
2374 
2375 size_t G1CMTask::process_partial_array(const G1TaskQueueEntry& task, bool stolen) {
2376   PartialArrayState* state = task.to_partial_array_state();
2377   // Access state before release by claim().
2378   objArrayOop obj = oop_cast<objArrayOop>(state->source());
2379 
2380   PartialArraySplitter::Claim claim =
2381     _partial_array_splitter.claim(state, _task_queue, stolen);
2382 
2383   process_array_chunk(obj, claim._start, claim._end);
2384 
2385   if (obj->is_refArray()) {
2386     return heap_word_size((claim._end - claim._start) * heapOopSize);
2387   } else {
2388     assert(obj->is_flatArray(), "Must be!");
2389     size_t element_byte_size = FlatArrayKlass::cast(obj->klass())->element_byte_size();
2390     size_t nof_elements = claim._end - claim._start;
2391     return heap_word_size(nof_elements * element_byte_size);
2392   }
2393 }
2394 
2395 void G1CMTask::drain_global_stack(bool partially) {
2396   if (has_aborted()) {
2397     return;
2398   }
2399 
2400   // We have a policy to drain the local queue before we attempt to
2401   // drain the global stack.
2402   assert(partially || _task_queue->size() == 0, "invariant");
2403 
2404   // Decide what the target size is, depending whether we're going to
2405   // drain it partially (so that other tasks can steal if they run out
2406   // of things to do) or totally (at the very end).
2407   // Notice that when draining the global mark stack partially, due to the racyness
2408   // of the mark stack size update we might in fact drop below the target. But,
2409   // this is not a problem.
2410   // In case of total draining, we simply process until the global mark stack is
2411   // totally empty, disregarding the size counter.
2412   if (partially) {
< prev index next >