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 31 class BoolObjectClosure; 32 class CodeBlobClosure; 33 class CodeBlobToOopClosure; 34 class nmethod; 35 36 class ScavengableNMethods : public AllStatic { 37 friend class VMStructs; 38 39 static nmethod* _head; 40 static BoolObjectClosure* _is_scavengable; 41 42 public: 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 static void flush_nmethod(nmethod* nm); 49 50 static void prune_nmethods(); 51 52 // Apply f to every live code blob in scavengable nmethods. Prune nmethods 53 // from the list of scavengable nmethods if f->fix_relocations() and a nmethod 54 // no longer has scavengable oops. If f->fix_relocations(), then f must copy 55 // objects to their new location immediately to avoid fixing nmethods on the 56 // basis of the old object locations. 57 static void scavengable_nmethods_do(CodeBlobToOopClosure* f); 58 59 static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN; 60 61 private: 62 static void unlist_nmethod(nmethod* nm, nmethod* prev); 63 64 static bool has_scavengable_oops(nmethod* nm); 65 66 static void mark_on_list_nmethods() PRODUCT_RETURN; 67 static void verify_unlisted_nmethods(CodeBlobClosure* f_or_null) PRODUCT_RETURN; 68 }; 69 70 #endif // SHARE_GC_SHARED_SCAVENGABLENMETHODS_HPP