1 /* 2 * Copyright (c) 2018, 2019, Red Hat, Inc. 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_SHENANDOAH_SHENANDOAHTRAVERSALGC_HPP 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_HPP 27 28 #include "memory/allocation.hpp" 29 #include "gc/shenandoah/shenandoahHeap.hpp" 30 #include "gc/shenandoah/shenandoahHeapRegionSet.hpp" 31 #include "gc/shenandoah/shenandoahTaskqueue.hpp" 32 #include "runtime/thread.hpp" 33 34 class ShenandoahTraversalGC : public CHeapObj<mtGC> { 35 private: 36 ShenandoahHeap* const _heap; 37 ShenandoahObjToScanQueueSet* const _task_queues; 38 ShenandoahHeapRegionSet _traversal_set; 39 40 public: 41 ShenandoahTraversalGC(ShenandoahHeap* heap, size_t num_regions); 42 ~ShenandoahTraversalGC(); 43 44 ShenandoahHeapRegionSet* traversal_set() { return &_traversal_set; } 45 46 void reset(); 47 void prepare(); 48 void init_traversal_collection(); 49 void concurrent_traversal_collection(); 50 void final_traversal_collection(); 51 52 template <class T, bool STRING_DEDUP, bool DEGEN, bool ATOMIC_UPDATE> 53 inline void process_oop(T* p, Thread* thread, ShenandoahObjToScanQueue* queue, ShenandoahMarkingContext* const mark_context); 54 55 bool check_and_handle_cancelled_gc(ShenandoahTaskTerminator* terminator, bool sts_yield); 56 57 ShenandoahObjToScanQueueSet* task_queues(); 58 59 void main_loop(uint worker_id, ShenandoahTaskTerminator* terminator, bool sts_yield); 60 61 private: 62 void prepare_regions(); 63 64 template <class T> 65 void main_loop_work(T* cl, jushort* live_data, uint worker_id, ShenandoahTaskTerminator* terminator, bool sts_yield); 66 67 void preclean_weak_refs(); 68 void weak_refs_work(); 69 void weak_refs_work_doit(); 70 71 void fixup_roots(); 72 void verify_roots_after_gc(); 73 }; 74 75 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_HPP