1 /*
2 * Copyright (c) 2017, 2018, 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 #ifndef SHARE_GC_Z_ZNMETHODTABLE_HPP
25 #define SHARE_GC_Z_ZNMETHODTABLE_HPP
26
27 #include "gc/z/zArray.hpp"
28 #include "gc/z/zGlobals.hpp"
29 #include "gc/z/zLock.hpp"
30 #include "gc/z/zNMethodTableEntry.hpp"
31 #include "gc/z/zNMethodTableIteration.hpp"
32 #include "memory/allocation.hpp"
33
34 class nmethod;
35 class ZNMethodClosure;
36 class ZNMethodData;
37 class ZNMethodDataOops;
38 class ZWorkers;
39
40 class ZNMethodTable : public AllStatic {
41 private:
42 static ZNMethodTableEntry* _table;
43 static size_t _size;
44 static size_t _nregistered;
45 static size_t _nunregistered;
46 static ZNMethodTableIteration _iteration;
47
48 static ZNMethodTableEntry* create(size_t size);
49 static void destroy(ZNMethodTableEntry* table);
50
51 static void attach_gc_data(nmethod* nm);
52 static void detach_gc_data(nmethod* nm);
53
54 static size_t first_index(const nmethod* nm, size_t size);
55 static size_t next_index(size_t prev_index, size_t size);
56
57 static void wait_until_iteration_done();
58
59 static bool register_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm);
60 static void unregister_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm);
61
62 static void rebuild(size_t new_size);
63 static void rebuild_if_needed();
64
65 static void log_register(const nmethod* nm);
66 static void log_unregister(const nmethod* nm);
67
68 public:
69 static size_t registered_nmethods();
70 static size_t unregistered_nmethods();
71
72 static void register_nmethod(nmethod* nm);
73 static void unregister_nmethod(nmethod* nm);
74 static void disarm_nmethod(nmethod* nm);
75
76 static ZReentrantLock* lock_for_nmethod(nmethod* nm);
77
78 static void oops_do(OopClosure* cl);
79
80 static void oops_do(nmethod* nm, OopClosure* cl);
81
82 static void nmethods_do_begin();
83 static void nmethods_do_end();
84 static void nmethods_do(ZNMethodClosure* cl);
85
86 static void unlink(ZWorkers* workers, bool unloading_occurred);
87 static void purge(ZWorkers* workers);
88 };
89
90 #endif // SHARE_GC_Z_ZNMETHODTABLE_HPP
|
1 /*
2 * Copyright (c) 2017, 2019, 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 #ifndef SHARE_GC_Z_ZNMETHODTABLE_HPP
25 #define SHARE_GC_Z_ZNMETHODTABLE_HPP
26
27 #include "gc/z/zNMethodTableIteration.hpp"
28 #include "memory/allocation.hpp"
29
30 class nmethod;
31 class ZNMethodClosure;
32 class ZNMethodTableEntry;
33 class ZWorkers;
34
35 class ZNMethodTable : public AllStatic {
36 private:
37 static ZNMethodTableEntry* _table;
38 static size_t _size;
39 static size_t _nregistered;
40 static size_t _nunregistered;
41 static ZNMethodTableIteration _iteration;
42
43 static ZNMethodTableEntry* create(size_t size);
44 static void destroy(ZNMethodTableEntry* table);
45
46 static size_t first_index(const nmethod* nm, size_t size);
47 static size_t next_index(size_t prev_index, size_t size);
48
49 static bool register_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm);
50 static void unregister_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm);
51
52 static void rebuild(size_t new_size);
53 static void rebuild_if_needed();
54
55 public:
56 static size_t registered_nmethods();
57 static size_t unregistered_nmethods();
58
59 static void register_nmethod(nmethod* nm);
60 static void unregister_nmethod(nmethod* nm);
61
62 static void wait_until_iteration_done();
63
64 static void nmethods_do_begin();
65 static void nmethods_do_end();
66 static void nmethods_do(ZNMethodClosure* cl);
67
68 static void unlink(ZWorkers* workers, bool unloading_occurred);
69 static void purge(ZWorkers* workers);
70 };
71
72 #endif // SHARE_GC_Z_ZNMETHODTABLE_HPP
|