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