1 /* 2 * Copyright (c) 2017, 2020, 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_SHENANDOAHCODEROOTS_HPP 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP 27 28 #include "code/codeCache.hpp" 29 #include "gc/shenandoah/shenandoahSharedVariables.hpp" 30 #include "gc/shenandoah/shenandoahLock.hpp" 31 #include "gc/shenandoah/shenandoahPadding.hpp" 32 #include "memory/allocation.hpp" 33 #include "memory/iterator.hpp" 34 #include "utilities/globalDefinitions.hpp" 35 36 class ShenandoahHeap; 37 class ShenandoahHeapRegion; 38 class ShenandoahNMethodTable; 39 class ShenandoahNMethodTableSnapshot; 40 class WorkGang; 41 42 class ShenandoahParallelCodeHeapIterator { 43 friend class CodeCache; 44 private: 45 CodeHeap* _heap; 46 shenandoah_padding(0); 47 volatile int _claimed_idx; 48 volatile bool _finished; 49 shenandoah_padding(1); 50 public: 51 ShenandoahParallelCodeHeapIterator(CodeHeap* heap); 52 void parallel_blobs_do(CodeBlobClosure* f); 53 }; 54 55 class ShenandoahParallelCodeCacheIterator { 56 friend class CodeCache; 57 private: 58 ShenandoahParallelCodeHeapIterator* _iters; 59 int _length; 60 61 NONCOPYABLE(ShenandoahParallelCodeCacheIterator); 62 63 public: 64 ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps); 65 ~ShenandoahParallelCodeCacheIterator(); 66 void parallel_blobs_do(CodeBlobClosure* f); 67 }; 68 69 class ShenandoahCodeRootsIterator { 70 friend class ShenandoahCodeRoots; 71 protected: 72 ShenandoahParallelCodeCacheIterator _par_iterator; 73 ShenandoahSharedFlag _seq_claimed; 74 ShenandoahNMethodTableSnapshot* _table_snapshot; 75 76 public: 77 ShenandoahCodeRootsIterator(); 78 ~ShenandoahCodeRootsIterator(); 79 80 void possibly_parallel_blobs_do(CodeBlobClosure *f); 81 }; 82 83 class ShenandoahCodeRoots : public AllStatic { 84 friend class ShenandoahHeap; 85 friend class ShenandoahCodeRootsIterator; 86 87 public: 88 static void initialize(); 89 static void register_nmethod(nmethod* nm); 90 static void unregister_nmethod(nmethod* nm); 91 static void flush_nmethod(nmethod* nm); 92 table()93 static ShenandoahNMethodTable* table() { 94 return _nmethod_table; 95 } 96 97 // Concurrent nmethod unloading support 98 static void unlink(WorkGang* workers, bool unloading_occurred); 99 static void purge(WorkGang* workers); 100 static void arm_nmethods(); 101 static void disarm_nmethods(); disarmed_value()102 static int disarmed_value() { return _disarmed_value; } disarmed_value_address()103 static int* disarmed_value_address() { return &_disarmed_value; } 104 105 private: 106 static ShenandoahNMethodTable* _nmethod_table; 107 static int _disarmed_value; 108 }; 109 110 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP 111