1 /*
2 * Copyright (c) 2017, 2022, 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/shenandoahLock.hpp"
30 #include "gc/shenandoah/shenandoahPadding.hpp"
31 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
32 #include "memory/allStatic.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 WorkerThreads;
41
42 class ShenandoahCodeRootsIterator {
43 friend class ShenandoahCodeRoots;
44 protected:
45 ShenandoahNMethodTableSnapshot* _table_snapshot;
46
47 public:
48 ShenandoahCodeRootsIterator();
49 ~ShenandoahCodeRootsIterator();
50
51 void possibly_parallel_nmethods_do(NMethodClosure *f);
52 };
53
54 class ShenandoahCodeRoots : public AllStatic {
55 friend class ShenandoahHeap;
56 friend class ShenandoahCodeRootsIterator;
57
58 public:
59 static void initialize();
60 static void register_nmethod(nmethod* nm);
61 static void unregister_nmethod(nmethod* nm);
62
63 static ShenandoahNMethodTable* table() {
64 return _nmethod_table;
65 }
66
67 // Concurrent nmethod unloading support
68 static void unlink(WorkerThreads* workers, bool unloading_occurred);
69 static void purge();
70 static void arm_nmethods_for_mark();
71 static void arm_nmethods_for_evac();
72 static void disarm_nmethods();
73 static int disarmed_value() { return _disarmed_value; }
74 static int* disarmed_value_address() { return &_disarmed_value; }
75
76 static bool use_nmethod_barriers_for_mark();
77
78 private:
79 static ShenandoahNMethodTable* _nmethod_table;
80 static int _disarmed_value;
81 };
82
83 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP