| 1 | /* |
| 2 | * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | * accompanied this code). |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License version |
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | * or visit www.oracle.com if you need additional information or have any |
| 21 | * questions. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include "precompiled.hpp" |
| 26 | #include "classfile/classLoaderDataGraph.hpp" |
| 27 | #include "gc/g1/g1CollectedHeap.hpp" |
| 28 | #include "gc/g1/g1FullCollector.hpp" |
| 29 | #include "gc/g1/g1FullGCMarker.hpp" |
| 30 | #include "gc/g1/g1FullGCMarkTask.hpp" |
| 31 | #include "gc/g1/g1FullGCOopClosures.inline.hpp" |
| 32 | #include "gc/g1/g1FullGCReferenceProcessorExecutor.hpp" |
| 33 | #include "gc/shared/gcTraceTime.inline.hpp" |
| 34 | #include "gc/shared/referenceProcessor.hpp" |
| 35 | #include "memory/iterator.inline.hpp" |
| 36 | |
| 37 | G1FullGCMarkTask::G1FullGCMarkTask(G1FullCollector* collector) : |
| 38 | G1FullGCTask("G1 Parallel Marking Task" , collector), |
| 39 | _root_processor(G1CollectedHeap::heap(), collector->workers()), |
| 40 | _terminator(collector->workers(), collector->array_queue_set()) { |
| 41 | // Need cleared claim bits for the roots processing |
| 42 | ClassLoaderDataGraph::clear_claimed_marks(); |
| 43 | } |
| 44 | |
| 45 | void G1FullGCMarkTask::work(uint worker_id) { |
| 46 | Ticks start = Ticks::now(); |
| 47 | ResourceMark rm; |
| 48 | G1FullGCMarker* marker = collector()->marker(worker_id); |
| 49 | MarkingCodeBlobClosure code_closure(marker->mark_closure(), !CodeBlobToOopClosure::FixRelocations); |
| 50 | |
| 51 | if (ClassUnloading) { |
| 52 | _root_processor.process_strong_roots(marker->mark_closure(), |
| 53 | marker->cld_closure(), |
| 54 | &code_closure); |
| 55 | } else { |
| 56 | _root_processor.process_all_roots(marker->mark_closure(), |
| 57 | marker->cld_closure(), |
| 58 | &code_closure); |
| 59 | } |
| 60 | |
| 61 | // Mark stack is populated, now process and drain it. |
| 62 | marker->complete_marking(collector()->oop_queue_set(), collector()->array_queue_set(), _terminator.terminator()); |
| 63 | |
| 64 | // This is the point where the entire marking should have completed. |
| 65 | assert(marker->oop_stack()->is_empty(), "Marking should have completed" ); |
| 66 | assert(marker->objarray_stack()->is_empty(), "Array marking should have completed" ); |
| 67 | log_task("Marking task" , worker_id, start); |
| 68 | } |
| 69 | |