1 /* 2 * Copyright (c) 2007, 2013, 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_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_HPP 27 28 #include "memory/genOopClosures.hpp" 29 #include "memory/padded.hpp" 30 31 // Closures for ParNewGeneration 32 33 class ParScanThreadState; 34 class ParNewGeneration; 35 typedef Padded<OopTaskQueue> ObjToScanQueue; 36 typedef GenericTaskQueueSet<ObjToScanQueue, mtGC> ObjToScanQueueSet; 37 class ParallelTaskTerminator; 38 39 class ParScanClosure: public OopsInKlassOrGenClosure { 40 protected: 41 ParScanThreadState* _par_scan_state; 42 ParNewGeneration* _g; 43 HeapWord* _boundary; 44 template <class T> void inline par_do_barrier(T* p); 45 template <class T> void inline do_oop_work(T* p, 46 bool gc_barrier, 47 bool root_scan); 48 public: 49 ParScanClosure(ParNewGeneration* g, ParScanThreadState* par_scan_state); 50 }; 51 52 class ParScanWithBarrierClosure: public ParScanClosure { 53 public: ParScanWithBarrierClosure(ParNewGeneration * g,ParScanThreadState * par_scan_state)54 ParScanWithBarrierClosure(ParNewGeneration* g, 55 ParScanThreadState* par_scan_state) : 56 ParScanClosure(g, par_scan_state) {} 57 virtual void do_oop(oop* p); 58 virtual void do_oop(narrowOop* p); 59 inline void do_oop_nv(oop* p); 60 inline void do_oop_nv(narrowOop* p); 61 }; 62 63 class ParScanWithoutBarrierClosure: public ParScanClosure { 64 public: ParScanWithoutBarrierClosure(ParNewGeneration * g,ParScanThreadState * par_scan_state)65 ParScanWithoutBarrierClosure(ParNewGeneration* g, 66 ParScanThreadState* par_scan_state) : 67 ParScanClosure(g, par_scan_state) {} 68 virtual void do_oop(oop* p); 69 virtual void do_oop(narrowOop* p); 70 inline void do_oop_nv(oop* p); 71 inline void do_oop_nv(narrowOop* p); 72 }; 73 74 class ParRootScanWithBarrierTwoGensClosure: public ParScanClosure { 75 public: ParRootScanWithBarrierTwoGensClosure(ParNewGeneration * g,ParScanThreadState * par_scan_state)76 ParRootScanWithBarrierTwoGensClosure(ParNewGeneration* g, 77 ParScanThreadState* par_scan_state) : 78 ParScanClosure(g, par_scan_state) {} 79 virtual void do_oop(oop* p); 80 virtual void do_oop(narrowOop* p); 81 }; 82 83 class ParRootScanWithoutBarrierClosure: public ParScanClosure { 84 public: ParRootScanWithoutBarrierClosure(ParNewGeneration * g,ParScanThreadState * par_scan_state)85 ParRootScanWithoutBarrierClosure(ParNewGeneration* g, 86 ParScanThreadState* par_scan_state) : 87 ParScanClosure(g, par_scan_state) {} 88 virtual void do_oop(oop* p); 89 virtual void do_oop(narrowOop* p); 90 }; 91 92 class ParScanWeakRefClosure: public ScanWeakRefClosure { 93 protected: 94 ParScanThreadState* _par_scan_state; 95 template <class T> inline void do_oop_work(T* p); 96 public: 97 ParScanWeakRefClosure(ParNewGeneration* g, 98 ParScanThreadState* par_scan_state); 99 virtual void do_oop(oop* p); 100 virtual void do_oop(narrowOop* p); 101 inline void do_oop_nv(oop* p); 102 inline void do_oop_nv(narrowOop* p); 103 }; 104 105 class ParEvacuateFollowersClosure: public VoidClosure { 106 private: 107 ParScanThreadState* _par_scan_state; par_scan_state()108 ParScanThreadState* par_scan_state() { return _par_scan_state; } 109 110 // We want to preserve the specific types here (rather than "OopClosure") 111 // for later de-virtualization of do_oop calls. 112 ParScanWithoutBarrierClosure* _to_space_closure; to_space_closure()113 ParScanWithoutBarrierClosure* to_space_closure() { 114 return _to_space_closure; 115 } 116 ParRootScanWithoutBarrierClosure* _to_space_root_closure; to_space_root_closure()117 ParRootScanWithoutBarrierClosure* to_space_root_closure() { 118 return _to_space_root_closure; 119 } 120 121 ParScanWithBarrierClosure* _old_gen_closure; old_gen_closure()122 ParScanWithBarrierClosure* old_gen_closure () { 123 return _old_gen_closure; 124 } 125 ParRootScanWithBarrierTwoGensClosure* _old_gen_root_closure; old_gen_root_closure()126 ParRootScanWithBarrierTwoGensClosure* old_gen_root_closure () { 127 return _old_gen_root_closure; 128 } 129 130 ParNewGeneration* _par_gen; par_gen()131 ParNewGeneration* par_gen() { return _par_gen; } 132 133 ObjToScanQueueSet* _task_queues; task_queues()134 ObjToScanQueueSet* task_queues() { return _task_queues; } 135 136 ParallelTaskTerminator* _terminator; terminator()137 ParallelTaskTerminator* terminator() { return _terminator; } 138 public: 139 ParEvacuateFollowersClosure( 140 ParScanThreadState* par_scan_state_, 141 ParScanWithoutBarrierClosure* to_space_closure_, 142 ParScanWithBarrierClosure* old_gen_closure_, 143 ParRootScanWithoutBarrierClosure* to_space_root_closure_, 144 ParNewGeneration* par_gen_, 145 ParRootScanWithBarrierTwoGensClosure* old_gen_root_closure_, 146 ObjToScanQueueSet* task_queues_, 147 ParallelTaskTerminator* terminator_); 148 virtual void do_void(); 149 }; 150 151 #endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_HPP 152