1/*
2 * Copyright (c) 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
25#ifndef SHARE_GC_SHARED_SCAVENGABLENMETHODS_HPP
26#define SHARE_GC_SHARED_SCAVENGABLENMETHODS_HPP
27
28#include "memory/allocation.hpp"
29#include "utilities/macros.hpp"
30
31class BoolObjectClosure;
32class CodeBlobClosure;
33class CodeBlobToOopClosure;
34class nmethod;
35
36class ScavengableNMethods : public AllStatic {
37 friend class VMStructs;
38
39 static nmethod* _head;
40 static BoolObjectClosure* _is_scavengable;
41
42public:
43 static void initialize(BoolObjectClosure* is_scavengable);
44
45 static void register_nmethod(nmethod* nm);
46 static void unregister_nmethod(nmethod* nm);
47 static void verify_nmethod(nmethod* nm);
48
49 // Remove nmethods that no longer have scavengable oops.
50 static void prune_nmethods();
51
52 // Apply closure to every scavengable nmethod.
53 // Remove nmethods that no longer have scavengable oops.
54 static void nmethods_do(CodeBlobToOopClosure* cl);
55
56 static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* cl) PRODUCT_RETURN;
57
58private:
59 static void nmethods_do_and_prune(CodeBlobToOopClosure* cl);
60 static void unlist_nmethod(nmethod* nm, nmethod* prev);
61
62 static bool has_scavengable_oops(nmethod* nm);
63
64 static void mark_on_list_nmethods() PRODUCT_RETURN;
65 static void verify_unlisted_nmethods(CodeBlobClosure* cl) PRODUCT_RETURN;
66};
67
68#endif // SHARE_GC_SHARED_SCAVENGABLENMETHODS_HPP
69