| 1 | /* |
| 2 | * Copyright (c) 2017, 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 | #ifndef SHARE_GC_G1_G1FULLGCMARKER_HPP |
| 26 | #define SHARE_GC_G1_G1FULLGCMARKER_HPP |
| 27 | |
| 28 | #include "gc/g1/g1FullGCOopClosures.hpp" |
| 29 | #include "gc/shared/preservedMarks.hpp" |
| 30 | #include "gc/shared/taskqueue.hpp" |
| 31 | #include "memory/iterator.hpp" |
| 32 | #include "oops/markOop.hpp" |
| 33 | #include "oops/oop.hpp" |
| 34 | #include "runtime/timer.hpp" |
| 35 | #include "utilities/chunkedList.hpp" |
| 36 | #include "utilities/growableArray.hpp" |
| 37 | #include "utilities/stack.hpp" |
| 38 | |
| 39 | typedef OverflowTaskQueue<oop, mtGC> OopQueue; |
| 40 | typedef OverflowTaskQueue<ObjArrayTask, mtGC> ObjArrayTaskQueue; |
| 41 | |
| 42 | typedef GenericTaskQueueSet<OopQueue, mtGC> OopQueueSet; |
| 43 | typedef GenericTaskQueueSet<ObjArrayTaskQueue, mtGC> ObjArrayTaskQueueSet; |
| 44 | |
| 45 | class G1CMBitMap; |
| 46 | |
| 47 | class G1FullGCMarker : public CHeapObj<mtGC> { |
| 48 | uint _worker_id; |
| 49 | // Backing mark bitmap |
| 50 | G1CMBitMap* _bitmap; |
| 51 | |
| 52 | // Mark stack |
| 53 | OopQueue _oop_stack; |
| 54 | ObjArrayTaskQueue _objarray_stack; |
| 55 | PreservedMarks* _preserved_stack; |
| 56 | |
| 57 | // Marking closures |
| 58 | G1MarkAndPushClosure _mark_closure; |
| 59 | G1VerifyOopClosure _verify_closure; |
| 60 | G1FollowStackClosure _stack_closure; |
| 61 | CLDToOopClosure _cld_closure; |
| 62 | |
| 63 | inline bool is_empty(); |
| 64 | inline bool pop_object(oop& obj); |
| 65 | inline bool pop_objarray(ObjArrayTask& array); |
| 66 | inline void push_objarray(oop obj, size_t index); |
| 67 | inline bool mark_object(oop obj); |
| 68 | |
| 69 | // Marking helpers |
| 70 | inline void follow_object(oop obj); |
| 71 | inline void follow_array(objArrayOop array); |
| 72 | inline void follow_array_chunk(objArrayOop array, int index); |
| 73 | public: |
| 74 | G1FullGCMarker(uint worker_id, PreservedMarks* preserved_stack, G1CMBitMap* bitmap); |
| 75 | ~G1FullGCMarker(); |
| 76 | |
| 77 | // Stack getters |
| 78 | OopQueue* oop_stack() { return &_oop_stack; } |
| 79 | ObjArrayTaskQueue* objarray_stack() { return &_objarray_stack; } |
| 80 | PreservedMarks* preserved_stack() { return _preserved_stack; } |
| 81 | |
| 82 | // Marking entry points |
| 83 | template <class T> inline void mark_and_push(T* p); |
| 84 | inline void follow_klass(Klass* k); |
| 85 | inline void follow_cld(ClassLoaderData* cld); |
| 86 | |
| 87 | inline void drain_stack(); |
| 88 | void complete_marking(OopQueueSet* oop_stacks, |
| 89 | ObjArrayTaskQueueSet* array_stacks, |
| 90 | ParallelTaskTerminator* terminator); |
| 91 | |
| 92 | // Closure getters |
| 93 | CLDToOopClosure* cld_closure() { return &_cld_closure; } |
| 94 | G1MarkAndPushClosure* mark_closure() { return &_mark_closure; } |
| 95 | G1FollowStackClosure* stack_closure() { return &_stack_closure; } |
| 96 | }; |
| 97 | |
| 98 | #endif // SHARE_GC_G1_G1FULLGCMARKER_HPP |
| 99 | |